in reply to Re: What is the * postfix operator, pre-'feature postderef'?
in thread What is the * postfix operator, pre-'feature postderef'?

Gaaak I feel STUPID! Of course you are correct. The lack of spaces threw off my disused spatial recognition skills. And I just got new glasses, sheesh .... But it also threw me off that multiplying a string containing spaces by 1 results in the first "field" of the string, the same as 's/\s.*//'. One really ought to use:
$uptime=`cat /proc/uptime`; print ref(\$uptime)," $uptime\n"; $uptime =~ s/\s.*//; print ref(\$uptime)," $uptime\n";

Replies are listed 'Best First'.
Re^3: What is the * postfix operator, pre-'feature postderef'?
by GrandFather (Saint) on Sep 10, 2014 at 21:28 UTC

    If you want the first numeric field I'd use:

    ($uptime) = $uptime =~ /(\d+)/;

    which makes the intent much clearer. What's with the ref(\$uptime)?

    Perl is the programming world's equivalent of English