Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Can a defined value be of zero length?

by BillKSmith (Deacon)
on Apr 19, 2014 at 23:20 UTC ( #1082923=note: print w/ replies, xml ) Need Help??


in reply to Can a defined value be of zero length?

Consider using a prompt module. (Untested)

use strict; use warnings; use IO::Prompt::Hooked; my %options = ( message => 'Enter Pattern> ', validate => sub {eval {qr /$_[0]/}; return $@}, error => "Invalid Pattern\n", escape => qr/^\s*$/, ); my $dir = '/etc'; while (my $pattern = prompt %options) { my @matched = grep { /$pattern/ } glob "$dir/*"; do{ local $, = "\n"; print "@matched\n";}; }
Bill


Comment on Re: Can a defined value be of zero length?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1082923]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (16)
As of 2015-07-01 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (12 votes), past polls