bustergonad has asked for the wisdom of the Perl Monks concerning the following question:
> ftptest.pl Enter the COEO :=> h9z238 splitter fail : No such file or directory at ./ftptest.pl line 91, <EX +TRACT1> chunk 39.
Thanks BusterGonad#!/usr/bin/perl -w use strict; use File::Path; use Getopt::Std; use lib "$ENV{HOME}/perllib"; use Net::FTP; my $username = "ftpuser"; my $password = "ftppass"; my $remdir = "/webdata/extracts/SWEST/"; my @remfiles; my $remfile; my $localdir = "$ENV{HOME}/hw_extracts/"; my $coeo; my $COEO; my $coeodir; # the directory where everything happens # main # print "Enter the COEO :=> "; chomp ($coeo = <STDIN>); $COEO = uc($coeo); $coeodir = $localdir . $COEO; if (chdir($coeodir)) { chdir($localdir); rmtree($COEO) ; mkdir($COEO, 0777); chdir($coeodir);} else { chdir($localdir); mkdir($COEO, 0777); chdir($coeodir)} $remdir .= $COEO; # # try some ftping here my $ftp = Net::FTP->new("XX.XX.XX.XX") or die "Cant connect: $@\n"; # +XX is just and example $ftp->login($username, $password); $ftp->cwd($remdir); @remfiles = $ftp->ls($remdir); foreach $remfile (@remfiles) { $ftp->get($remfile); } # it works so far up to here , changes dirs etc,... # &Renamefile($coeodir); &Splitter($coeodir); ##################################################### sub Renamefile { my $extract; my $newname; my @flist; my $tempdir = shift; opendir (COEODIR, $tempdir) or die "Can't opendir $tempdir: $!"; @flist = grep { $_ ne '.' and $_ ne '..' } readdir COEODIR ; foreach $extract (@flist) { if ( $extract =~ /^.*_memo/) { $newname = $coeo."_memo"; } elsif ( $extract =~ /^.*_seq/) { $newname = $coeo."_seqchart" +; } else { open ( EXTRACT,"< $extract") || die "renamefile fail: $! +"; my @lines = <EXTRACT> ; # slurp the file into array AND my $lines = $lines[0]; # get the newfilename from the f +irst line $lines =~ /TAB (.*?)$/; $newname = $coeo . "_" . lc($1); } # close EXTRACT; rename($extract, $newname) or warn "Cant rename $extract to $newname +, $!\n"; }#foreach }#sub ##################################################### sub Splitter { my $i=0; my @arraychunk; my $extract1; my @flist; my @temparray; my $tempdir = shift; opendir (COEODIR1, $tempdir) or die "Can't opendir $tempdir: $!"; @flist = grep { $_ ne '.' and $_ ne '..' } readdir COEODIR1 ; foreach $extract1 (@flist) { open ( EXTRACT1,"< $extract1") || die "splitter fail : $!"; ## t +his is where the error comes from @temparray = <EXTRACT1> ; if ( @temparray > 600 ) { print "$extract1\n"; while (@arraychunk = splice @temparray, 0, 600 ) { open (NEWFILE, "> $extract1"."_"."$i"); $i++; print NEWFILE @arraychunk;} #while } #if # close (EXTRACT1) ; # close (NEWFILE) ; } #foreach } #sub
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: 2 Working Subroutines Conflict
by Vavoom (Scribe) on Oct 21, 2001 at 03:09 UTC | |
by Fletch (Bishop) on Oct 21, 2001 at 04:54 UTC | |
by bustergonad (Acolyte) on Oct 21, 2001 at 08:05 UTC | |
|
Re (tilly) 1: 2 Working Subroutines Conflict
by tilly (Archbishop) on Oct 21, 2001 at 03:47 UTC | |
|
Re: 2 Working Subroutines Conflict
by slayven (Pilgrim) on Oct 21, 2001 at 01:58 UTC | |
|
Re: 2 Working Subroutines Conflict
by data64 (Chaplain) on Oct 21, 2001 at 01:02 UTC | |
by bustergonad (Acolyte) on Oct 21, 2001 at 01:45 UTC |