Quote:
Originally Posted by casperdaghost
Tink this is beautiful
so the -n loops through but does not print the output -a splits the string in the fith column into individual characters (ex cib100 = c-i-b-1-0-0) and if a character =~ (matches) a number it substitutes is with a nothing
$ perl -ane '$F[5]=~s/[0-9]//g; print "$F[5]\n"' casper
which part of the script acts on the file first - the print "$F[5]\n"' or the perl -ane '$F[5]=~s/[0-9]//g; ?\
i am just hazy on if the script seperates the string into single characters - how does the script puts the string back together.
|
Nope regarding the -a ... the array gets split along the
whitespace, and the snippet takes each line, splits the
columns into the array element. $F[5] is column 6.
The regex 's/[0-9]//g' simply strips ANY number from
the 6th column (of every line), and the print then
prints it.
basically -an is shorthand for
Code:
while (<>) {
@F = split(' ');
}
All the ops on the commandline (following -e) get
executed in sequence AFTER the split.
Cheers,
Tink