Hi all.
I'm trying to whip up a perl script...and it's been a while since I've messed with perl.
I've got a line of text stored in a variable, aptly named $line and I've got a pattern I've defined called $pattern.
I'd like to see if I can find $pattern in the $line.
If my pattern were simple text, such as "abcd" I'd do something like:
if ( $line =~ m/abcd )
{
print "Match found, line contains abcd.";
}
However, I'd like to know if it's possible in Perl to do this:
if ( $line =~ m/$pattern )
{
print "Match found, line contains abcd.";
}
Would there be any constraints if my $pattern had characters I would normally escape with the \?
*edit* sorry about the code...tried to do the attach code..but it doesn't show up in preview...so thought it was lost. No idea how to "remove" the attached code block either.
I'm trying to whip up a perl script...and it's been a while since I've messed with perl.
I've got a line of text stored in a variable, aptly named $line and I've got a pattern I've defined called $pattern.
I'd like to see if I can find $pattern in the $line.
If my pattern were simple text, such as "abcd" I'd do something like:
if ( $line =~ m/abcd )
{
print "Match found, line contains abcd.";
}
However, I'd like to know if it's possible in Perl to do this:
if ( $line =~ m/$pattern )
{
print "Match found, line contains abcd.";
}
Would there be any constraints if my $pattern had characters I would normally escape with the \?
*edit* sorry about the code...tried to do the attach code..but it doesn't show up in preview...so thought it was lost. No idea how to "remove" the attached code block either.