in reply to $_ and filehandles
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
|
|---|