Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Can a defined value be of zero length?

by BillKSmith (Chaplain)
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 browsing the Monastery: (4)
As of 2014-09-23 23:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (241 votes), past polls