Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re^2: Optimization tips

by Marshall (Canon)
on Jul 24, 2022 at 17:24 UTC ( #11145687=note: print w/replies, xml ) Need Help??

in reply to Re: Optimization tips
in thread Optimization tips

I see that you fixed one "unreachable code" problem...
Op should be aware of this in his code:
To be inside of the while (<MAPPINGFILE2>) { loop means that you are not at the eof yet. When this while loop finishes, MAPPINGFILE2 will be eof, but not before.

UPDATE: I decided that this is not right. The read of the very last line will consume all characters and hence reach eof. So you can reach eof before a read of <MAPPINGFILE2> would return an undef (the normal way to detect eof).

while (<MAPPINGFILE2>) { chomp(); # Skip blank lines and comments next if /^(\s*(#.*)?)?$/; # Split mapping columns (tab) @mapping = split /\t/, $_; # Mapping is matching if ($line =~ m/$mapping[0]/) { $line =~ s/$mapping[0]/$mapping[4]/; @source = split /\t/, $line; $line =~ s/$source[2]/$mapping[2]\tALLOC_$sour +ce[2]/; push @lines2, $line; last; } elsif (eof(MAPPINGFILE2)) { #correction: ###### +Can happen push @rejects, "Lignes non mappées (Account): +"."\t".$line; } }

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2023-03-24 00:41 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (60 votes). Check out past polls.