lamasculo has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl #my hash which tries to "map" a regular expression to a a new name my %Ren2Dol = ( rrv193\d{4}cm => "RNF191", ); #pretend data line to teest my $line='rrv1931009cm.new090626'; #split the data line ($base,$rest)=split(/[\.\_]/,$line,2); #test print it to see that it split correxctly print "$base\n"; #try to see what new name would be my $newname=$Ren2Dol{$base}; print "$newname\n"; # a test print to make sure regular expression matches if ($line=~m/^rrv193\d{4}cm/) {print "line matched\n"}; if ($base=~m/^rrv193\d{4}cm/) {print "base matched\n"};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regular expression in a hash
by GrandFather (Saint) on Jul 08, 2009 at 09:39 UTC | |
by spazm (Monk) on Jul 08, 2009 at 21:55 UTC | |
by lamasculo (Novice) on Jul 08, 2009 at 16:06 UTC | |
|
Re: regular expression in a hash
by fullermd (Vicar) on Jul 08, 2009 at 09:30 UTC | |
|
Re: regular expression in a hash
by BioLion (Curate) on Jul 08, 2009 at 09:43 UTC | |
|
Re: regular expression in a hash
by Anonymous Monk on Jul 08, 2009 at 09:21 UTC |