deibyz has asked for the wisdom of the Perl Monks concerning the following question:
I have some functions that perform inplace edits on files passed as arguments. I set $^I to use <> "magic". They look like that:
Now, I would like to check if all the files were successfully opened (like in open or die "$!"), but I can't find anything in the documentation that tells me how to do it. Is there anyway to do it without refusing to use $^I and <> "magic"?sub inplace{ my @files = @_; local ($^I, @ARGV) = (".bak", $file); # Now i can use <> while(<>){ # do stuff on $_ print; } }
Edited: Forgot local
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checking status of implicit open (diamond operator)
by BrowserUk (Patriarch) on Mar 17, 2005 at 12:50 UTC | |
by deibyz (Hermit) on Mar 17, 2005 at 14:37 UTC | |
by BrowserUk (Patriarch) on Mar 17, 2005 at 14:55 UTC | |
|
Re: Checking status of implicit open (diamond operator)
by Joost (Canon) on Mar 17, 2005 at 12:51 UTC |