Suppose all the files were captured into @files, then for concatenating all 
of em into one file.txt do--

First find where is cat command lying in the Unix box. If it is in /usr/bin 
then--
system ("/usr/bin/cat @files >$new_file.txt") ## On Unix
    and on Win32
system ("type @files >$new_file.txt")  ## On Win32.

BTW, ZMumba, did you used "unlink <*H>" to remove all the files or the 
alternative ?

Cheers.


--- On Thu, 11/13/08, zilore mumba <[EMAIL PROTECTED]> wrote:

> From: zilore mumba <[EMAIL PROTECTED]>
> Subject: RE: How does one concatenate many files into one?
> To: [EMAIL PROTECTED]
> Date: Thursday, November 13, 2008, 8:38 PM
> Thanks to Sena and Mustafa.
> Unfortunately am very novice in Perl, please see the points
> where I seek clarification below. And by the way, my first
> question which seems to have disappeared is how do you
> concatenate? I have in my code
> cat *H > $model$cycle$UK_sufx$grib_ext;
> or should it be ./cat *H >
> ./$model$cycle$UK_sufx$grib_ext;
> 
> --- On Thu, 11/13/08, p sena <[EMAIL PROTECTED]>
> wrote:
> 
> From: p sena <[EMAIL PROTECTED]>
> Subject: RE: How does one concatenate many files into one?
> To: [EMAIL PROTECTED], [email protected],
> [EMAIL PROTECTED]
> Date: Thursday, November 13, 2008, 3:36 PM
> 
> Hi,
> opendir (DIR, $dir...);
> @files = grep { -f "$dir/$_" && /*.H$/ }
> readdir DIR;
> close DIR;
> unlink @files; ## make sure here full path names are
> there.I understood this to mean that my code for deleting
> should be:opendir (BASE, $$base_dir/$model/$dat);my @files =
> grep { -f "$base_dir/$model/$dat/$_" &&
> /*.H$/ } readdir DIR;
> close DIR;
> unlink @files $base_dir/$model/$dat/$_" &&
> /*.H$/ ; ## make sure here full path names are there.
> 
> Well, could someone clarify why unlink <*H> or unlink
> (glob (*H)) is not
> being discussed here ? This could have been more fast if
> size is more.
> Just chdir $dir and then unlink...Cheers.
> --- On Thu, 11/13/08, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]> wrote:
> > From: [EMAIL PROTECTED]
> <[EMAIL PROTECTED]>
> > Subject: RE: How does one concatenate many files into
> one?
> > To: [EMAIL PROTECTED],
> [email protected]
> > Date: Thursday, November 13, 2008, 5:05 PM
> > You use the system command for this as below,
> > 
> system("perl grib2ctl.pl";  F  this part here
> is what I put in my code
> system("perl /usr/local/bin/grib2ctl.pl") -verf
> $model$cycle$UK_sufx$grib_ext >
> $model$cycle$UK_sufx$ctl_ext;
> system("/usr/local/grads/bin/gribmap") -i 
> $model$cycle$UK_sufx$ctl_ext -v -e;
> 
>  
> >         first do the pattern matching like this,
> >         $file_delete =~ /H$/;
> >          and read the complete path like
> >         $file_delete = /home/zilore/$file_delete;
> >          system("rm $file_delete);
> >     Use for loop for the itteration to search all
> H files.
> > $file_delete =~ /H$/;
>       $file_delete =
> $base_dir/$model/$dat/$file_delete;
>       system("rm $file_delete);
> > 
> > --
> > Regards,
> > Mustafa
> > 
> > 
> > 
> > ________________________________
> > 
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]
> On
> > Behalf Of zilore
> > mumba
> > Sent: Thursday, November 13, 2008 12:54 PM
> > To: [email protected]
> > Subject: How does one concatenate many files into one?
> > 
> > 
> > Esteemed Perl users,
> > I have a perl script below which is meant to perform a
> > couple of tasks,
> > viz.,
> > combine several files into one (marked blue in the
> code
> > below). I have
> > looked, without success, for the command which does
> this.
> > 1. Help how do I do this (all files end in H)?
> > 2. I have to run another perl script (grib2ctl.pl), is
> this
> > how to do it
> > (marked blue in the code below).
> > 3. I have to delete the files ending in H. Is unlink
> > <*H>; the way?
> > 
> > Assistance will be appreciated.
> > Zilore
> > 
> > #
> > #!/usr/bin/perl -w
> > #This script processes UKMO model data from
> RETIM-SYNERGIE
> > and archives
> > it on
> > #the ACMAD system. The cycles (or times) are 00 and
> 12.
> > #
> > use strict;
> > use warnings;
> > use POSIX;
> > use File::Path;
> > use File::Copy;
> > #
> > my $ctl_ext=".ctl";
> > my $grib_ext=".grib";
> > #
> > my $UK_sufx="2";
> > my $dash="-";
> > my $model="ukmo";
> > my @now = localtime;
> > #
> > my $dat = strftime "%Y%m%d", @now;
> > my $dat1 = $dat + 1;
> > my $hr = strftime "%H", @now;
> > my $cycle = '00'; $cycle = '12' if $hr
> >
> > 15;
> > #
> > my $model_mon=`date "+%m"`;
> > my $mon_name=`date "+%B"`;
> > my $yr=`date "+%y"`;
> > #
> > my
> >
> $base_dir="/home/Mumba/archive/$model_mon$dash$mon_name$yr";
> > #
> >       chdir $base_dir/$model/$dat;
> >       my @files =ls;
> >         foreach my $file (@files) {
> >             *H "." $file >
> > $model$cycle$grib_ext;
> > #cat *H > $model$cycle$grib_ext;
> >       /usr/local/bin/grib2ctl.pl -verf
> > $model$cycle$grib_ext >
> > $model$cycle$ctl_ext;
> >       /usr/local/grads/bin/gribmap -i
> $model$cycle$ctl_ext
> > -v -e;
> >       unlink <*H>;
> >   #
> >      
> >
> rename("$base_dir/$model/$dat1/*H","$base_dir/$model/$dat");
> >       my @files =ls;
> >         foreach my $file (@files) {
> >             *H "." $file >
> > $model$cycle$grib_ext;
> > #cat *H > $model$cycle$UK_sufx$grib_ext;
> >       /usr/local/bin/grib2ctl.pl -verf
> > $model$cycle$UK_sufx$grib_ext >
> > $model$cycle$UK_sufx$ctl_ext;
> >       /usr/local/grads/bin/gribmap -i 
> > $model$cycle$UK_sufx$ctl_ext -v
> > -e;
> >       unlink <*H>;
> >    #
> > #
> > date;
> > exit 0;
> > 
> > 
> > 
> > 
> > Please do not print this email unless it is absolutely
> > necessary. 
> > 
> > The information contained in this electronic message
> and
> > any attachments to this message are intended for the
> > exclusive use of the addressee(s) and may contain
> > proprietary, confidential or privileged information.
> If you
> > are not the intended recipient, you should not
> disseminate,
> > distribute or copy this e-mail. Please notify the
> sender
> > immediately and destroy all copies of this message and
> any
> > attachments. 
> > 
> > WARNING: Computer viruses can be transmitted via
> email. The
> > recipient should check this email and any attachments
> for
> > the presence of viruses. The company accepts no
> liability
> > for any damage caused by any virus transmitted by this
> > email. 
> > 
> > www.wipro.com
> > _______________________________________________
> > ActivePerl mailing list
> > [email protected]
> > To unsubscribe:
> > http://listserv.ActiveState.com/mailman/mysubs
> 
> 
>       
> 
> _______________________________________________
> ActivePerl mailing list
> [email protected]
> To unsubscribe:
> http://listserv.ActiveState.com/mailman/mysubs


      

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to