in reply to Seeking regexp @ARGV arrays Wisdom

I haven't quite understood what you're trying to do but
m#^(?!-\s)$#
Will only match an empty string (which you don't have in your @ARGV as far as I can tell). And
m#^(-\s)$#
won't match anything either because Bash removes all unquoted whitespace.

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
    `whatis --wildcard *`

    The * will be expanded by the shell before whatis is called. If the intent is to have * be expanded to the files in the current directory, then the --wildcard switch can be dropped, but if the intent is to have the * be used in whatis's database search (which goes beyond the files in the current directory!), the * needs to be quoted, e.g. `whatis --wildcard "*"` - or use a module that can bypass the shell, such as capturex from IPC::System::Simple.

      The * will be expanded by the shell before whatis is called.
      Yes, I think that was what the OP intended. I'm just too lazy to read the manpage for 'whatis'. This thing doesn't seem very useful to me.