Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: RegExp eating my $1

by busunsl (Vicar)
on Jul 31, 2008 at 21:30 UTC ( #701534=note: print w/ replies, xml ) Need Help??


in reply to RegExp eating my $1 - FIXED!

I haven't run your program yet, but a few things struck my eyes:

$line =~ m/^(.{6}).*/; my $ffc = $1;

Regexes are not always better/faster than anything else, in this case the substr function might be better.
E.g.:

my $ffc = substr($line, 0, 6);

If you want to assign the captured part of a match to a variable, you can do it like this:

my ($foo) = $bar =~ /(...)/;

Mind the parenthesises around $foo, the match returns a list of values.

Your loop through the keys of %files is uneccessary, use the exists function.

Perhaps you might be able to streamline your program a bit, so that the error is more obvious.


Comment on Re: RegExp eating my $1
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://701534]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-08-01 12:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Who would be the most fun to work for?















    Results (12 votes), past polls