On Tue, Mar 08, 2005 at 12:02:09PM +0100, John Doe wrote:
> Am Dienstag, 8. März 2005 02.04 schrieb David Storrs:
> > > >Suneel Kumar B <mailto:[EMAIL PROTECTED]> wrote:
> > > >: Can i
> > > >: have an option by which i could open a file for both read and
> > > >: write simultaneously

> > The literal answer to your question would be this:
> >
> >    open FILE, '/path/to/the/file', '+<'
> >       or die "Couldn't open: $!";
> 
> open FILE, '+<', '/path/to/the/file'  or die "Couldn't open: $!";
> 
> (see order of arguments)
> 
> perldoc -f open

Sorry, yes.  I had originally used the 'IO::File' version there, for
which that is the correct order.  When I changed it to the bare open
call, I forgot to swap them.  This difference in the order is
something that has tripped me a lot.

> > or, preferably (as it will manage some safety issues for you):
> >
> >    use IO::File;
> >    my $file = new IO::File('/path/to/the/file', '+<')
> >       or die "Couldn't open: $!";


--Dks

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to