"Chris Charley" <char...@pulsenet.com> writes: > You could do that in 1 line - See the following small program. > (The line using a 'grep' solution is commented out. It would work as well). > > > #!/usr/bin/perl > use strict; > use warnings; > > while (my $id = <DATA>) { > chomp $id; > #if (grep /itemid=.*?[^\w-]/, split /&/, $id) { > if ($id =~ /itemid/ && $id !~ /itemid=[\w-]+(?:&|$)/) { > print "Bad id: <$id>\n"; > } > } > > __DATA__ > itemid=AT18C&i_AT18C=1&t=main.htm&storeid=1&cols=1&c=detail.htm&ordering=asc > c=detail.htm&itemid=AT18C > itemid=AT18/C > t=main.htm&storeid=1&cols=1&c=detail.htm&ordering=asc
This might be a string with a bad item id because there is none: Are you going to process the string, assuming that it is a good item id? How do you determine the beginning of the relevant sequence --- and thus whether the string contains a good item id or not --- when the string might not contain 'itemid' to designate the beginning? I think you might need to work with cleaner definitions, and/or attempt to find the good item ids instead of the bad ones. > itemid=?AT18C > > > When this is run, it prints out: > > Bad id: <itemid=AT18/C> > Bad id: <itemid=?AT18C> > > Chris -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/