This should solve the problem. Save following lines as some_name.pl Also mention file name in the file as mentioned.
#!/usr/bin/perl
open(vp,"myfile");
#myfile is the file in the same dir or u can specify full path here eg: /home/my/myfile
foreach $names (<vp>){
#Th following lines by Devdas Bhagat
@names = split(' ',$names); #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
}Run the file as perl some_name.pl You can redirect its output to file as perl some_name.pl > names.txt
Regards swanand techieinfo.cjb.net
Message: 4 Date: Tue, 16 Dec 2003 15:06:56 +0530 From: Devdas Bhagat <[EMAIL PROTECTED]> Subject: Re: [ILUG-BOM] regexp query To: Devdas Bhagat <[EMAIL PROTECTED]>, "GNU/Linux Users Group, Mumbai, India" <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> Content-Type: text/plain; charset=us-ascii
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
_________________________________________________________________
Worried about inbox overload? Get MSN Extra Storage now! http://join.msn.com/?PAGE=features/es
-- http://mm.ilug-bom.org.in/mailman/listinfo/linuxers

