Questions tagged [perl]

Perl is a high-level, general-purpose, interpreted, dynamic programming language. It was originally developed by Larry Wall as a general-purpose Unix scripting language to make report processing easier, over a period with support from open source community, it has evolved and matured to be used for graphics programming, system administration, network programming, finance, bioinformatics, and other engineering applications.

Source: Wikipedia.

Perl is a general-purpose programming language originally developed for text manipulation, but as of 2010 is used for a wide range of tasks including system administration, web development, network programming, games, bioinformatics, and GUI development. The language is intended to be practical (easy to use, efficient, complete) rather than beautiful (tiny, elegant, minimal). Its major features include support for multiple programming paradigms (procedural, object-oriented, and functional styles), reference counting memory management (without a cycle-detecting garbage collector), built-in support for text processing, and a large collection of third-party modules. According to Larry Wall, Perl has two slogans. The first is "There's more than one way to do it", commonly known as TMTOWTDI. The second slogan is "Easy things should be easy and hard things should be possible".

Perl is known as one of "the three Ps" (along with Python and PHP), the most popular dynamic languages for writing Web applications. It is also an integral component of the popular LAMP solution stack for web development. Large projects written in Perl include cPanel, Slash, Bugzilla, RT, TWiki, and Movable Type. Many high-traffic websites use Perl extensively. Examples include Amazon.com, bbc.co.uk, Priceline.com, Craigslist,IMDb, LiveJournal, Slashdot and Ticketmaster. Perl is often used as a glue language, tying together systems and interfaces that were not specifically designed to interoperate, and for "data munging",that is, converting or processing large amounts of data for tasks such as creating reports. In fact, these strengths are intimately linked. The combination makes Perl a popular all-purpose language for system administrators, particularly because short programs can be entered and run on a single command line. More at http://en.wikipedia.org/wiki/Perl

1358 questions
10
votes
2 answers

How exactly does perl's -0 option work?

According to man perlrun: -0[octal/hexadecimal] specifies the input record separator ($/) as an octal or hexadecimal number. If there are no digits, the null character is the separator. and The special value 00 will cause Perl to…
terdon
  • 242,166
10
votes
6 answers

Using Perl to count the number of scientific numbers in a file

How I can count the number of scientific numbers in a file? The file also has a few lines of header which needs to be skipped. A portion of the file's content is in…
8
votes
3 answers

Perl: change in interpretation of shell symbols in system() invocation?

Today I noticed that something changed in Perl, probably recently, in the way it runs shell commands. Could someone explain what has changed? I cannot find the answer myself and sadly we learned about this change in a hardest way possible. Some new…
Kamil
  • 1,461
7
votes
2 answers

passing a named variable as a command line argument to a perl script

awk offers a convenient way to pass named variables to a script using the -v flag (e.g., awk -v var="value" ...), a facility that is quite useful when composing ad hoc scripts. Can the same be done with Perl or does one need to resort to argv,…
user001
  • 3,698
4
votes
1 answer

Perl - closing curly bracket before the opening one. How does it work?

I came across this solution to reverse the content of a file : $ cat f1 abc def ghi jkl $ perl -ne 'push @arr,$_;}{print reverse @arr;' f1 jkl ghi def abc Could someone please explain how the curly brackets work ? I'm confused, the closing bracket…
ChennyStar
  • 1,743
4
votes
1 answer

BEGIN {...}; in Perl

I have a perl-script: #!/usr/bin/perl BEGIN { print "That's BEGIN message\n"; BEGIN { print "That's BEGIN-2 message\n"; }; END { print "That's END message\n"; }; BEGIN { print "That's BEGIN-3 message\n"; }; }; It works so: That's…
4
votes
3 answers

What does '(...)? = $1 : $2' do in Perl?

I came across with these two lines, and though I've been trying to figure out what they do, I'm still in doubt about their meaning in the code. The piece of code I am talking about is: my $mapped_from = ($num_phones_in == 60)? = $1 : $2; my…
4
votes
5 answers

Regular expression to replace an instance of two consecutive strings that might be separated by whitespace

I want to write a perl one-liner that replaces every instance of two specific consecutive strings that may or may not be separated by whitespace. For instance, say my two strings are john paul and george and I want to replace consecutive instances…
3
votes
2 answers

Read STDIN with timeout

I want to read STDIN, but at most for 5 seconds. After that I want to process the data I have read so far. select seems to be made for exactly that: Wait until there is input or until timeout. If there is input I should then just read that…
Ole Tange
  • 35,514
3
votes
1 answer

Unix perl match string and delete line

Im using perl to remove a string from a file, it is removing the string from file, But the actual line is not getting deleted, Due to which the next insert to the files are getting written over next line. Perl command used: host=ABC1234 perl -lpi…
3
votes
1 answer

Filenames with spaces inside perl command inside echo

How do I support filenames with spaces in the following command? echo "$(perl -MMIME::Base64 -e 'open F, shift; @lines=; close F; print MIME::Base64::encode(join(q{}, @lines))' $filename)" I tried the following which didn't seem to work: echo…
forthrin
  • 2,289
3
votes
4 answers

How to permanently set some path in @INC

I want to set a path in @INC, as script is failing to locate perl module. Requirement is that , i cannot include the module path in the script directly. So , i am thinking to add module path directly in @INC. Is there a way i can do that. I have…
Mudassar Rana
  • 27
  • 1
  • 3
3
votes
3 answers

perl library getopts.pl

I'm trying to install a program, but keeps giving an error saying it doesn't find the perl library getopts.pl. My perl version is v5.16.2. The error message is: Can't locate getopts.pl in @INC (@INC…
3
votes
2 answers

Release memory in perl script

I want all this combinations but I don't have enough memory. How can I release memory in my script? use strict; use warnings; use Algorithm::Combinatorics 'variations_with_repetition'; my @let = qw/ A G C T /; my @cad =…
zorbax
  • 340
2
votes
1 answer

int seems to be not int in a used perl library

A peculiar phenomenon is on my mind. As you may know, dealing with a mail server directly exposed to the internet can be quite the 'joy' with various individuals attempting to break into it or use it as a relay. I don't have any issues with manually…
numchrun
  • 508
1
2 3 4 5 6 7