
venkatc
New User
Feb 19, 2010, 12:51 PM
Post #3 of 4
(8957 views)
|
Re: [FishMonger] How How to make mac written perl program to work in VISTA
[In reply to]
|
Can't Post
|
|
Thank you very much for your quick reply. Here is the code that is not working in VISTA and which was written for Mac. Thanks print STDERR "Split up datafile - JATD - 23/9/97\n"; print STDERR "This splits a long luminometer run into separate files, one for each tube.\n"; print STDERR "Data for each tube should be preceeded by \'no 03\' etc.\n"; print STDERR "Just drag your datafiles in turn onto the program icon,\n"; print STDERR "in the order in which they are to be processed.\n"; print STDERR "The program automatically appends data to existing files,\n"; print STDERR "or creates new ones as needed.\n"; print STDERR "Files are placed in the same folder as the input files.\n\n"; $numargs=@ARGV; $state=0; $n=0; print STDERR "ARGV contained $numargs arguments.\n"; for ($m=0; $m<$numargs; $m++) { open (INFILE, $ARGV[$m]) || die "Couldn't open infile\n"; print STDERR "Opened file: $ARGV[$m]\n"; # establish path of infile @path=split(/:/,$ARGV[$m]); $pathlength=@path; $num= $path[$pathlength-1]; $path[$pathlength-1]=""; $root=join(":",@path); while (!(eof(INFILE))) { # get next record $n++; $i=<INFILE>; # does it contain text? if ($i =~ /[A-HJ-Za-z]/) { @array=split(/ /,$i); $arraylength=@array; $num= $array[$arraylength-1]; $array[$arraylength-1]=""; # close any existing file close (OUTFILE); if ($recnum) {print STDERR " - $recnum lines written.\n"; } # work out full pathname of the desired file $filename=join(" ",@array); $filename=~ s/[ ]+/ /g; if ($filename =~ /(no [0-9]+)/) { $filename = $1; } $file=$root; $file.= $filename; if (-e $file) { print STDERR "Adding to existing outfile: $file"; } else { print STDERR "Opening new outfile: $file"; } open (OUTFILE, ">>$file") || die "Couldn't open outfile\n"; $recnum=1; $i=$num; } $i =~ s/[ ]+/ /g; $recnum++; print OUTFILE $i; } # now at the end of the input # close any existing file close (OUTFILE); if ($recnum) {print STDERR " - $recnum lines written.\n"; } print STDERR "\nInput file contained $n records.\n"; } print STDERR "All finished.\n";
|