Re: File open head scratcher

[email protected] (Dan Scott) Sat, 17 Mar 2012 17:18:46 -0400
Newsgroups perl.perl4lib
Message-ID <CAAY5AM2zaRuhXdXPdB3ZSd071uJEsMXmCQfcRAX-NQ8sfR1eMQ@mail.gmail.com>
On Sat, Mar 17, 2012 at 3:09 PM, Doran, Michael D <[email protected]> wrote:
> I am migrating  a perl script from a server running perl v5.8.5 on Solaris 9 to a server running perl v5.12.2 on Redhat Linux 5.5.  The new environment doesn't seem to like the syntax I'm using to open a file, and I'm scratching my head over why that is the case.
>
> That part that is not working appears to be where it opens and reads a file (a file which it will later append to).  The file that is being opened for read and appending exists and contains data.
>
> This appears to be the relevant code:
>
>  open (my $DATEFILE, "+>>$date_file")
>        || die "Cannot open $date_file: $!";

The head-scratching behaviour you describe, where only the system call
outputs results, matches mine with perl 5.14.2. Maybe there's a
difference in the versions of perl on your two systems?

For what it's worth, "Mixing reads and writes" in perlopentut says
that you probably want:

open (my $DATEFILE, "+<", $date_file) ...

(and making that change to my copy of your script makes it work for me).

-- 
Dan Scott
Laurentian University