IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New And I would point out that...
you really want to check whether mkdir succeeds. Perhaps you don't have permissions to the directory it is in? Perhaps there is a file there of that name?

This is somewhat mitigated by the fact that he shortly afterwards tries to create a file in that directory and checks $! there. So he will notice the error. But good habits are good habits.

Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New How to do that...
mkdir($foo) or die "Unable to make directory!" unless -d $foo; ? Does that need parentheses anywhere?

Note that I was just demonstrating using -d, and not actually putting any thought into the answer whatsoever. ;-)
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New That works but...
There is a reason why Perl does not let you nest if's directly. It is confusing. Perl allows enough cryptic things, but even Larry drew the line at that one.

Create a block for that. They're cheap.
\nunless (-d $foo) {\n  mkdir($foo) or die "Cannot mkdir '$foo': $!";\n}\n


Cheers,
Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
New Ah, good. Thanks.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
     Checking for the existence of a directory in Perl - (pwhysall) - (53)
         I use: - (admin) - (52)
             Context - (pwhysall) - (51)
                 Re: Context - (admin) - (5)
                     Moochos grassy arse. -NT - (pwhysall)
                     And I would point out that... - (ben_tilly) - (3)
                         How to do that... - (admin) - (2)
                             That works but... - (ben_tilly) - (1)
                                 Ah, good. Thanks. -NT - (admin)
                 Minor points - (ben_tilly) - (44)
                     Re: Minor points - (pwhysall)
                     Slightly OT: on brace style: - (admin) - (42)
                         That's what I've been doing, but I'm a noob. - (Another Scott)
                         No way, this is the shizzit - (jake123)
                         Yes, that is the correct form - (tuberculosis)
                         I've heard arguments for and against that - (ben_tilly) - (38)
                             The arguments are simple - (tuberculosis) - (13)
                                 Ah, an open mind. - (Yendor) - (1)
                                     Yeah, but he's right. - (pwhysall)
                                 Yes, we know you're strongly imprinted - (ben_tilly) - (10)
                                     I'm interested in research too - (tuberculosis) - (4)
                                         so K&R is wrong? Heretic BURN HIM! -NT - (boxley) - (1)
                                             :-\ufffd :-\ufffd :-\ufffd :-\ufffd -NT - (jb4)
                                         There's a lot of stuff at scholar.google.com - (Another Scott)
                                         I think it depends on your visual habits. - (static)
                                     Sidenote - (Simon_Jester) - (4)
                                         Automate that Jalopy - (Yendor) - (2)
                                             That's okay... - (Simon_Jester) - (1)
                                                 np - (Yendor)
                                         Yes, that's a PBP recommend :-) - (ben_tilly)
                             I'm seeing comments that "Code Complete" addresses that - (Another Scott) - (15)
                                 Where? - (ben_tilly) - (14)
                                     CC2, pp 740-743 -NT - (Yendor) - (3)
                                         I should finish reading it then - (ben_tilly) - (2)
                                             Ar - (Yendor) - (1)
                                                 I read the first one that way, the first time - (ben_tilly)
                                     E.g. - (Another Scott) - (9)
                                         What I see on that page: - (admin) - (8)
                                             I see. - (Another Scott) - (7)
                                                 Dunno what to tell you... - (admin) - (2)
                                                     www.mr-anderson.net could not be found... - (Another Scott) - (1)
                                                         Can you dig it? - (pwhysall)
                                                 They work here. Check your browser/adblock. -NT - (pwhysall)
                                                 For some reason reading text isn't so bad. - (admin) - (2)
                                                     Would you be better off wearing a patch? -NT - (broomberg) - (1)
                                                         Tried that for a bit. - (admin)
                             It's not just "bad vision" - (admin) - (5)
                                 I'm *so* playing you at pool, for money. -NT - (pwhysall) - (4)
                                     Bastard. - (admin) - (1)
                                         :-D -NT - (Another Scott)
                                     ICLRPD: I'm *so* playing you at pool, for money. (new thread) - (Steve Lowe)
                                     You're English. Isn't that advantage enough? -NT - (ben_tilly)
                             It's a pretty print problem... - (ChrisR) - (1)
                                 Code Complete reserves special criticism for that one -NT - (ben_tilly)

Choose life. Choose LRPDism-spotting.
74 ms