Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

schwern (1528)

schwern
  (email not shown publicly)
http://schwern.net/
AOL IM: MichaelSchwern (Add Buddy, Send Message)
Jabber: schwern@gmail.com

Schwern can destroy CPAN at his whim.

Journal of schwern (1528)

Wednesday May 14, 2003
01:52 AM

perlsyn - sed syntax?

[ #12186 ]

Reading the first two paragraphs of perlsyn, I've noticed there is more information in there about sed, awk, C and command line switches than introductory perl syntax.

A Perl script consists of a sequence of declarations and statements. The sequence of statements is executed just once, unlike in sed and awk scripts, where the sequence of statements is executed for each input line. While this means that you must explicitly loop over the lines of your input file (or files), it also means you have much more control over which files and which lines you look at. (Actually, I'm lying--it is possible to do an implicit loop with either the -n or -p switch. It's just not the mandatory default like it is in sed and awk.)

Perl is, for the most part, a free-form language. (The only exception to this is format declarations, for obvious reasons.) Text from a "#" character until the end of the line is a comment, and is ignored. If you attempt to use /* */ C-style comments, it will be interpreted either as division or pattern matching, depending on the context, and C++ // comments just look like a null regular expression or defined-or operator, so don't do that.

What is this actually teaching?

  • A Perl script consists of declarations and statements executed once no matter what the input.
  • Sed and awk execute once for every line of input.
  • Perl has -n and -p switches to act more like sed and awk
  • Perl comments start with #
  • C comments look like /* */
  • C++ comments look like //
  • // is either a division or null regular expression or defined-or in Perl

This quantifies like so:

  • 2 facts about basic Perl syntax
  • 2 facts about advanced Perl features
  • 3 facts about other languages/tools

Obviously a hold over from the days when Perl was just a replacement for awk and sed and Real Programmers coded in C. While this information might be useful, the opening paragraphs of the Perl syntax documentation is not the place to put it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I for one would like to see a separate pod file dealing specifically with sed, awk, etc. Possibly either detailing the differences between perl and these, or detailing how to convert bits of sed and awk into pure perl..

    Yes it's in there now, but moving them off to their own section would allow a little more expounding on these topics, and may remove some of the clutter from those pods that contain these references now.

    If this makes no sense, it's because I'm still on my first cup of coffee.. ;-)
  • by VSarkiss (704) on 2003.05.14 10:20 (#20113) Journal

    It's useful information, but you're right, it doesn't belong in an introductory document. It might be more appropriate in perltrap, for instance.

    In the same vein, I keep thinking there's a lot of documentation, but it's hard to skim because it's all one flat structure. (How many people remember what's in perldsc?) It would be nice to have it arranged into groups, maybe something like:

    • Introductory and Core: perlsyn, perlfunc, perldata, perlbook, perlboot, etc.
    • Internals: perlguts, perlhack, perldebguts, etc.
    • FAQs: perlfaq1 thru N
    • System-specific: perlaix, perlhpux, and all the rest.
    • Tutorials: perldsc, perltoot, perltooc, perlretut, etc.
    I could go on, but you get the idea. It would be even better if you could cross-reference, since some things easily fit in more than one category.

    I'd gladly make and maintain such a list, but I don't know how to get it out there. Give it to you? ;-)