Questions tagged [perl]

Perl is a procedural, high-level, general-purpose, dynamic programming language, known for its native support of regular expressions and string parsing capabilities. Please use this tag for questions about Perl in general. For things related to the new (but related) language Raku (formerly "Perl 6"), please use the raku tag. For Perl-style regular expressions in other languages, use the regex tag, or, if they are based on the PCRE library, the pcre tag.

Perl is a highly capable, feature-rich programming language with over 25 years of development. Perl runs on over 100 platforms from portables to mainframes and is suitable for both rapid prototyping and large-scale development projects.

Perl can also refer to a family of high-level, general-purpose, interpreted, dynamic programming languages. The languages in this family include Perl and Raku (formerly known as Perl 6). For Raku-related questions, please use the tag . For "Perl-style" regular expressions in other languages, often based on the PCRE library, do not use tag , but tag or a more specific tag such as tag .

Related Resources

Perl-related Blogs and Bloggers

Free Perl Programming Books

Perl Programming Books

Related tags

Date & Time

Libraries for working with dates and times

Devices

Libraries to talk to physical devices

DevOps Tools

Libraries that help when you want to deploy software across networks on several hosts that are working across computer networks

  • Rex - Remote Execution

FAQs

Frequently ask questions

More information

67820 questions
809
votes
48 answers

How to fix a locale setting warning from Perl

When I run perl, I get the warning: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = (unset), LC_ALL = (unset), LANG = "en_US.UTF-8" are supported and installed on your system. perl:…
xain
  • 13,159
  • 17
  • 75
  • 119
594
votes
7 answers

Why does modern Perl avoid UTF-8 by default?

I wonder why most modern solutions built using Perl don't enable UTF-8 by default. I understand there are many legacy problems for core Perl scripts, where it may break things. But, from my point of view, in the 21st century, big new projects (or…
w.k
  • 8,218
  • 4
  • 32
  • 55
523
votes
6 answers

Why is this program valid? I was trying to create a syntax error

I'm running ActiveState's 32 bit ActivePerl 5.14.2 on Windows 7. I wanted to mess around with a Git pre-commit hook to detect programs being checked in with syntax errors. (Somehow I just managed to do such a bad commit.) So as a test program I…
Bill Ruppert
  • 8,956
  • 7
  • 27
  • 44
396
votes
7 answers

Match whitespace but not newlines

I sometimes want to match whitespace but not newline. So far I've been resorting to [ \t]. Is there a less awkward way?
JoelFan
  • 37,465
  • 35
  • 132
  • 205
352
votes
12 answers

Why are scripting languages (e.g. Perl, Python, and Ruby) not suitable as shell languages?

What are the differences between shell languages like Bash (bash), Z shell (zsh), Fish (fish) and the scripting languages above that makes them more suitable for the shell? When using the command line, the shell languages seem to be much easier. It…
Muhammad Alkarouri
  • 23,884
  • 19
  • 66
  • 101
330
votes
7 answers

Regex to match any character including new lines

Is there a regex to match "all characters including newlines"? For example, in the regex below, there is no output from $2 because (.+?) doesn't include new lines when matching. $string = "START Curabitur mollis, dolor ut rutrum consequat, arcu…
kurotsuki
  • 4,357
  • 8
  • 25
  • 28
321
votes
5 answers

How do I break out of a loop in Perl?

I'm trying to use a break statement in a for loop, but since I'm also using strict subs in my Perl code, I'm getting an error saying: Bareword "break" not allowed while "strict subs" in use at ./final.pl line 154. Is there a workaround for…
Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
309
votes
24 answers

How can I start an interactive console for Perl?

How can I start an interactive console for Perl, similar to the irb command for Ruby or python for Python?
ibz
  • 44,461
  • 24
  • 70
  • 86
287
votes
5 answers

What are the differences between Perl, Python, AWK and sed?

What are the main differences among them? And in which typical scenarios is it better to use each language?
Khaled Al Hourani
  • 3,277
  • 3
  • 20
  • 17
278
votes
12 answers

How can I check if a Perl array contains a particular value?

I am trying to figure out a way of checking for the existence of a value in an array without iterating through the array. I am reading a file for a parameter. I have a long list of parameters I do not want to deal with. I placed these unwanted…
Mel
  • 3,855
  • 4
  • 24
  • 19
277
votes
12 answers

Find size of an array in Perl

I seem to have come across several different ways to find the size of an array. What is the difference between these three methods? my @arr = (2); print scalar @arr; # First way to print array size print $#arr; # Second way to print array size my…
David
  • 2,825
  • 2
  • 16
  • 8
266
votes
5 answers

What's the difference between Perl's backticks, system, and exec?

Can someone please help me? In Perl, what is the difference between: exec "command"; and system("command"); and print `command`; Are there other ways to run shell commands too?
rlbond
  • 65,341
  • 56
  • 178
  • 228
244
votes
33 answers

How can I quickly sum all numbers in a file?

I have a file which contains several thousand numbers, each on its own line: 34 42 11 6 2 99 ... I'm looking to write a script which will print the sum of all numbers in the file. I've got a solution, but it's not very efficient. (It takes several…
Mark Roberts
  • 3,159
  • 3
  • 24
  • 13
243
votes
9 answers

How do I use boolean variables in Perl?

I have tried: $var = false; $var = FALSE; $var = False; None of these work. I get the error message Bareword "false" not allowed while "strict subs" is in use.
Chad DeShon
  • 4,732
  • 6
  • 28
  • 29
236
votes
24 answers

What's the easiest way to install a missing Perl module?

I get this error: Can't locate Foo.pm in @INC Is there an easier way to install it than downloading, untarring, making, etc?
dreeves
  • 26,430
  • 45
  • 154
  • 229
1
2 3
99 100