in reply to Seeking regexp @ARGV arrays Wisdom
Will only match an empty string (which you don't have in your @ARGV as far as I can tell). Andm#^(?!-\s)$#
won't match anything either because Bash removes all unquoted whitespace.m#^(-\s)$#
I also have no idea why you're pushing and shifting, so I don't know whether you're using them incorrectly, but my intuition says 'yes'
Anyway, Perl can do backticks and can change directories, so your users don't need to bother:
use strict; use warnings; sub usage { die <<END Usage: $0 <directory of binaries you want to test your knowledge of> For example: $0 /usr/bin END } my $path = shift or usage(); -r -x -d $path or usage(); chdir $path or die $!; my @whatis; print "wait a little...\n"; for (`whatis --wildcard * 2>/dev/null`) { chomp; push @whatis, [ split /\s+-\s+/, $_ ]; } print "(control-d to exit)\n\n"; MAINLOOP: while (1) { for (@whatis) { print $_->[0]; defined <STDIN> or last MAINLOOP; print "\t", $_->[1], "\n\n"; } } print "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Seeking regexp @ARGV arrays Wisdom
by Anonymous Monk on Dec 21, 2014 at 17:03 UTC | |
by Anonymous Monk on Dec 21, 2014 at 17:09 UTC |