
FishMonger
Veteran
/ Moderator
Jun 23, 2009, 10:34 AM
Post #10 of 10
(4260 views)
|
Re: [aravindprasad] strict problems
[In reply to]
|
Can't Post
|
|
Anyways this is a complete code example: #!/usr/bin/perl -w use strict; mainsub(); sub mainsub { open FH, ">filename.ext" || die "failed"; sub1(); close FH; } sub sub1 { print FH "printing to FH in sub1 though it was opened in mainsub\n"; return 1; } This will create a 0 bytes filename.ext and print the message to the screen. It is my personal opinion that this should at least elicit a warning from perl. -AP If that's true, then your perl installation is broken. Other than using the -w switch, which you should not do, instead of the warnings pragma, that is the same as what I have already shown to work. Please list, execute and post your example as I did. Now, if you're saying that the actual production code, which obviously differs from the posted example, exhibits this behavior, then that is certainly possible. I can only help you troubleshoot the code you post.
|