Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Using qw

by GrandFather (Sage)
on Nov 18, 2005 at 01:52 UTC ( #509666=note: print w/replies, xml ) Need Help??

in reply to Using qw

In both cases you have an array and print does not insert any extra characters between the elements of an array. You can use join to do that however:

use strict; my @days; @days = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday); print ((join ' ', @days), "\n"); print join ' ', qw(Monday Tuesday Wednesday Thursday Friday), "\n";


Monday Tuesday Wednesday Thursday Friday Saturday Sunday Monday Tuesday Wednesday Thursday Friday

To see why I put the brackets in try these two lines:

print ((join ' ', @days), "x\n"); print join ' ', @days, "x\n"; #prints: Monday Tuesday Wednesday Thursday Friday Saturday Sundayx Monday Tuesday Wednesday Thursday Friday Saturday Sunday x

Note the space before the x in the second line because @days, "x\n" is a list that join acts on, rather than the paraneter for join followed by a parameter for print.

DWIM is Perl's answer to Gödel

Replies are listed 'Best First'.
Re^2: Using qw
by Tech77 (Novice) on Nov 18, 2005 at 19:15 UTC
    Excellent explanation GrandFather. Thank you and thank you to everyone else who wrote in. I am working through your examples.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://509666]
[1nickt]: Interesting article on the Coming Software Apocaplyse that I found while following one of eyepopslikeamosqui to's posts. Posits that no one can guarantee the quality of, or even understand, the 100 million lines of code in a mo
[holli]: you know, monk days are fun and all. but too many of them are bad for your health
[1nickt]: ...modern car. Suggests using TLA+ or other software modeling language to autogenerate code.
1nickt is not sure more and more layers separating the programmer from the program is the right way to go...
[holli]: happy one, shmem ;)
[1nickt]: I had an interview couople of weeks ago, heard from a principal engineer that a friend of his who works at The Google told him that the self-teaching software that determines the dynamic pricing for their adverts...
[1nickt]: ... has become so complex that there is no one at the Goole who knows what it does.
[marto]: William Gibson was right
[moritz]: a classical problem with machine learning
[1nickt]: moritz isn;t the difference today that the machine learning algos are in charge of most stuffs?

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (11)
As of 2017-11-21 13:00 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (301 votes). Check out past polls.