Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Motherfuckin' Perl

Name: Anonymous 2012-07-13 15:44


$thingy = "asdf1.jpg";
$num = $thingy =~ s/.*/asdf/;
print $num;


Why the fuck is this outputting a "1" instead of "asdf"?

Name: Anonymous 2012-07-13 16:57

Because in scalar context =~ returns the number of matches. In list context it returns matches themselves. So:
($num) = $thingy =~ s/.*/asdf/;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List