in reply to Re: Access elements of $_
in thread Access elements of $_
What is the difference in using an array or doing it as above ? I thought split will split a string into an array of strings anyway. Hence I'm a bit puzzled as to why I explicitly have to use an array as per your example. Is this better programming practice ?$id = 1; # <--- semicolon was missing open(MYFILE,"/var/tmp/mylist.dat") or die "Cant open mylist.dat" while (<MYFILE>) { # <--- wrong file handle fixed chomp; split /,/; die "Request Id $id already present in file\n" if $_[0] eq $id; } close MYFILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Access elements of $_
by shmem (Chancellor) on Aug 12, 2010 at 14:29 UTC | |
|
Re^3: Access elements of $_
by Anonymous Monk on Aug 12, 2010 at 14:24 UTC |