> >> I can usually figure out regexes, and this one seems simple, but it
> >> still eludes me--
> >>
> >> I'm looking for a regex (or a couple of regexes) to do the
> following:
> >>
> >> blahblah{ab,abcd}blah --> blahblah(ab|abcd)blah
> >> blahblah{a,b,c}blah --> blahblah(a|b|c)blah
> >
> > Well, you can do
> >
> > tr/{},/()|/
> >
> > I don't know if that's robust enough for what you're doing...
>
> Probably not, since there may be commas elsewhere in the string.
So you only want to replace commas inside of the { } brackets? Why
didn't you say that the first time :-)
Can you do this:
$var =~ s/\{([^}]*)\}/$v = $1; $v =~ s!,!|!g; qq!($v)!/ge;
> >> If it's not obvious I'm trying to glob-select files like the tcsh
> >> would. I've got the rest, this is the last part...
> >
> > Doesn't File::Glob have the ability to do this already?
>
> Perhaps. I'm dealing with many thousands of files on perl 5.4, which
> doesn't handle globbing correctly on large numbers of files.
> This script
> has to be super-portable, meaning I can't guarantee that the
> destination
> platform will have any modules installed (which I don't know how to do
> anyway).
In this case, opendir() and readdir() are your friends.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>