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
74
votes
4 answers

Installing modules using Strawberry Perl

Until now I used ActiveState's ActivePerl, and used the ppm for installing modules. Last week I moved to Strawberry Perl, but I don't know how I should install modules using Strawberry Perl. What is some information on how module installation is…
ronssd
  • 741
  • 1
  • 5
  • 3
74
votes
8 answers

How can I get a call stack listing in Perl?

Is there a way I can access (for printout) a list of sub + module to arbitrary depth of sub-calls preceding a current position in a Perl script? I need to make changes to some Perl modules (.pm's). The workflow is initiated from a web-page thru a…
slashmais
  • 7,069
  • 9
  • 54
  • 80
74
votes
5 answers

How do I tell what type of value is in a Perl variable?

How do I tell what type of value is in a Perl variable? $x might be a scalar, a ref to an array or a ref to a hash (or maybe other things).
pm100
  • 48,078
  • 23
  • 82
  • 145
74
votes
9 answers

How can I install and use ack library on Windows?

I have never used Perl, but I am really impressed by the ack, which I would like to use for source code searching, etc. Can anyone guide me of how to make use of this excellent library on Windows?
rajesh pillai
  • 8,102
  • 7
  • 43
  • 60
73
votes
7 answers

How can I store regex captures in an array in Perl?

Is it possible to store all matches for a regular expression into an array? I know I can use ($1,...,$n) = m/expr/g;, but it seems as though that can only be used if you know the number of matches you are looking for. I have tried my @array =…
cskwrd
  • 2,803
  • 8
  • 38
  • 51
72
votes
10 answers

How do I get a file's last modified time in Perl?

Suppose I have a filehandle $fh. I can check its existence with -e $fh or its file size with -s $fh or a slew of additional information about the file. How can I get its last modified time stamp?
cowgod
  • 8,626
  • 5
  • 40
  • 57
72
votes
5 answers

Perl read line by line

I have a simple Perl script to read a file line by line. Code is below. I want to display two lines and break the loop. But it doesn't work. Where is the bug? $file='SnPmaster.txt'; open(INFO, $file) or die("Could not open file."); $count = 0;…
user534009
  • 1,419
  • 4
  • 23
  • 25
72
votes
6 answers

How can I list all of the files in a directory with Perl?

Is there a function in Perl that lists all the files and directories in a directory? I remember that Java has the File.list() to do this? Is there a comparable method in Perl?
Paradius
  • 7,949
  • 11
  • 32
  • 38
71
votes
9 answers

Should I use \d or [0-9] to match digits in a Perl regex?

Having read a number of questions/answers over the past few weeks, I have seen the use of \d in perl regular expressions commented on as incorrect. As in the later versions of perl \d is not the same as [0-9], as \d will represent any Unicode…
Beano
  • 7,551
  • 3
  • 24
  • 27
71
votes
9 answers

What regex can match sequences of the same character?

A friend asked me this and I was stumped: Is there a way to craft a regular expression that matches a sequence of the same character? E.g., match on 'aaa', 'bbb', but not 'abc'? m|\w{2,3}| Wouldn't do the trick as it would match 'abc'. m|a{2,3}|…
Bill
  • 3,584
  • 5
  • 35
  • 47
71
votes
6 answers

How to match once per file in grep?

Is there any grep option that let's me control total number of matches but stops at first match on each file? Example: If I do this grep -ri --include '*.coffee' 're' . I get this: ./app.coffee:express = require 'express' ./app.coffee:passport =…
pathikrit
  • 32,469
  • 37
  • 142
  • 221
69
votes
5 answers

How can I install a CPAN module into a local directory?

I'm using a hosted Linux machine so I don't have permissions to write into the /usr/lib directory. When I try to install a CPAN module by doing the usual: perl Makefile.PL make test make install That module is extracted to a blib/lib/ folder. I…
Ram
  • 3,034
  • 11
  • 38
  • 46
69
votes
4 answers

What's the difference between a hash and hash reference in Perl?

I would like to properly understand hashes in Perl. I've had to use Perl intermittently for quite some time and mostly whenever I need to do it, it's mostly related to text processing. And everytime, I have to deal with hashes, it gets messed up. I…
user855
  • 19,048
  • 38
  • 98
  • 162
69
votes
6 answers

How to decrypt hash stored by bcrypt

I have this script that encrypts a password but I don't know how to reverse it and decrypt it. This may be a very simple answer but I don't understand how to do it. #!/usr/bin/perl use Crypt::Eksblowfish::Bcrypt; use Crypt::Random; $password =…
BluGeni
  • 3,378
  • 8
  • 36
  • 64
68
votes
5 answers

What's the difference between exists and defined?

What is the difference between if (defined $hash{$key}) { } and if (exists $hash{$key}) { } When do I know which to use?
Sandra Schlichting
  • 25,050
  • 33
  • 110
  • 162