http://qs321.pair.com?node_id=550663


in reply to Re: Log File Parsing using "split"
in thread Log File Parsing using "split"

($name, $city, $state, $zip) = (split / /, $_)[4,5,6,8];

I think the OP is probably with the default behavioiur of split() - nothing to be gained by spelling it out.

It would be very unusal in real code that in an assignement statement such as the one above you would really want to overwrite the values of four existing variables. It would be far more common that this is the point in the code at which these four variables would be introduced.

Newcommers to Perl often have problems with variable declaration. When presenting issolated code fragments all assignment statements should have a my() if is more likely than not that they would need one in any well-written real code.

my ($name, $city, $state, $zip) = (split)[4,5,6,8];