I have the code below. I also am thankful someone in this forum told me about expresso so I can build regular expressions quite easily. Unfortunately, some things don't move over to perl without issue. I saw some example code that said what I'm doing is possible in perl, but when I write it, it doesn't give me what I want. I'm just trying to get the results of the first matched group in the code below as $1 but it's not doing it. There must be a simple explanation but I can't see it.
#!/usr/bin/perl -w
my $msline ="";
my $dataline ="";
my $msnumtext ="MSNumbers=";
$msline = "<TD CLASS=\"shared\"><a href=http://www.mydomain.com/aac/index.php?Action=sm_hot&MSNumbers=316030>316030</a></TD>";
if ($msline =~ /$msnumtext(\d)+/) {
print "Msline is: $msline\n";
$dataline = $1;
print "Dataline value is: $dataline \n";
print "msnumtext is: $msnumtext \n";
}
What I'm trying to accomplish here is simply to get the digits after the MSNumbers= so in this example it would be "316030"
Thanks in advance.
it's not doing it
Example doing basically the same thing from the link reference you gave:
1. $x = "cat dog house"; # 3 words
2. while ($x =~ /(\w+)/g) {
3. print "Word is $1, ends at position ", pos $x, "\n";
4. }
What is the result I'm getting? Right here:
Msline is: <TD CLASS="shared"><a href=http://www.mydomain.com/aac/index.php?Action=sm_hot&MSNumbers=316030>316030</a></TD>
Dataline value is: 0
msnumtext is: MSNumbers=
So...value is zero. I would think the value would be 316030
Anyone else who may know why I'm getting zero instead of 316030?