Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: qw space issues

by Mr. Muskrat (Canon)
on Aug 26, 2012 at 17:21 UTC ( #989849=note: print w/replies, xml ) Need Help??

in reply to qw space issues

I'm curious. Why are you "too lazy to put quotes around"?

Based on your post, it's obvious that you don't understand how qw() works. It is often called "quote words". It will give you a list of literal strings.

&comgetter(qw(Aardgas Goud brent olie Koper,)) will pass the list ("Aardgas", "Goud", "brent", "olie", "Koper,") into the comgetter subroutine.

tobyink's sample uses qw() which you now understand and q() which returns a literal string (although he used an alternate quoting character 'w'). &comgetter(qw(Aardgas Goud), q wbrent oliew, qw(Koper,)); is the same as writing comgetter(qw(Aardgas Goud), q(brent olie), qw(Koper,)); or even comgetter('Aardgas', 'Goud', 'brent olie', 'Koper,');.

More information is available in perlop's section on Quote and Quote-like Operators.

BTW, don't use an ampersand (&) in front of the subroutine name unless you understand what you are asking for and need it for correct functionality. As used above, you're telling Perl to call your subroutine and ignore the prototypes in place on that subroutine. Assuming this is the same comgetter subroutine you shared in a previous thread, then you don't have prototypes in place (and the name of the subroutine doesn't conflict with a built-in function) so using it is misleading to anyone who sees the code. Save using the ampersand for when you need it. See perlsub for all the details. (I know that many argue that beginners should always use it but I disagree. It just ingrains bad habits.)

Replies are listed 'Best First'.
Re^2: qw space issues
by robertw (Sexton) on Aug 29, 2012 at 19:53 UTC

    Thank you for your reply:), I will read thos paragraphs and I was unaware of the ampersand meaning: I just people it that way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989849]
LanX leaves with a song of the Chjuman League
[ambrus]: LanX: that's funny because it's actually the upper class that sleep in hotels, so they're the ones who should know how it's pronounced
[LanX]: h is mute in French (and most other romanic languages)

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (12)
As of 2017-03-27 17:31 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (321 votes). Check out past polls.