Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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.

Replies are listed 'Best First'.
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2018-03-18 22:33 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.