Bestrophin has asked for the wisdom of the Perl Monks concerning the following question:

Hi Everyone,

I have the below program which was written for MAC OS 1997. And now I would like to use this program to run this in windows vista in the active perl.

Could anyone helpe me to make the below program work for VISTA? Any help is highly appreciated. 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";

20100222 Janitored by Corion: Added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: How How to make mac written perl program to work in VISTA
by BrowserUk (Patriarch) on Feb 19, 2010 at 22:28 UTC

    Four things stand out:

    1. The path separator will need to change: @path=split(/:/,$ARGV[$m]
    2. Why does the definition of "text" exclude 'I'?
      # does it contain text? if ($i =~ /A-HJ-Za-z/)
    3. You'll probably need to set up a short cut using wperl.exe if you want to:
      print STDERR "Just drag your datafiles in turn onto the program icon,\ +n";
    4. You might want to wrap the main body in a loop over @ARGV, to cater for multi-file drag&drop.

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
Re: How How to make mac written perl program to work in VISTA
by almut (Canon) on Feb 19, 2010 at 21:13 UTC

    What happens when you try?  At first glance, I don't see anything OS specific in the program...

Re: How How to make mac written perl program to work in VISTA
by CountZero (Bishop) on Feb 19, 2010 at 21:42 UTC
    It would help if:
    1. Your code was enclosed in <code> ... </code> tags
    2. You tell us what your progam does / should do, rather than the Monks having to guess or reverse engineer from the code.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James