The following script
[blue]$_="1234 56 752";
@x=$_=~m/(\d*)/;
print "\$1=$1 ,\$x[0]=$x[0] and \@x=@x\n";[/blue]
produces an output
[blue]$1=1234 ,$x[0]=1234 and @x=1234[/blue]
just as I expected from the documentation. But when I did a global match like
[blue]$_="1234 56 752";
@x=$_=~m/(\d*)/[red]g[/red];
print "\$1=$1 ,\$x[0]=$x[0] and \@x=@x\n";[/blue]
no value was attached to $1:
[blue]$1= ,$x[0]=1234 and @x=1234 56 752[/blue]
Can somebody explain the behaviour of $1 in this context?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
[blue]$_="1234 56 752";
@x=$_=~m/(\d*)/;
print "\$1=$1 ,\$x[0]=$x[0] and \@x=@x\n";[/blue]
produces an output
[blue]$1=1234 ,$x[0]=1234 and @x=1234[/blue]
just as I expected from the documentation. But when I did a global match like
[blue]$_="1234 56 752";
@x=$_=~m/(\d*)/[red]g[/red];
print "\$1=$1 ,\$x[0]=$x[0] and \@x=@x\n";[/blue]
no value was attached to $1:
[blue]$1= ,$x[0]=1234 and @x=1234 56 752[/blue]
Can somebody explain the behaviour of $1 in this context?
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]