Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Catch XML error

by philcrow (Priest)
on Jul 13, 2007 at 20:44 UTC ( #626535=note: print w/ replies, xml ) Need Help??


in reply to Catch XML error

Try wrapping in eval:

my $value; eval { $value = $record1->getAttribute('value1'); }; next FILE if ( $@ );

Note the scope. Define the variable outside the eval, or you'll only be able to use it in the block.

Phil

The Gantry Web Framework Book is now available.


Comment on Re: Catch XML error
Download Code
Re^2: Catch XML error
by kyle (Abbot) on Jul 13, 2007 at 23:31 UTC

    Note that the eval will catch all errors, not just this one. It might be prudent to look at the contents of $@ (see perlvar) to see if the error you caught is really the one you want to skip silently.

    my $value; eval { $value = $record1->getAttribute('value1'); }; if ( $@ ) { next FILE if ( $@ =~ /^duplicate attribute/ ); die $@; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://626535]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-12-28 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls