in reply to Propose addition to use warnings?
You must have done something weird in my_sub because for me, warnings already tell me that I'm using a closed filehandle:
#!/usr/bin/perl use strict; use warnings; open my $fh, '<', $0 or die "I can't read myself"; open my $fh2, '<', $0 or die "I can't read myself (2)"; my @lines = <$fh>; close $fh; sub my_sub { my( $this_fh, $line ) = @_; warn sprintf "At offset %d: %s", tell $this_fh, $line; }; while (my $line = <$fh2>) { my @data = my_sub($fh, $line); # copy/paste error, should have pas +sed $second_fh here # and of course a bunch of non-relevant stuff here } __END__ tell() on closed filehandle $fh at tmp.pl line 15. At offset -1: #!/usr/bin/perl tell() on closed filehandle $fh at tmp.pl line 15. At offset -1: ...
Maybe you can show us what you were doing in my_sub with the filehandle and where Perl didn't warn there?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Propose addition to use warnings?
by haukex (Archbishop) on Nov 28, 2016 at 15:02 UTC | |
by perldigious (Priest) on Nov 28, 2016 at 18:41 UTC |