From: Ossama K. <os...@nh...> - 2003-04-29 06:50:44
|
Salam, I'm using Active State's Perl 5.8 on my Win2K AS machine. I have a file that has a list of countries as an option list which I want to extract, and put each option in a line and add a closing </option> tag. After trying for hours I got this script, which worked fine except that it repeats any line that has an ending \n (newline). ---- Begin Perl script ---- #!/usr/bin/perl while (<STDIN>) { while (m/(<option[\w\s=3D\"]*>[\w\s\d&#;]+)/gi){ chomp(); print "$1</option>\n"; } }---- End Perl script ---- I'm running the script as: #perl extract.pl < countries.txt Can any one please help, and also explain some things: * How can I use \G (explained as: matches were the previous m//g left off)? * What is the difference between using chop() and chomp()? I read through the manual but just couldn't figure it out. Thanks in advance, Ossama Khayat |