Script:
$aString = "This is Just a temp string just for fun";
print '^^^^^^^^' . "\n";
if( $aString =~ /^This\sis.*just/ )
{
print $aString . " ->true<-\n" . "^^^^^^^^" ."$1";
}
else
{
print $aString . " ->false<-\n" . "^^^^^^^^" ."$1"
}
Output:
^^^^^^^^
This is Just a temp string just for fun ->true<-
^^^^^^^^
Questions:
- Why $1 is empty?
- How to know how much sub-expression in
aStringis matched?
Pls clarify.
Your expression has no capture groups (
()) in it. Perhaps you mean:Once you have captured some data, you can test it however you like.