I'm miss understanding something basic about the numbered values like
$1 $2 in a s/// operation.
In this script... I don't understand why $line has the value it does
when the $2 paren enclosed regex does not match anything.
#!/usr/local/bin/perl
use strict;
use warnings;
my $line;
my $data =
'KVM","id":815,"parent":797,"dateAdded":1212954973000000,"lastModified":1245888615000000,"type":"text/x-moz-place-container","children"';
($line = $data) =~ s/(^.*?)(\"uri\".*?)(\"\}|\",\")(.*$)/$2/;
print "$line" ."\n";
output (wrapped for mail:
KVM","id":815,"parent":797,"dateAdded":1212954973000000,"lastModified"\
:1245888615000000,"type":"text/x-moz-place-container","children"
The regex (\"uri\".*?) Doesn't match at all so I would expect the $2
to return ''. But instead it appears to return the whole line.
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/