Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Perl: the Markov chain saw
 
PerlMonks  

Re: Noob could use advice on simplification & optimization

by brx (Pilgrim)
on May 03, 2012 at 21:06 UTC ( #968809=note: print w/ replies, xml ) Need Help??


in reply to Noob could use advice on simplification & optimization

Nothing important to say, except bravo! :)

Anyway some advice you could follow if you really insist :) (I can't test your script)

use strict; use warnings;

'for' loops: try the perlish syntax

for(my $i = $#data; $i > 0; $i--) { if ($data[$i] =~ /\|/) { $last_line = $data[$i]; $i=0; # correct line found, exit loop. } } # or # for my $line (reverse @data) { $last_line = $line; last if $line =~ /\|/; }

line 70 - you don't need @result:

( $directory, $search_string, ..., $scan_down...) = split('|',$last_line);

line 136: you could use 'join':

print SAVED_SEARCH (join '|', $directory, $search_string, ..., $scan_down..., "\n");


Comment on Re: Noob could use advice on simplification & optimization
Select or Download Code
Re^2: Noob could use advice on simplification & optimization
by bgreg (Initiate) on May 03, 2012 at 21:54 UTC
    Cool, thanks for the response. I'll definitely make these changes. Using strict is going to be a challenge for me, this code isn't organized for that right now.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (18)
As of 2013-05-22 12:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (461 votes), past polls