Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Set Array Columns to 0

by jethro (Monsignor)
on Jul 05, 2012 at 16:41 UTC ( #980113=note: print w/replies, xml ) Need Help??

in reply to Set Array Columns to 0

Your second line will only initialize the first variable $dow with "", all the other variables will be set to undef

The simplest code to make it work is to extend the list on the right hand side of line 4 so that it will always be enough to fill all variables even if split would return the empty list:

($dow,$mon,$day,$year,$num1,$num2,$num3,$dow2,$mon2,$day2,$year2)= ( s +plit(/[,]/, $line),("") x 11 );

Note that 'x' is an operator that in this case produces a list of 11 empty strings. Naturally you could also use 0 instead of "".

Replies are listed 'Best First'.
Re^2: Set Array Columns to 0
by Anonymous Monk on Jul 05, 2012 at 21:18 UTC

    Is there any way to fill in the missing area (the top line where the date is) with comma-separated 0's? I tried your example and it does not print with zeros. Thank you.

      Just replace the quotes in ("") x 11 with your placeholder of choice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980113]
[marto]: yeah, so our hackerspace, we run mailman. that's a public discussion list, not a weekly buy our crap marketing list, people can unsubscribe at any time. What they can't do is delete their mails from the archive, or from the inboxes of our hundreds of user
[Corion]: marto: I'm not sure on how to treat mail archives. I think you could either set an auto-deletion timespan or an auto-anonymisation timespan if you wanted to do it right.
[Corion]: For PM, I think we'll create a user "gdpr", who gets assigned the nodes of users who want to give up their user status here.

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2018-05-22 08:26 GMT
Find Nodes?
    Voting Booth?