Thanks that works really well.

I was complicating my life by using the eval...

Thanks again
Francis

-----Original Message-----
From: Matt Schneider [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 31, 2004 11:54 AM
To: Francis Paulin; [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: RE: [Perl-unix-users] Capturing an evaluated pattern matching

I was able to get this to work by just doing normal regular expression
matching.
<snip>
$stringFromFirstFile  = "Test: trying to capture this part of the string";
$stringFromSecondFile = "^Test: (.*)";
($capture) = $stringFromFirstFile =~ /$stringFromSecondFile/;
print "$capture\n";
<snip>


Matthew Schneider
System Administrator / Programmer
SKLD Information Services, LLC
303.820.0863


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of
Francis Paulin
Sent: Wednesday, March 31, 2004 9:31 AM
To: [EMAIL PROTECTED]; Perl-Unix-Users
([EMAIL PROTECTED])
Subject: [Perl-unix-users] Capturing an evaluated pattern matching


Hi,

I'm trying to capture an evaluated pattern matching.
The code sample looks like that:

<snip>
# In the real script, these two scalars received their values from external
files
$stringFromFirstFile = "Test: trying to capture this part of the string";
$stringFromSecondFile = "^Test: (.*)"

# That's why I will try to use an eval here:
$expression = "\"$ stringFromFirstFile \" =~ /" . $ stringFromSecondFile.
"/";

# This work whenever $ stringFromFirstFile starts by "Test:" (eval return 1)
if (eval($expression))
{
    # Wants to capture the (.*) of $ stringFromSecondFile but $1 is always
empty
    $capture = $1; # Does not work
}
<snip>


Someone knows how I can fix this?
Thanks

Francis Paulin
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to