in reply to $_ and filehandles

We sort of understand what you are trying to do but assumption is the root cause for many evils. We have no idea what you know and what you don't to make a good reply. That's exactly why davido asked you to stay away from "Does not work" statements

Sample data (whatever is reqd to demonstrate the issue) and code that can be run to produce the problem will be much better.

If you had known that <FILE>; will populate $_ when used as while() conditional and not when it is called by itself the response would have been totally different as you are seeing something unexpected.

Going back to your question -

If i do this i get expected output

#!/usr/bin/perl use strict; use warnings; my ($field1,$field2) = (); $_ = <DATA>; ($field1, $field2) = split(/;/); print $field1,",",$field2; __DATA__ hi;there

output:

hi,there

Please note that playing around with $_ requires caution. check out perldoc perlvar and search for nasty_break().

cheers

SK