On 11/12/03 09:52 +0530, Devdas Bhagat wrote:
> On 10/12/03 18:00 +0530, Dr. Sharukh K. R. Pavri. wrote:
> > I have a text file in the format
> >
> > Full name [EMAIL PROTECTED]
> perl -e 'while(<>) { @names = split /\s+/; foreach (@names) { print "$_ " if !
> /\@/)}; print "\n" } ' < file.
Replying to myself:
The above one liner is equivalent to:
#!/usr/bin/perl
while (<STDIN>) { #read one line from standard input
@names = split /\s+/; #Split the line on whitespace
#and assign to the array @names
foreach (@names) { #For all values in the array
print "$_ " #Print the value followed by a single
# space
if ! /\@/; #Iff there was no '@' in it.
}
print "\n"; #Print a newline
}
I redirect standard input from the file 'file' via the shell operator <.
Devdas Bhagat
--
http://mm.ilug-bom.org.in/mailman/listinfo/linuxers