SUMMARY : PERL Problem

From: Jean Schuller <schuller_at_crnal4.in2p3.fr>
Date: Wed, 19 Mar 1997 10:45:33 +0100 (MET)

Hi all,

Many thanks for all the good and efficient hints .. You're great.


Special thanks to : (WHAT A LIST !!!!!!!!)
Geert Jan Bex
Paul A Sand
Dan Peters
Dan Rosenthal
Roy Rapoport
Juan Gallego
Lance A. Brown
Jean-Loup Risler
John K. Peterson
James Michaud
Anthony Talltree
Hans Kowallik
Eric Pettersen
Lam Tak Ming
Ben Goodwin
Stavros A. Papadak
Ollivier Robert

====================================================

My problem :
>When I execute my script :
>#!/usr/local/bin/perl
>print "Start of splitting main file\n";
>system("split -100 FINAL.LISTE_SORTED SORTIX.");
>print "Main file splitted\n";
>_at_list = `ls SORTIX* `;
>print "SORTIX List created\n";
>$rank=0;
>foreach $li (_at_list)
>{
> print "I read ",$li," I write ",$outfile,"\n";
> $rank++;
> $outfile="SORTIX".$rank;
> system("mv $li $outfile");
>}
>.
>.
>.
>I have each time an error message :
>Start of splitting main file
>Main file splitted
>List with SORTIXn created
>I read SORTIX.aa
> I write SORTIX1
>usage: mv [-i | f] [--] src target
>.
>.
>.


The solution(s) :

-------------------------------------------------------
use Perl's 'rename' instead?
-------------------------------------------------------
use _at_list = <SORTIX*>;
-------------------------------------------------------
use system(`mv $li $outfile`);
-------------------------------------------------------

        Your big problem here is that you have not removed line returns
from your array elements. The way to fix your script is to add
chomp $li;
-------------------------------------------------------
   chop $li;
-------------------------------------------------------
ather than doing:
_at_list = `ls SORTIX* `;
I would try
_at_list=<SORTIX*>;

and why not
rename($li,$outfile);
rather than
system(....)
-------------------------------------------------------
$outfile="SORTIX.$rank";
Also, use rename() instead of spawning an mv invocation.
-------------------------------------------------------


JEAN




-----------------------------------------------------------------------------
Jean Schuller _/ _/_/_/ _/_/_/ _/_/_/_/
schuller_at_crnal4.in2p3.fr _/ _/ -/ _/ _/ _/
                               _/ _/_/_/-/ _/_/_/ _/_/_/_/
                              _/ _/ -/ _/ _/
                             _/ _/ _/ _/_/_/ _/_/_/_/
local call: 0388106630 Institut de Recherches Subatomiques
foreign call: (33)388106630 Boîte Postale 28
local fax : 0388106234 23, Rue du Loess
foreign fax : (33)388106234 F-67037 STRASBOURG CEDEX - France
-----------------------------------------------------------------------------
Received on Wed Mar 19 1997 - 11:11:33 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:36 NZDT