Perl Print Quotes

We've searched our database for all the quotes and captions related to Perl Print. Here they are! All 5 of them:

To base64-encode the whole file, use this: perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' file Here, the -0777 argument together with -n causes Perl to slurp the whole file into the $_ variable. Next, the file is base64-encoded and printed. (If Perl didn’t slurp the entire file, it would be encoded line by line, and you’d end up with a mess.)
Peteris Krumins (Perl One-Liners: 130 Programs That Get Things Done)
For example, to print the lines 13, 19, 88, 290, and 999, you do this: perl -ne 'print if $. == 13 || $. == 19 || $. == 88 || $. == 290 || $. == 999' If you want to print more lines, you can put them in a separate array and then test whether $. is in this array: perl -ne '   @lines = (13, 19, 88, 290, 999, 1400, 2000);   print if grep { $_ == $. } @lines ' This one-liner uses grep to test if the current line $. is in the @lines array. If the current line number is found in the @lines array, the grep function returns a list of one element that contains the current line number and this list evaluates to true.
Peteris Krumins (Perl One-Liners: 130 Programs That Get Things Done)
perl -00 -pe '' This one-liner is really tricky, isn’t it? First, it doesn’t have any code! The -e is empty. Next, it has a silly -00 command-line option that turns paragraph slurp mode on, meaning Perl reads text paragraph by paragraph, rather than line by line. (A paragraph is text between two or more newlines.) The paragraph is put into $_, and the -p option prints it out.
Peteris Krumins (Perl One-Liners: 130 Programs That Get Things Done)
Calculate the factorial perl -MMath::BigInt -le 'print Math::BigInt->new(5)->bfac()' This one-liner uses the bfac() function from the Math::BigInt module in the Perl core. (In other words, you don’t need to install it.) The Math::BigInt->new(5) construction creates a new Math::BigInt object with a value of 5, after which the bfac() method is called on the newly created object to calculate the factorial of 5.
Peteris Krumins (Perl One-Liners: 130 Programs That Get Things Done)
Compile the code with the make command: % make cp Base64.pm blib/lib/MIME/Base64.pm cp QuotedPrint.pm blib/lib/MIME/QuotedPrint.pm /usr/bin/perl -I/opt/perl5/5.6.1/i386-freebsd -I/opt/perl5/5.6.1
Sean M. Burke (Perl & LWP: Fetching Web Pages, Parsing HTML, Writing Spiders & More)