Garrett Esperum wrote:
>
> Hello all,
Hello,
> Below is what I have so far for my script, I can get every piece to work
> correctly on it's own, nut I cannot get these two pieces to work together. I
> think I am messing up the syntax of this script. What Am I doing wrong?? How
> do I loop in the Directory creation, and file copy procedures??
>
> #!/usr/local/bin/perl -w
>
> use strict;
> use File::Path;
> use File::Copy;
>
> my $file;
> my $type;
> my $location;
> my $owner;
> my $permissions;
> open (MDATA, "meta-data") or die "Cannot open $!\n";
> while (<MDATA>) {
> chomp;
> ($file, $type, $location, $owner, $permissions) = split /\t/;
Because these variables are only used inside the while loop you should declare them
here.
my ($file, $type, $location, $owner, $permissions) = split /\t/;
Also, if you are only using one of the variables ($location) there is no
need to declare the other variables.
my $location = (split /\t/)[2];
> forech $location
^^^^^^ ^^^^^^^^^
The first word should be "for" or "foreach".
The expression must be enclosed in parentheses.
foreach ( $location ) {
# OR
for ( $location ) {
But because $location is a single value (scalar) there is really no need to use a loop.
if ( $location ) {
> {
> unless( -d $location )
> {
> system mkdir $location or die "Couldn't make the target directory:
>$!\n";
^^^^^^^^^^^^
Is there any reason that you are not using the built-in mkdir() function?
perldoc -f mkdir
> }
> }
> }
> close MDATA
>
> Error:
> --------------------------------------------------------
> Global symbol "%location" requires explicit package name at ./creation.pl
> line 17.
> syntax error at ./creation.pl line 17, near "$location
> {"
> syntax error at ./creation.pl line 22, near "}"
> Execution of ./creation.pl aborted due to compilation errors.
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]