develooper Front page | perl.perl4lib | Postings from March 2012

RE: File open head scratcher

Thread Previous
From:
Doran, Michael D
Date:
March 17, 2012 14:40
Subject:
RE: File open head scratcher
Message ID:
2EA599FC682D6F4684DC0DF501E209E7919C14A27E@MAVMAIL2.uta.edu
Hi Dan,

> For what it's worth, "Mixing reads and writes" in perlopentut says
> that you probably want:
> 
> open (my $DATEFILE, "+<", $date_file) ...

Hmmm.  I may give that a try, too!  Thanks!

-- Michael

> -----Original Message-----
> From: denials@gmail.com [mailto:denials@gmail.com] On Behalf Of Dan Scott
> Sent: Saturday, March 17, 2012 4:19 PM
> To: Doran, Michael D
> Cc: perl4lib
> Subject: Re: File open head scratcher
> 
> On Sat, Mar 17, 2012 at 3:09 PM, Doran, Michael D <doran@uta.edu> 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

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About