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

Re: my $var = join('|',@array) not behaving

by ww (Archbishop)
on May 09, 2008 at 02:39 UTC ( [id://685590]=note: print w/replies, xml ) Need Help??


in reply to my $var = join('|',@array) not behaving

Update What follows is mostly true (save the striken phrase), but see the answers above. I misread the square brackets as parens (probably because that'swhat I expected... which goes to show, if nothing else, that seeing what one expects rather than what exists is a source of many errors.

join expects a list.

From perldoc -f join:

join EXPR,LIST
Joins the separate strings of LIST into a single string with fields separated by the value of EXPR, and returns that new string. Example:
  $rec = join(’:’, login,$passwd,$uid,$gid,$gcos,$home,$shell);

Your @array is not a list. Rather, in this case (ie, in the way you've written the assignment to $print_string, the list has a single-element -- a reference to @array.

See References quick reference.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2026-04-23 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.