Differences between revisions 3 and 4
Revision 3 as of 2002-05-28 11:56:31
Size: 942
Editor: SimonHuggins
Comment: Add navbar style thingie
Revision 4 as of 2008-02-19 15:39:14
Size: 942
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

CategoryComputingTips > PerlCompTips

Perl Tips

Oneliners

  • Use perl -le '... print ...' instead of perl -e '... print ... ,"\n";' to get newlines. See man perl for the gory details about -l

  • Use perl -i.bak with -pe something to modify text and a list of filenames for a safe way to try your perl on files e.g. perl -i.bak -pe 's/^bar/baz/' *

Documentation

  • perldoc is actually useful:

    • perldoc -f function
    • perldoc modulek
  • You can find module documentation for the latest versions on http://search.cpan.org/

rename

rename is bundled with perl and installed in all good perl installs :)

It's really useful as the syntax is

Usage: rename [-v] perlexpr [filenames]

So renaming multiple files according to a pattern becomes suddenly easy.

rename 'tr/A-Z/a-z/' *

rename 's/\.foo$/.bar/' *

TheEarthWiki: PerlCompTips (last edited 2008-02-19 15:39:14 by localhost)