Re: using scalar as an operator

2007-12-31 Thread Jeremy Kister
On 12/31/2007 7:10 PM, Chas. Owens wrote: Use the embedded pattern-match modifier. See perldoc perlre or http://perldoc.perl.org/perlre.html#'(%3fpimsx-imsx)' for more information. That's good info, thanks for the pointer! -- Jeremy Kister http://jeremy.kister.net./ -- To unsubscribe, e-mai

Re: using scalar as an operator

2007-12-31 Thread Jeremy Kister
On 12/31/2007 7:09 PM, Tom Phoenix wrote: There is no correct way to use a variable as an operator. [...] This is why '(?i)' was invented. You want something like this: perfect. Thanks! -- Jeremy Kister http://jeremy.kister.net./ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

Re: using scalar as an operator

2007-12-31 Thread John W. Krahn
yitzle wrote: my $regex = 'word'; my $regex2 = 'Word'; my $modifier = 'i'; my $string = 'a string that has Words in it'; print "match\n" if($string =~ s/$regex/$modifier/); print "match2\n" if($string =~ s/$regex2/$modifier/); You were missing the leading 's' for substitute and the final backsl

Re: using scalar as an operator

2007-12-31 Thread John W. Krahn
Jeremy Kister wrote: what is a correct way to use a variable as an operator ? i thought the following could work, but i get a syntax error on the matching line. my $regex = 'word'; my $modifier = 'i'; my $string = 'a string that has Words in it'; if($string =~ /$regex/$modifier){ print "ma

Re: using scalar as an operator

2007-12-31 Thread Chas. Owens
On Dec 31, 2007 4:29 PM, Jeremy Kister <[EMAIL PROTECTED]> wrote: snip > if($string =~ /$regex/$modifier){ snip Use the embedded pattern-match modifier. See perldoc perlre or http://perldoc.perl.org/perlre.html#'(%3fpimsx-imsx)' for more information. #!/usr/bin/perl use strict; use warnings; m

Re: using scalar as an operator

2007-12-31 Thread yitzle
my $regex = 'word'; my $regex2 = 'Word'; my $modifier = 'i'; my $string = 'a string that has Words in it'; print "match\n" if($string =~ s/$regex/$modifier/); print "match2\n" if($string =~ s/$regex2/$modifier/); You were missing the leading 's' for substitute and the final backslash. -- To uns

Re: using scalar as an operator

2007-12-31 Thread Tom Phoenix
On Dec 31, 2007 1:29 PM, Jeremy Kister <[EMAIL PROTECTED]> wrote: > what is a correct way to use a variable as an operator ? There is no correct way to use a variable as an operator. > my $regex = 'word'; > my $modifier = 'i'; > my $string = 'a string that has Words in it'; > > if($string =~ /$r

using scalar as an operator

2007-12-31 Thread Jeremy Kister
what is a correct way to use a variable as an operator ? i thought the following could work, but i get a syntax error on the matching line. my $regex = 'word'; my $modifier = 'i'; my $string = 'a string that has Words in it'; if($string =~ /$regex/$modifier){ print "match\n"; } Thanks, --