----- Original Message -----
From: ""Chris Charley"" <char...@pulsenet.com>
Newsgroups: perl.beginners
To: <beginners@perl.org>
Sent: Wednesday, November 18, 2009 12:39 PM
Subject: Re: mkdir in the mounted partition,please help me,thanks
----- Original Message -----
From: ""gaochong"" <zjgaoch...@gmail.com>
Newsgroups: perl.beginners
To: <beginners@perl.org>
Sent: Tuesday, November 17, 2009 6:41 AM
Subject: mkdir in the mounted partition,please help me,thanks
[snip some content]
As to a better way, here is another way (without reconstructing the @list
array).
#!/usr/bin/perl
use strict;
use warnings;
use File::Path; # uses 'mkpath' to make new included dirs in a path
my ($i, @p) = (-1, 3 .. 9);
foreach my $f ("FA00000001".."FA00002000") {
my $p = $p[++$i % @p];
There is really no need for the @p array. You could calculate $p like:
my $p = ++$i % 7 + 3;
#mkpath(["/data$p/NRU/$f"], 0, 0755) unless -e "/data$p/NRU/$f";
#symlink "/data$p/NRU/$f","/usr/local/Titan/NRU/$f"
# or warn"symlink /data$p/NRU/$f err:$!";
print "/data$p/NRU/$f\n";
}
This example uses the 'mkpath()' function which *will* construct the
entire path (unlike the mkdir() function). mkpath() is included in the
base perl 5.8 distribution, so it may be available to you.
Chris
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/