[ale] perl help

Fletch fletch at phydeaux.org
Fri Apr 12 10:59:02 EDT 2002



        Copying this back to the list just in case I confuzzled anyone
else out there . . . :)


>>>>> "Matthew" == Matthew Brown <matthew.brown at cordata.net> writes:

    Matthew> I'm sorry, but I am not sure what this one does.  Could
    Matthew> you explain?  It looks like you're searching for all the
    Matthew> .bak files, then I don't understand the -pe, or the stuff
    Matthew> inside the pattern part of the s///.

        perldoc perlrun explains all of the magic, but to take it
piece by piece:

    Me> $ perl -i.bak -pe 's/\cM+$//' lalala

        `-i.bak' says edit files in place, making a backup of the
original with the extension .bak (so you'd get lalala.bak)


        `-p' says wrap the entire program in


while( <ARGV> ) {
  ...
} continue {
  print 
}


        which basically will iterate over all of the files named on
the command line line by line, executing whatever code was provided in
place of the `...' and printing $_ before reading the next line.
compare and contrast with -n.


        `-e' provides code as the next argument (rather than it having
to be in a file), in this case the code being . . .


        `s/\cM+$//' says replace one or more control-M's before the end
of the line with nothing.


        `lalala' represents the file (or files) that you want to
munge.


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 933-0600 x211(w)  |  scary questions." -- Jules                =(___)=
                      |                                               U

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list