On May 10, Dave Chappell said: >I read a file line by line, on each line if any numbers in the range >specified below exist between comas, > >Example: >Line 1> hello,world,123,, >Line 2> The grass,456, is,greener, >Line 3> On,533,the,other, side >Line 4> As, long, as the,10000,grass is watered >Line 5> Bye,world,680,, > >print the line to another file. I have tried different variations. In the >example above and based on my ranges, line 3 & 5 should be printed to >another file. Where am I going wrong?
>(/,[512..520|528..568|576..578|592..600|608..622|624..670|672..685|768..771] You can't do that. A character class is for CHARACTERS, not strings. And ranges don't work like that either. You could do something like this: my $num_rx = join '|', 512..520,528..568,576..578, ...; while (<FILE>) { if (/,($num_rx),/) { print "got #$1\n"; } } Or you could make a regex that matches those ranges of numbers, but that's a considerably more daunting task: /5(?:1[2-9]|2[089]|[345]\d|6[0-8]|7[678]|...)/ I think the above method is better in the long run. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]