--- Scott McWhirter <[EMAIL PROTECTED]> wrote: > On Mon, Jan 19, 2004 at 09:04:16PM +0000, Mikhael Goikhman wrote: > Sorry, i'm going to do a short perl rant... > > > Never write: > > > > open(...); > > > > If you want to catch problems, write something like: > > > > open(...) or die "Can't open file $fileName: $!\n";
> If he doesn't understand the syntax why should he write it? There are > lots of people that say... do it this way... but don't explain why. If > you say to someone, you should do it this way... explain why and what > the > syntax means. Oh, come now! Everyone knows that Perl's motto is: TMTOWTDI. The reason why he should write it a certain way is because it is the correct way. Mikhael did actually explain why, but not in so much detail. That is why the man pages and copious book exist about perl > For reference, > open(MOO,$file) or die "Barf on $file: $!\n"; > > If the open fails for some reason (permissions?) it will run the code > after the "or". So in this case it would die and give the message > supplied. $! in perl is a special variable containing any error messages > from external sources (ie: the file open). Actually $! will contain whatever error message is thrown up at that time. -- Thomas Adam ===== "The Linux Weekend Mechanic" -- http://linuxgazette.net "TAG Editor" -- http://linuxgazette.net "<shrug> We'll just save up your sins, Thomas, and punish you for all of them at once when you get better. The experience will probably kill you. :)" -- Benjamin A. Okopnik (Linux Gazette Technical Editor) ________________________________________________________________________ Yahoo! Messenger - Communicate instantly..."Ping" your friends today! Download Messenger Now http://uk.messenger.yahoo.com/download/index.html -- Visit the official FVWM web page at <URL: http://www.fvwm.org/>. To unsubscribe from the list, send "unsubscribe fvwm" in the body of a message to [EMAIL PROTECTED] To report problems, send mail to [EMAIL PROTECTED]
