There are a couple of ways to do this. The cleanest doesn't use shell code at all:
my $topdir = '.';
my @subdirectory_names = ( 'bob', 'bill', 'sue' );
foreach my $dir( @subdirectory_names ){
mkdir( "$topdir/$dir" ) or die "Couldn't mkdir $topdir/$dir: $!";
foreach my $redirect( 'redirect_1.html', 'redirect_2.html' ){
open( OUT, ">$topdir/$dir/$redirect" );
print OUT $redirect_html_code; # this should be set above
close OUT;
}
}
If you must use shell for some reason, though, there are three functions that execute shell code: exec, system,
and backticks (``, or qx//). Each of those links lead to an explanation of each function.
Hope that helps!
--
Love justice; desire mercy.
| [reply] [d/l] [select] |
You can probably manage with perl, using mkdir, and open to create files and directories.
In order to use shell scripts, however, you may use the back ticks (`command`), and perhaps system and exec (i'm not one hundred per cent on that - i'm not a unix guy).
the backticks will return the output, but if you want a real pipe, you should use open (READ,"command |"); # this opens a pipe from 'command'
open (WRITE,"| command"); # this opens a pipe to 'command'
-nuffin zz zZ Z Z #!perl | [reply] [d/l] [select] |
I'm not quite clear exactly what you are trying to do, but if it is all possible, you should (in general) avoid calling shell scripts (and other non-portable commands) in your perl scripts. Instead, where possible, use modules that provide equivalent behavior.
That being said, you can easily run shell commands using the back-ticks operator `echo "blah"`, or the regex like quote operators qx{echo "blah"}. Output to STDOUT from the shell command is returned.
If that doesn't answer your question, perhaps you could clarify a bit, or post some example code? | [reply] [d/l] [select] |