aboutsummaryrefslogtreecommitdiff
path: root/sbofind
diff options
context:
space:
mode:
Diffstat (limited to 'sbofind')
-rwxr-xr-xsbofind30
1 files changed, 15 insertions, 15 deletions
diff --git a/sbofind b/sbofind
index 5e8931d..c530217 100755
--- a/sbofind
+++ b/sbofind
@@ -18,7 +18,7 @@ use warnings FATAL => 'all';
my %config = %SBO::Lib::config;
my $self = basename ($0);
-sub show_usage {
+sub show_usage () {
print <<EOF
Usage: $self (search_term)
@@ -37,30 +37,30 @@ EOF
my %options;
getopts ('hvir', \%options);
-show_usage () and exit (0) if (exists $options{h});
-show_version () and exit (0) if (exists $options{v});
+show_usage and exit 0 if exists $options{h};
+show_version and exit 0 if exists $options{v};
-my $show_readme = exists $options{r} ? 'TRUE' : 'FALSE';
-my $show_info = exists $options{i} ? 'TRUE' : 'FALSE';
+my $show_readme = exists $options{r} ? 1 : 0;
+my $show_info = exists $options{i} ? 1 : 0;
-show_usage () and exit (1) unless exists $ARGV[0];
+show_usage and exit 1 unless exists $ARGV[0];
my $search = $ARGV[0];
# if we can't find SLACKBUILDS.TXT in $config{HOME}, prompt to fetch the tree
-slackbuilds_or_fetch ();
+slackbuilds_or_fetch;
# find anything with $search in its name
my (@findings, $name);
-my $found = 'FALSE';
+my $found = 0;
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");
+my $fh = open_read "$config{SBO_HOME}/SLACKBUILDS.TXT";
FIRST: while (my $line = <$fh>) {
- if ($found eq 'FALSE') {
- $found = 'TRUE', next FIRST if $name = ($line =~ $name_regex)[0];
+ unless ($found) {
+ $found++, next FIRST if $name = ($line =~ $name_regex)[0];
} else {
if (my ($location) = ($line =~ $loc_regex)[0]) {
- $found = 'FALSE';
+ $found = 0;
$location =~ s#^\.##;
push @findings, {$name => $config{SBO_HOME} . $location};
}
@@ -68,9 +68,9 @@ FIRST: while (my $line = <$fh>) {
}
sub get_file_contents {
- exists $_[0] or script_error ('get_file_contents requires an argument');
- -f $_[0] or script_error ('get_file_contents argument is not a file');
- my $fh = open_read (shift);
+ exists $_[0] or script_error 'get_file_contents requires an argument';
+ -f $_[0] or script_error 'get_file_contents argument is not a file';
+ my $fh = open_read shift;
my $contents = do {local $/; <$fh>};
$contents =~ s/\n/\n /g;
$contents =~ s/ $//g;