Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

RE: Re: Can perl do...?

by nashdj (Friar)
on Jun 05, 2000 at 15:56 UTC ( #16386=note: print w/ replies, xml ) Need Help??


in reply to Re: Can perl do...?
in thread Can perl do...?

There is still one thing beyond me. What about.. $foo;
What purpose does it serve being able to do that. As I said before all I can think it would be good for is as a return for a sub. (I really need to get some books dont I)
I'm just curious :)


Comment on RE: Re: Can perl do...?
Download Code
RE: RE: Re: Can perl do...?
by athomason (Curate) on Jun 05, 2000 at 23:17 UTC
    That doesn't do anything at all; you're introducing a value into a null context. That is, your statement has no effect whatsoever since there are no side effects. For instance, try the one-liner perl -we "$_;"Using the -w flag will let you know when your statements aren't doing anything.
      Ok, so if it does nothing, then why not in a future perl release allow that to assign the value to $_. Sure it might sound completely useless, but if it already is useless. I would find something like that very handy. As for making sense, it seems to do that too..
      It does one thing nashdj alluded to. As the last statement in a block, the resultant value of the block is the value in the variable.

      For example, in the Everything source they'll occasionally have a subroutine that does something like:

      sub do_thisorthat { my ($text, $op) = shift; my $code = get_op($op); $code->$text; # manipulate text $text; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://16386]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (11)
As of 2015-07-07 00:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (86 votes), past polls