From da7a0ae64572ce945820934a10e78fbd1e67900e Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Tue, 5 Jun 2012 21:18:40 -0500 Subject: reduced extra code in sbofind, seems to also be faster? huh. --- sbofind | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sbofind b/sbofind index 999801a..f431e6c 100755 --- a/sbofind +++ b/sbofind @@ -50,21 +50,18 @@ slackbuilds_or_fetch (); # find anything with $search in its name my (@findings, $name); my $found = 'FALSE'; -my $regex = qr/NAME:\s.*\Q$search\E.*/i; +my $name_regex = qr/NAME:\s+(.*\Q$search\E.*)$/i; +my $loc_regex = qr/LOCATION:\s+(.*)$/; my $fh = open_read ("$config{SBO_HOME}/SLACKBUILDS.TXT"); FIRST: while (my $line = <$fh>) { unless ($found eq 'TRUE') { - if ($line =~ $regex) { + if ($name = ($line =~ $name_regex)[0]) { $found = 'TRUE'; - my @split = split (' ', $line); - chomp ($name = $split[2]); next FIRST; } } else { - if ($line =~ /LOCATION/) { + if (my ($location) = ($line =~ $loc_regex)[0]) { $found = 'FALSE'; - my @split = split (' ', $line); - chomp (my $location = $split[2]); $location =~ s#^\.##; push (@findings, {$name => $config{SBO_HOME} . $location} ); } -- cgit v1.2.3