Skip to content

Commit

Permalink
expand: garbage collect a global
Browse files Browse the repository at this point in the history
* ARGV is a list of files, which could be empty if stdin default is used
* Using a direct copy of ARGV provides no benefit
* The usage() function was previously converted to not take any params
  • Loading branch information
mknos authored Jan 3, 2025
1 parent 9df8833 commit 13eec96
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions bin/expand
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ my $Program = basename($0);
my %line_desc;
my $tabstop = 8;
my @tabstops;
my @files;

while (@ARGV && $ARGV[0] =~ /\A\-(.+)/) {
my $val = $1;
Expand All @@ -46,12 +45,10 @@ while (@ARGV && $ARGV[0] =~ /\A\-(.+)/) {
last;
}
@tabstops = split /,/, $val;
usage(1) if grep /\D/, @tabstops; # only integer arguments are allowed
usage() if grep /\D/, @tabstops; # only integer arguments are allowed
shift @ARGV;
}

@files = @ARGV;

# $tabstop is used only if multiple tab stops have not been defined
if(scalar @tabstops == 0) {
$tabstop = 8;
Expand All @@ -68,7 +65,7 @@ if(scalar @tabstops == 0) {
}
}

for my $file (@files) {
for my $file (@ARGV) {
my $in;
unless (open $in, '<', $file) {
warn "$Program: couldn't open '$file' for reading: $!\n";
Expand All @@ -79,7 +76,7 @@ for my $file (@files) {
}
close $in;
}
unless (@files) {
unless (@ARGV) {
while (<>) {
expand_line($_);
}
Expand Down

0 comments on commit 13eec96

Please sign in to comment.