- Perl -ne 'print if $. = 15; exit if $. Just lines NOT between line 10 and 20 perl -ne 'print unless 10. Lines between START and END perl -ne 'print if /^START$/. In-place edit of.c files changing all foo to bar perl -pi.bak -e 's/bfoob/bar/g'.c 5. Delete first 10 lines perl -i.old.
- Regular Expression Flags; i: Ignore case: m ^ and $ match start and end of line: s. Matches newline as well: x: Allow spaces and comments: J: Duplicate group names allowed.
- The tables below are a reference to basic regex. While reading the rest of the site, when in doubt, you can always come back and look here. (It you want a bookmark, here's a direct link to the regex reference tables).I encourage you to print the tables so you have a cheat sheet on your desk for quick reference.
- This cheat sheet contains all the perl's special variables, their description and examples where possible. It can be nicely printed on one sheet of paper by having two pages per side. Two on one side and two on other. That's how I have printed it. Available as usual in.doc and.pdf formats. Download Perl's Special Variable Cheat Sheet.
In my previous post - downloading youtube videos with a Perl one-liner - I used Perl's special variable $_. This is just one of many Perl's special variables.
One day last year I decided to go through all the Perl's special variables carefully so I could become a better Perl programmer and make a cheat sheet which I could always keep on my desk and look things up when needed.
As I explained in the previous cheat-sheet post (awk's cheat sheet), the cheat sheets are for learning things better and not doing things blindly and looking the stuff each time up. Here is another example why cheat sheets are helpful - suppose you programmed for 5 hours and then sat back in your chair to relax for 10 minutes. You could relax by taking cheat sheet in your hands and just scan through it and remember a thing or two.
Go Cheat Sheet for Perl Hackers. Contribute to oalders/go-for-perl-hackers development by creating an account on GitHub.
This cheat sheet contains all the perl's special variables, their description and examples where possible.
Perl Cheat Sheets
It can be nicely printed on one sheet of paper by having two pages per side. Two on one side and two on other. That's how I have printed it.
Available as usual in .doc and .pdf formats.
Download Perl's Special Variable Cheat Sheet
- PDF document: perl.predefined.variables.pdf
- MS Word (.doc): perl.predefined.variables.doc
See you next time!
PrevNext
When learning regexes, or when you need to use a feature you have not used yet or don't use often, itcan be quite useful to have a place for quick look-up. I hope this Regex Cheat-sheet will provide such aid for you.
Character Classes
Regex Character Classes and Special Character classes.
TODO: add examples w and d matching unicode letters and numebers.
Quantifiers
'Quantifier-modifier' aka. Minimal Matching
Other
Grouping and capturing
Anchors
Modifiers
Perl Cheat Sheet Pdf
Extended
Other Regex related articles
Official documentation
Published on 2015-08-19