Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use a variable for the modifier in a match ?? 1

Status
Not open for further replies.

cptk

Technical User
Mar 18, 2003
305
US
if ( $name =~ /$sp/i ) ### works as expected

...but I want to instead use:

my $cs="i"
if ( $name =~ /$sp/$cs ) ### can I somehow use a variable for the modifier?

PS - I don't want to convert everything to a specific case -i.e. - \U
 
Hi

Code:
[b]my[/b] [navy]$cs[/navy][teal]=[/teal][green][i]"(?i)"[/i][/green]
[b]if[/b] [teal]([/teal] [navy]$name[/navy] [teal]=~[/teal] [green][i]/$cs$sp/[/i][/green] [teal])[/teal] [gray]# yes, you can. see [url=http://perldoc.perl.org/perlre.html#Extended-Patterns]man perlre | Extended Patterns[/url][/gray]

Feherke.
 
Thanks Feherke ... I investigate this ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top