Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: problem unless I use ".="

by chargrill (Parson)
on May 13, 2007 at 14:30 UTC ( #615170=note: print w/ replies, xml ) Need Help??

in reply to problem unless I use ".="

Pretty sure you'll get the warning regardless if you use $a = $a . $b vs. $a .= $b, especially given the above code.*

In your above code, $baseball{yankees} hasn't been initialized, hence the warning that you're trying to use an uninitialized value in a concatenation.

You can get more detail if you use diagnostics; at the top of your program, which yeilds:

Use of uninitialized value in concatenation (.) or string at -e line 1 (#2) (W uninitialized) An undefined value was used as if it were already defined. It was interpreted as a "" or a 0, but maybe it was a mistake. To suppress this warning assign a defined value to your variables.

To help you figure out what was undefined, perl tells you what operation you used the undefined value in. Note, however, that perl optimizes your program and the operation displayed in the warning may not necessarily appear literally in your program. For example, "that $foo" is usually optimized into "that " . $foo, and the warning will refer to the concatenation (.) operator, even though there is no . in your program.

What are you trying to do, exactly?

If you just want to add a new key/value pair to your hash,

$baseball{yankees} = 'new york'; # OR $baseball{yankees} = $baseball{mets};

... will suffice.

* Update: Incorrect

s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2016-08-29 08:50 GMT
Find Nodes?
    Voting Booth?
    The best thing I ever won in a lottery was:

    Results (399 votes). Check out past polls.