On Jul 19, Jeff 'japhy' Pinyan said: >On Jul 19, Jerry Preston said: > >> $_ = "p8,INT,5" >> >> if( $_ =~ /(w+),INT,\d{2}$/ ) { >> } > >Well, you're not DOING anything inside the if block. I assume you are in >your actual code (it's best to SHOW us your actual code). > >I see one big error, one potential mistake, and one area for improvement. > >1. Your (w+) should be (\w+); you've left out an important backslash. >2. You might want to start your regex with ^, which anchors to the > beginning of the string. >3. You can leave out the "$_ =~" part. Regexes work on $_ by default. > You would need to keep the =~ in if you were working on $foo. > >So I'd rewrite it as > > if (/^(\w+),INT,\d{2}$/) { > print "matched: $1\n"; > }
Oh yeah, and you only have ONE digit after the comma. That means that your \d{2} won't match, since it's trying to match TWO digits. if (/^(\w+),INT,\d$/) { ... } Or perhaps you want \d+ instead. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ <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]