Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: Using Subroutine Returns

by perrin (Chancellor)
on Apr 23, 2009 at 03:35 UTC ( [id://759470]=note: print w/replies, xml ) Need Help??


in reply to Re: Using Subroutine Returns
in thread Using Subroutine Returns

So complicated and ugly! Just concatenate it with the '.' operator.

Replies are listed 'Best First'.
Re^3: Using Subroutine Returns
by almut (Canon) on Apr 23, 2009 at 09:53 UTC
    So complicated and ugly!

    That's true, of course... but some people just want to interpolate :) — I have to admit I've also felt that urge at times...

    This is probably the outcome of the generalizing behavior of our brains: we've learnt we can interpolate scalars and arrays, so why not also hashes, functions, anything?  (This behavior, in and of itself, is certainly a Good Thing, BTW, otherwise we probably wouldn't be where we are today, messing with Perl... supported by those little silicon chips, etc.)

    Also, some people just find

    "abc ${\config('username')} xyz";

    easier to read/type than

    "abc ".config('username')." xyz";

    even though they are exactly the same number of chars.

    Anyhow, the nice thing is that with Perl's TIMTOWTDI-ness, everyone can get happy :)

Re^3: Using Subroutine Returns
by doug (Pilgrim) on Apr 23, 2009 at 17:30 UTC
    It is in a print, so a comma would be more natural than a dot. There is no need to build a single scalar when the operator takes a list.
    print config('username'), " is my username";
    Most likely the OP would want a \n in there too, but that isn't really part of the interpolation question.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-19 04:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found