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
81
votes
9 answers

Quickly getting to YYYY-mm-dd HH:MM:SS in Perl

When writing Perl scripts I frequently find the need to obtain the current time represented as a string formatted as YYYY-mm-dd HH:MM:SS (say 2009-11-29 14:28:29). In doing this I find myself taking this quite cumbersome path: man…
knorv
  • 49,059
  • 74
  • 210
  • 294
81
votes
5 answers

Find everything between two XML tags with RegEx

In RegEx, I want to find the tag and everything between two XML tags, like the following: 280 Flinders Mall PROPERTY -19.261365
Doz
  • 7,009
  • 12
  • 61
  • 69
80
votes
7 answers

What does shift() do in Perl?

What could the following line possibly mean? my $x = shift;
cam
79
votes
13 answers

Automatically get loop index in foreach loop in Perl

If I have the following array in Perl: @x = qw(a b c); and I iterate over it with foreach, then $_ will refer to the current element in the array: foreach (@x) { print; } will print: abc Is there a similar way to get the index of the current…
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
79
votes
5 answers

Text processing - Python vs Perl performance

Here is my Perl and Python script to do some simple text processing from about 21 log files, each about 300 KB to 1 MB (maximum) x 5 times repeated (total of 125 files, due to the log repeated 5 times). Python Code (code modified to use compiled re…
ihightower
  • 3,093
  • 6
  • 34
  • 49
78
votes
18 answers

Is there any use for Bash scripting anymore?

I just finished my second year as a university CS student, so my "real-world" knowledge is lacking. I learned Java my first year, continued with Java and picked up C and simple Bash scripting my second. This summer I'm trying to learn Perl (God…
Daniel Harms
  • 1,178
  • 1
  • 11
  • 20
78
votes
10 answers

How do I include functions from another file in my Perl script?

This seems like a really simple question but somehow my Google-Fu failed me. What's the syntax for including functions from other files in Perl? I'm looking for something like C's #include "blah.h" I saw the option for using Perl modules, but that…
Zain Rizvi
  • 23,586
  • 22
  • 91
  • 133
78
votes
8 answers

What does $1 mean in Perl?

What does $1 mean in Perl? Further, what does $2 mean? How many $number variables are there?
Chad DeShon
  • 4,732
  • 6
  • 28
  • 29
77
votes
6 answers

Is Try::Tiny still recommended for exception handling in Perl 5.14 or later?

The consensus of the Perl community seems to be that Try::Tiny is the preferred way to handle exceptions. Perl 5.14 (which is the version I use) seems to solve the issues with eval that Try::Tiny addresses. Will Try::Tiny still provide any benefits…
Eugene Yarmash
  • 142,882
  • 41
  • 325
  • 378
76
votes
5 answers

Submit form and stay on same page?

I have a form that looks like this
and I would like to stay on the same page, when Submit is clicked, but still have…
Sandra Schlichting
  • 25,050
  • 33
  • 110
  • 162
76
votes
9 answers

how to remove the first two columns in a file using shell (awk, sed, whatever)

I have a file with many lines in each line there are many columns(fields) separated by blank " " the numbers of columns in each line are different I want to remove the first two columns how to?
wenzi
  • 1,235
  • 2
  • 11
  • 11
76
votes
16 answers

What is the difference between my and local in Perl?

I am seeing both of them used in this script I am trying to debug and the literature is just not clear. Can someone demystify this for me?
Brian G
  • 53,704
  • 58
  • 125
  • 140
76
votes
11 answers

How can I check if a Perl module is installed on my system from the command line?

I tried to check if XML::Simple is installed in my system or not. perl -e 'while (<@INC>) { while (<$_/*.pm>) { print "$_\n"; } }' The above one-liner was used for listing all modules installed in my system. However, it is not listing XML…
joe
  • 34,529
  • 29
  • 100
  • 137
75
votes
5 answers

Which cpan installer is the right one? (CPAN.pm/CPANPLUS/cpanminus)

There are multiple installers for cpan modules available; I know of at least CPAN.pm (comes with perl,) CPANPLUS, and cpanminus. What is the difference between the three? What situations call for using one over the other? Are there other module…
Sean McMillan
  • 10,058
  • 6
  • 55
  • 65
75
votes
6 answers

How can I install a specific version of a set of Perl modules?

I'm tasked with replicating a production environment to create many test/sit environments. One of the things I need to do is build up Perl, with all the modules which have been installed (including internal and external modules) over the years. I…
Matthew Watson
  • 14,083
  • 9
  • 62
  • 82