Any help would be MUCH appreciated - thank you!

I'm forced to work with someone else within the company who is running this in the Unix environment. This disconnect makes resolving issues frustrating.

Due to company restrictions, I do not have access to a Unix environment to test my code, and can only relay error messages from my coworker. This is frustrating for both of us!

My perl version is perl 5, version 20, subversion 1 (v5.20.1) built for MSWin32-x64-multi-thread. I have reached out to my coworker to ask what version of perl he is using.

Here is the full code:

#!/usr/bin/perl -w use strict; use warnings; use Encode; use Cwd; use File::Copy; #my ($path) = @ARGV; #use this to pass path as argument #my ($path) = 'C:/TMP/wow/'; #use this to force path my ($path) = cwd(); #use this to set path = current directory #print $path . "\n"; #makes archive and output directories if they don't exist my $dirout = $path . "/output"; my $dirarc = $path . "/archive"; mkdir $dirout; mkdir $dirarc; $path // die "No path specified"; (-e $path) or die "Path not found: $path"; (-d $path) or die "Not a directory: $path"; my @files = <$path/*.x937>; foreach my $file (@files) { process($file); } sub process { my ($fname) = @_; my ($dir, $file) = $fname =~ m{^(.*)/(.+)$}; my $tiff_flag = 0; my $count = 0; my $outfile = sprintf("%s/output/%s_0.txt", $dir, $file); $outfile =~ s/.x937//; while (-e $outfile) { $outfile =~ s/([0-9]+).txt/$1 + 1/e; $outfile = $outfile . ".txt"; } my $mfname = sprintf("%s/archive/%s_0.x937", $dir, $file); $mfname =~ s/.x937_/_/; while (-e $mfname) { $mfname =~ s/([0-9]+).x937/$1 + 1/e; $mfname = $mfname . ".x937"; } open (my $outfh, '>', $outfile) or die "Unable to create $outfile. + $!"; open (my $infh, '<:raw', $fname) or die "Error opening '$file'. $! +"; my $buffer = undef; while (read ($infh,$buffer,4)) { my $rec_len = unpack("N", $buffer); die "Bad record length: $rec_len" unless ($rec_len > 0); read ($infh, $buffer, $rec_len); if (substr($buffer, 0, 2) eq "\xF5\xF2") { if ($tiff_flag) { $count++; my $tiff_filename = sprintf('%s/output_%s_img%04d.tiff +', $dir, $file, $count); open (my $tiffh, '>', $tiff_filename) or die "Can't cr +eate image file $!"; binmode($tiffh) or die 'Error setting binary mode on i +mage file'; print $tiffh substr($buffer, 117); close $tiffh; } $buffer = substr($buffer, 0, 117); } print $outfh decode ('cp1047', $buffer) . "\n"; } close $infh; close $outfh; move($fname,$mfname) or die "Move failed: $!"; }

Here are the errors received:

Scalar found where operator expected at x937.pl line 32, near ")$}" (Missing operator before $}?) Global symbol "$file" requires explicit package name at x937.pl line 1 +9. Global symbol "$file" requires explicit package name at x937.pl line 1 +9. Global symbol "$fname" requires explicit package name at x937.pl line +19. Global symbol "$dir" requires explicit package name at x937.pl line 19 +. Global symbol "$file" requires explicit package name at x937.pl line 1 +9. Global symbol "$fname" requires explicit package name at x937.pl line +19. syntax error at x937.pl line 32, near "my ($dir, $file) = $fname =~ m{ +^(.*)/(" (Might be a runaway multi-line // string starting on line 19) Global symbol "$dir" requires explicit package name at x937.pl line 38 +. Global symbol "$file" requires explicit package name at x937.pl line 3 +8. Global symbol "$dir" requires explicit package name at x937.pl line 45 +. Global symbol "$file" requires explicit package name at x937.pl line 4 +5. Global symbol "$fname" requires explicit package name at x937.pl line +54. Global symbol "$file" requires explicit package name at x937.pl line 5 +4. Global symbol "$dir" requires explicit package name at x937.pl line 67 +. Global symbol "$file" requires explicit package name at x937.pl line 6 +7. Global symbol "$fname" requires explicit package name at x937.pl line +80. Unmatched right curly bracket at x937.pl line 81, at end of line x937.pl has too many errors.


In reply to code works in Windows (Strawberry Perl), fails in Unix - possible path/environment issue by ilmenolimone

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.