Hi, I’m Dave Cross and I’m a Perl hacker. I’ve been using Perl since 1996. In 1998 I started the London Perl Mongers, the first Perl User Group outside of North America. I’ve been heavily involved in the Perl community ever since. I’m the author of Data Munging with Perl and a co-author of Perl.
Replies are listed 'Best First'. | |
---|---|
Re: Perl cheat sheet by TheDamian (Priest) on Nov 29, 2002 at 23:00 UTC | |
A few possible additions: | [reply] [d/l] [select] |
by Juerd (Abbot) on Nov 29, 2002 at 23:19 UTC | |
* The regex metacharacter ^ means 'start of string', not 'start of line' (unless the /m modifier is used) * The regex metacharacter $ means 'end of string', not 'end of line' (unless the /m modifier is used) Because 'foon' =~ /foo$/, I tend to explain it differently. ^ and $ are begin and end of a line, but /m modifies the meaning of line. $ certainly is not end of string when the string ends in n. I'm not sure if and how I want to change the sheet. * . is 'any char except n' or just 'not n' (unless the /s modifier is used) Good point, will be changed. regex A, Z and z Maybe if I need to fill some room in a future version, but I kind of wanted to keep it simple. I also didn't include G, X, C, b, B. I think I'd add b and C first. * Another commonly ignored 'NEVER' is: /$userinput/ Good one, but I'd need another line :). Will remember it for a future version, though. Update - Added valdez' link suggestion and a use Modules; et voila: a line to put /$userinput/ on! Thanks for your input! | [reply] [d/l] [select] |
by TheDamian (Priest) on Dec 02, 2002 at 01:33 UTC | |
Because 'foon' =~ /foo$/, I tend to explain it differently. ^ and $ are begin and end of a line, but /m modifies the meaning of 'line'. I don't see how that explanation can work, though. $ only ever means EOL when /m is operative. You can see that by running: I see that you've updated the sheet to just: Can I suggest that (if you also used the suggestion at the end of this node) that could just become: Those descriptions would be sufficient if you were also more explicit about /s and /m. Explaining that they mean singleline and multiline respectively doesn't really help newbies remember which is which or what each of them does. Heck, if uri hadn't taught me the mnemonic that /s changes a Single metacharacter (i.e. .) whilst /m changes Multiple metacharacters (i.e. ^ and $), then I still wouldn't be able to remember which is which myself! So maybe you'd like to consider changing them to something like: | [reply] [d/l] [select] |
by Juerd (Abbot) on Dec 02, 2002 at 07:42 UTC | |
•Re: Perl cheat sheet by merlyn (Sage) on Nov 29, 2002 at 22:15 UTC | |
And your backslashes seem to be missing from the description of s. -- Randal L. Schwartz, Perl hacker | [reply] |
by Juerd (Abbot) on Nov 29, 2002 at 22:22 UTC | |
Oops, I forgot the parens. Guess I am a Perl newbie too :) The backslashes are gone because I forgot to escape them on my own site-to-be (I copied and pasted it from there to here. Might have been a better idea to copy it from the initial text file). Both are fixed. Thanks! | [reply] |
Re: Perl cheat sheet by boo_radley (Parson) on Nov 30, 2002 at 01:45 UTC | |
| [reply] |
by grantm (Parson) on Nov 30, 2002 at 19:18 UTC | |
Possibly not what you're thinking of, but The Perl Reference Guide by Johan Vromans is available for download. It has also evolved into The Perl Pocket Reference from O'Reilly. That document has a somehwat more ambitious scope than Juerd's effort though. | [reply] |
by bivouac (Beadle) on Dec 12, 2002 at 19:05 UTC | |
| [reply] |
by Aristotle (Chancellor) on Dec 14, 2002 at 22:57 UTC | |
by mooseboy (Pilgrim) on Nov 30, 2002 at 11:35 UTC | |
Yes, you did see a Perl cheatsheet. I don't have it, but I have the Linux one -- comes in handy for those brain-fade moments. If your local bookstore doesn't stock them, you can get them on the Web at www.cram.com. | [reply] |
by Popcorn Dave (Abbot) on Nov 30, 2002 at 05:38 UTC | |
There is no emoticon for what I'm feeling now. | [reply] |
Re: Perl cheat sheet by belg4mit (Prior) on Nov 30, 2002 at 02:45 UTC | |
-- | [reply] |
by mattr (Curate) on Dec 01, 2002 at 15:32 UTC | |
| [reply] |
Re: Perl cheat sheet by DapperDan (Pilgrim) on Nov 30, 2002 at 17:37 UTC | |
Nice work! I often get slices and basic regexps wrong when I guess and try to wing it; I don't want to get off my ass and get the camel off the shelf or do a mental context-switch to read pod so it'll be nice to be able to just glance at the wall as I do when I forget something in vi. I copynpasted this into Word, formatted it in Andale Mono 12, ran off a copy on my laserjet and taped it on the wall next to my vi cheat sheet. I added the URL of this node and the date ('November 2002'); maybe you should too? My vi cheat sheet has been on the wall since 1998. I guess most people who use this will want hard copy. I can make a pdf if you want to host it.. /msg me. | [reply] |
by Juerd (Abbot) on Nov 30, 2002 at 19:52 UTC | |
I added the URL of this node and the date ('November 2002'); maybe you should too? The URL that is already there (http://juerd.nl/) will host a whole new website soon (ETA: one or two weeks), including the cheat sheet. What's the purpose of a date if it already has a version number? My vi cheat sheet has been on the wall since 1998. And you still don't know it by heart? :) My guess is that beginners will only use this Perl sheet for one, maybe two months. I guess most people who use this will want hard copy. I can make a pdf if you want to host it.. /msg me. I think you are right about people wanting hard copy, but I also think that anyone capable of typing #!/usr/bin/perl knows how to make print a text file :) Feel free to host it yourself if you want. I disclaim both responsibility and copyright (regarding 'Perl 5 Cheat Sheet v5'), but please don't remove my name and URL. | [reply] |
Re: Perl cheat sheet by theorbtwo (Prior) on Nov 30, 2002 at 03:01 UTC | |
Why are there two LINKS sections? (I thought for a minute that you simply couldn't fit them all in one section, but they're mostly dupes.) Also, if you could find room, the args of localtime and the return of stat would be very useful, for me at least. Also, ? as the non-greedy modifier would be useful. Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node). | [reply] |
by Juerd (Abbot) on Nov 30, 2002 at 13:24 UTC | |
Why are there two LINKS sections? (I thought for a minute that you simply couldn't fit them all in one section, but they're mostly dupes.) Dupes? use less 'alcohol';, because there are no duplicates. The link sections were added just to fill some room, and I had two huge gaps that needed filling. | [reply] [d/l] |
by theorbtwo (Prior) on Nov 30, 2002 at 22:28 UTC | |
<font size='big'>D'oh</font> Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node). | [reply] |
Re: Perl cheat sheet by mce (Curate) on Dec 04, 2002 at 11:06 UTC | |
Nice. Perhaps something to put on the back of PM t-shirt. (or the front, if you want to use it a lot :=) ) | [reply] |
Re: Perl cheat sheet by oakbox (Chaplain) on Jan 01, 2003 at 09:16 UTC | |
Just to make sure that I'm reading this correctly. This is saying, 'if $foo is a scalar value, don't try to expand it as an array reference.' Is that correct? | [reply] [d/l] |
by Juerd (Abbot) on Jan 01, 2003 at 14:09 UTC | |
Just to make sure that I'm reading this correctly. This is saying, 'if $foo is a scalar value, don't try to expand it as an array reference.' Is that correct? Not really. It's saying: 'Do not use symbolic references.' With $foo = 'bar'; $$foo = 'xyzzy';, xyzzy is assigned to $bar. Of course, strict does not allow symbolic references (although you can of course use no strict 'refs';. The entry in the cheat sheet is just a reminder for newbies, who generally don't know the term 'symbolic reference' and do use Perl like this. It's the kind of newbie that hasn't discovered hashes yet. So what I'm really saying is: 'If $foo is a scalar value, don't use it as a reference.' This is not only for arrays. | [reply] [d/l] [select] |
Re: Perl cheat sheet by Thelonious (Scribe) on Feb 22, 2005 at 05:54 UTC | |
| [reply] |
by holli (Abbot) on Feb 22, 2005 at 07:18 UTC | |
| [reply] |
Re: Perl cheat sheet by Anonymous Monk on Aug 21, 2006 at 18:57 UTC | |
| [reply] |
by ikegami (Pope) on Aug 21, 2006 at 19:32 UTC | |
'$foo' creates a stringified copy of $foo. $foo will get stringified when it needs to get stringified. There's no reason to do it prematurely. For example, it prevents people from using object with stringification overloaded. | [reply] [d/l] [select] |
by ursus (Acolyte) on Jan 07, 2009 at 00:50 UTC | |
| [reply] [d/l] [select] |
by ikegami (Pope) on Jan 07, 2009 at 01:24 UTC | |
by ursus (Acolyte) on Jan 07, 2009 at 06:10 UTC | |
by lodin (Hermit) on Jan 07, 2009 at 08:07 UTC | |
by ikegami (Pope) on Jan 07, 2009 at 09:23 UTC |