From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078609810482.tru64-unix-managers.marc@archive.invalid> From: Jean Schuller Date: Wed, 19 Mar 1997 09:45:33 +0000 To: tru64-unix-managers Subject: SUMMARY : PERL Problem X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078609810482 Hi all, Many thanks for all the good and efficient hints .. You're great. Special thanks to : (WHAT A LIST !!!!!!!!) Geert Jan Bex=20 Paul A Sand Dan Peters=20 Dan Rosenthal Roy Rapoport Juan Gallego Lance A. Brown=20 Jean-Loup Risler John K. Peterson =20 James Michaud Anthony Talltree=20 Hans Kowallik Eric Pettersen Lam Tak Ming Ben Goodwin Stavros A. Papadak Ollivier Robert =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D 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"; >@list =3D `ls SORTIX* `; >print "SORTIX List created\n"; >$rank=3D0; >foreach $li (@list) >{ > print "I read ",$li," I write ",$outfile,"\n"; > $rank++; > $outfile=3D"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 @list =3D ; ------------------------------------------------------- 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: @list =3D `ls SORTIX* `; I would try @list=3D; and why not rename($li,$outfile); rather than system(....) ------------------------------------------------------- $outfile=3D"SORTIX.$rank"; Also, use rename() instead of spawning an mv invocation. ------------------------------------------------------- JEAN -------------------------------------------------------------------------= ---- Jean Schuller _/ _/_/_/ _/_/_/ _/_/_/_/ schuller@crnal4.in2p3.fr _/ _/ -/ _/ _/ _/ =20 _/ _/_/_/-/ _/_/_/ _/_/_/_/ _/ _/ -/ _/ _/ _/ _/ _/ _/_/_/ _/_/_/_/ =20 local call: 0388106630 Institut de Recherches Subatomiques foreign call: (33)388106630 Bo=EEte Postale 28=20 local fax : 0388106234 23, Rue du Loess foreign fax : (33)388106234 F-67037 STRASBOURG CEDEX - France -------------------------------------------------------------------------= ----