Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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.


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?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (14)
As of 2015-06-30 15:07 GMT
Find Nodes?
    Voting Booth?

    What kind of chocolate gives you the most pleasure?

    Results (790 votes), past polls