[Omaha.pm] Add a pipe to a pipe delim file
Jay Hannah
jay at jays.net
Tue Dec 20 11:16:16 PST 2005
Sean Baker wrote:
> If all you want to do is add a pipe to the end:
>
> perl -pi -e "s/$/|/g" [filename]
>
> Or the beginning:
>
> perl -pi -e "s/^/|/g" [filename]
Ya. To do what I needed (tweak the 9th column, not the last one), perhaps -a or -F would do that in a one liner? I'm not good with those yet.
j
perldoc perlrun
-a turns on autosplit mode when used with a -n or -p. An implicit
split command to the @F array is done as the first thing inside
the implicit while loop produced by the -n or -p.
perl -ane 'print pop(@F), "\n";'
is equivalent to
while (<>) {
@F = split(' ');
print pop(@F), "\n";
}
An alternate delimiter may be specified using -F.
More information about the Omaha-pm
mailing list