Today I needed to do mkdir in the middle of something unwieldy and I thought, uh oh, how do I error check against this.
perlfunc mkdir wasn't real helpful, and perlmonks didn't pop anything up right away either.
My shortcut was to use the google "site:" syntax to search stonehenge.com repository of merlyn articles
There, in the third result, was my answer. Since google gives such nice summaries, with the key words bolded for easier viewing, I saw it right away: -d $CORRUPT or mkdir $CORRUPT, 0755 or die "Cannot mkdir $CORRUPT: $!";
So, that's all.
If there's ever a bit of idiom that you *almost* know, but can't quite nail, and you're too shy to ask on the chatterbox, do a site query on stonhenge.com or (who else is good for this?) and sometimes the answer pops right out.
Cheers :)
***************
UPDATE: Actually, though, what I really wanted was
#!/usr/bin/perl use strict; use warnings; my $log_dir="/root/blee"; my $result = system("mkdir -p $log_dir"); print "result: $result\n"; -d $log_dir or system("mkdir -p $log_dir") && die "couldn't make $log_ +dir: $!"; print "error: should have died already\n";
Because system returns 0 on success, whereas perl mkdir returns 0 on failure.
So much for magic bullets ;)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to find code written by smart people
by diotalevi (Canon) on Aug 21, 2006 at 14:48 UTC | |
|
Re: How to find code written by smart people
by jplindstrom (Monsignor) on Aug 21, 2006 at 16:46 UTC | |
|
Re: How to find code written by smart people
by explorer (Chaplain) on Aug 21, 2006 at 15:09 UTC | |
|
Re: How to find code written by smart people
by BerntB (Deacon) on Aug 22, 2006 at 07:58 UTC | |
|
Re: How to find code written by smart people
by radiantmatrix (Parson) on Aug 25, 2006 at 14:22 UTC | |
by Hue-Bond (Priest) on Aug 25, 2006 at 17:16 UTC | |
by radiantmatrix (Parson) on Aug 25, 2006 at 19:46 UTC | |
|
Re: How to find code written by smart people
by shmem (Chancellor) on Aug 21, 2006 at 22:49 UTC |