in reply to Checking status of implicit open (diamond operator)

Set a __WARN__ handler.

>perl -i.bak -e"$SIG{__WARN__}=sub{ warn qq[failed:$ARGV]}; print <>" +fred.dat failed: fred.dat at -e line 1.

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

Replies are listed 'Best First'.
Re^2: Checking status of implicit open (diamond operator)
by deibyz (Hermit) on Mar 17, 2005 at 14:37 UTC
    Thank's a lot for your reply! Was exactly what I need ++

    Now I have to make sure I'm not trapping the rest of the warnings, any guidance on where to search for info?

      You're localising $^I and @ARGV, localise $SIG{__WARN__} also:

      sub inplace{ my @files = @_; local($^I, @ARGV)=(".bak", $file); # Now i can use <> local $SIG{__WARN__} = sub{ ## Handle open errors here }; while(<>){ local $SIG{__WARN__}; # disable it for loop body # do stuff on $_ print; } }

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco.
      Rule 1 has a caveat! -- Who broke the cabal?