#perl
31 October 2007
Total 28 pages. You are browsing page 3/28.
First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last
02:37 <****> :D
02:37 <****> If you use open that way, you can use Fatal.
02:38 <****> use Fatal qw( open close );
02:38 <****> Perhaps, but I like doing it manually.
02:38 <****> And those are core modules, silly.
02:38 <****> I'm trying to perfect my laziness whilst learning how to catch exceptions.
02:39 <****> You wouldn't be catching one with a die call.
02:39 <****> start small, learn to catch mice first
02:39 <****> Just FYI.
02:39 <****> apeiron: why not?
02:39 <****> Because die throws.
02:40 <****> sorry: I'm trying to perfect my laziness whilst learning how to catch/throw exceptions.
02:40 <****> Start small. Learn to catch mice first. :)
02:40 <****> i.e., have you read perldoc -f die?
02:40 <****> no
02:41 * jagerman hates "no modules, work policy"
02:41 <****> /etc/games is no good at canasta line 123.
02:41 <****> heheh
02:41 <****> I should hope not.
02:41 <****> Who *is* good at canasta?
02:41 <****> I bet Larry Wall is a mean canasta player.
02:42 <****> Probably extremely good at bridge too.
02:42 * CPAN upload: Perl6-Say-0.10 by JKEENAN
02:42 <****> Hooray for Say!
02:42 <****> newlines be dammed!
02:42 * apeiron shrugs, off to read before bed.
02:42 <****> Bridge is rather fun
02:49 <****> if i really really want to use IO::File....
02:49 <****> is this the way to do this?
02:49 <****>new("< $ps_file"); croak "Unable to open $ps_file" unless $fh;
02:50 <****> i wouldn't
02:51 <****> open my $fh, '<', $ps_file or croak "Unable to open $ps_file: $!";
02:51 <****> k
02:51 <****>open in that usage is just a front-end to open() anyways.
02:52 <****> Jmax: if I use Fatal, I don't need or croak "Unable to open $ps_file: $!" right?
02:52 <****> Fatal?
02:52 <****> Fatal.pm
02:52 <****> ah, I see
02:52 <****> perldoc Fatal
02:52 <****> Jmax: I don't want to use some random thing. Is that legit to use?
02:53 <****> Fatal might be core
02:53 <****> core: Fatal
02:53 <****> pravus: Added to perl core as of 5.00307
02:53 <****> but you should get in the habit of checking your opens anyway
02:53 <****> Jmax: seriously, why if it is an option in core?
02:53 <****> and closes/writes/whatever too. you never know when you're programming some application taht can't die for whatever reason
02:53 <****> perhaps it's a daemon and would rather log the error
02:53 <****> Fatal takes care of close.
02:54 <****> why not just use ' ... or die ...;'?
02:54 <****> Jmax: If I know I'm just opening/closing files on disk...
02:54 <****> Fatal.pm is in Perl Best Practices.
02:54 <****> The Fatal module is passed a list of builtins and, by the use of dark and terrible magics[*], it transforms those functions so that they no longer return false on failure; they now throw an exception instead. This means that the last three untested lines of the previous example are now perfectly acceptable. Either each builtin will succeed, or one will fail, at which point that builtin will throw an exception.
02:55 <****> the three previously lines being open / print / close.
02:55 <****> PBP is a lot like "The Bible", in that it's words to live by, but not words to live for.
02:55 <****> Maybe I have stronger faith in Jesus Christ than you?
02:55 * sili blinks
02:55 <****> Although, the Damian is rather devilish.
02:55 <****> what happens when you want to throw some exception object when an open() fails?
02:55 <****> who said it was *that* "The Bible"?
02:56 <****> initself: laziness or flexibility. your choice.
02:58 <****> heh the code for Fatal is pretty neat
02:58 <****> I can't say I really even understand how it works
02:59 <****> probably just creates a copy of the standard open/close with one that dies and lets Exporter do the replacement magic
03:00 <****> read the code. it's whack.
03:00 <****> :o
03:00 <****> :O
03:00 <****> ah, it uses AUTOLOAD
03:00 <****> that's not too "whack" :D
03:00 <****> how about something like this?
03:00 <****>parse ($line);
03:01 <****> what about it?
03:01 <****> with code like that, do you always have to check the return value for errors or might there be other 'special' variables like $! with error data?
03:01 <****> $proto = prototype $sref; <- is 'prototype' a core command? I didn't think it was..
03:01 <****> initself: that's up to the author
03:01 <****> in very few cases should a module play with $!
03:01 <****> but it can
03:01 <****>parse()
03:01 <****> initself: usually code will use return values for errors.. $! is just crazy.
03:01 <****> jawnsy: it is, perldoc -f prototype. it might be an operator
03:02 <****> wow that's messed up
03:02 <****> jawnsy: have you read HOP yet? :D
03:02 <****> I've never seen that before
03:02 <****> what?
03:02 <****> there is much to learn, (possibly elder) padawan
03:02 * dwu giggles.
03:02 <****> perlbot HOP
03:02 <****> Higher Order Perl, http://hop.perl.plover.com/
03:03 <****> I may have read it before
03:04 <****> but not recently.
03:04 <****> it hasn't been around very long
03:04 <****> yeah, only a couple of years
03:04 <****>{RaiseError}.
03:04 <****> initself: in that case the author gives you a choice about how you want to develop your error handling strategy
03:06 <****> Khisanth: I haven't known Perl more than a year or two :p
03:06 <****> That's a long time o.O
03:06 <****> perlbot IHOP
03:06 <****> unless I'm getting older faster than I realize, which may be a bad sign
03:07 <****> I need to get HOP online.
03:07 <****> DSterling: PANCAKES are good.
03:07 <****> i was just going to say that, yrlnry__
Total 28 pages. You are browsing page 3/28.
First :: Prev :: [1] [2] [3] [4] [5] [...] :: Next :: Last
