in reply to Re^3: Error handling
in thread Error handling

Basically, I think its not something to deal with what posts_for retrieves. Its about how to skip this error. I don't know but if there is something that I can do to skip this error which stops my program. Something like eval{}! If anyone knows about this error kindly help me. That would be really great. Thank you.

Replies are listed 'Best First'.
Re^5: Error handling
by ikegami (Patriarch) on Jul 18, 2011 at 20:20 UTC
    Assuming the text comes from an exception being thrown, eval { } will catch it.

      Well, thank you for your help. Another expert really helped me to solve this query without really knowing what is posts_for and all stuff. No offense, but I think stackoverflow is far better than and easy to handle. I posted the same question twice. I understand initially it was my mistake to put up the question as I am new to programing but the response I got here is not appreciable. Well, as perlmonks is to learn from others mistake as what I understood from the monks here. I would like to write that not only it matters if someone puts up the question in right way but it also matters how the person understands the easy question. Sometimes it may happen that the question is rather easy but the person makes it complicated and hard to understand for himself. For people who want to know the answer for my question, I have posted it down. I am all new to programing, I don't know how much this helps to rest of all, and so think each bit is important.

      while (<IN0>) { my $currentURI = $_; chomp($currentURI); my @tags = eval { # Use eval to make this safe, $@ will con +tain any error $c->posts_for(uri =>"$currentURI"); } my $error = $@; if (defined($error)) { warn($error); # If eval failed, warn and skip to next l +ine next; } if (! @tags) { next; # Assuming no tags means go to next line +in input } ... do something ... }

        the response I got here is not appreciable.

        What you posted on StackOverflow was completely different than what you posted here.

        On StackOverflow, you asked "how do I fix this error and move ahead to next uri?" Here, you didn't even ask a question! First you posted about an error you didn't want to fix. Then you posted about wanting an alternative to eval.

        How can we help you achieve your goals if you don't state them?

        For people who want to know the answer for my question

        It would have gone a lot smoother if there had actually been a question to answer!

        I strongly recommend that you read How (Not) To Ask A Question before posting here or on StackOverflow again. (Obviously some of it is specific to PerlMonks, but there's lots of good tips in there that aren't specific to PerlMonks.) Good luck!