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";

In reply to Re: Seeking regexp @ARGV arrays Wisdom by Anonymous Monk
in thread Seeking regexp @ARGV arrays Wisdom by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.