# Keep all of the lines matching /myst/ in mysteryhunt.xml, removing others # Save a backup in filename.bak perl -n -i.bak -e'print if /myst/i;' mysteryhunt.xml # Print all of the words containing /myst/ in the given files. perl -n -e'print (m/\b\w*myst\w*\b/gi);' mysteryhunt.xml mh2.xml mh3.xml -n = while (<>) { # Your script here } -p = while (<>) { # Your script here print; } -i = edit in place -i.bak = ... and make a backup by appending ".bak" to the filename -e 'script goes here' perl -p -i -e 's/foo/bar/' files* find . -name "*.html" -print0 | xargs -0 perl -p -i -e 's/foo/bar/' # Examine a given structure with Data::Dumper: perl -MData::Dumper -e 'print Dumper(\%INC);'