Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Re: strings with options - how do I do this?

by Hofmator (Curate)
on Feb 27, 2003 at 10:31 UTC ( #239052=note: print w/replies, xml ) Need Help??


in reply to Re: strings with options - how do I do this?
in thread strings with options - how do I do this?

Works fine with the caveat that the string shouldn't contain any meta characters that glob might want to expand, like '*'. And this:
for ($text) { s/\[/{/g; s/\]/}/g; s/\|/,/g; }
could be written as: $text =~ tr/[|]/{,}/;

-- Hofmator

Replies are listed 'Best First'.
Re: Re: Re: strings with options - how do I do this?
by blakem (Monsignor) on Feb 27, 2003 at 11:04 UTC
    Good points... How about this:
    use File::Glob qw(:glob); sub parseit { my $text = shift; $text =~ tr/[|]/{,}/; $text =~ s/([\\?*])/\\$1/g; map {s/\\([\\?*])/$1/g; $_} bsd_glob($text, GLOB_BRACE | GLOB_NOCHECK); }

    -Blake

      thank you people ... that does it perfectly. I learnt my "something new" for today too.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2021-03-01 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?