> -----Original Message-----
> From: Xavier Mas [mailto:[EMAIL PROTECTED]
> Sent: 14 August 2008 12:00
> To: beginners@perl.org
> Subject: Re: Not able to open a file.
> 
> El Thursday 14 August 2008 12:42:15 jis va escriure:
> > On Aug 13, 7:46 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> > > jis wrote:
> > > > Hi
> > >
> > > Hello,
> > >
> > > > I simply could not open a file which is in the same path as my
> script
> > > > is.
> > > > i could open the file if i explicitly mention the path. but i dont
> > > > want that..
> > > >
> > > > my script is..
> > > >
> > > >  use strict;
> > > > use warnings;
> > > >  my  $fil="pdef.txt";
> > > > open(DEFILE,"<$fil")|| die "Couldnt open pdef file - $!\n";
> > > >
> > > > Any idea what is wrong..( the file exists in the same path as the
> > > > script is.)
> > >
[Stewart Anderson] 
This  works.


#!/usr/bin/perl

use strict;
use warnings ;

my $filetoopen="test.out"; 

open FILEH, '<', $filetoopen or die "Can't open file:\t $filetoopen " .  $! . 
"\n"; 

while (<FILEH>) { print $_  } ;



#test.out 
One
Two
Three





Information in this email including any attachments may be privileged, 
confidential and is intended exclusively for the addressee. The views expressed 
may not be official policy, but the personal views of the originator. If you 
have received it in error, please notify the sender by return e-mail and delete 
it from your system. You should not reproduce, distribute, store, retransmit, 
use or disclose its contents to anyone. Please note we reserve the right to 
monitor all e-mail communication through our internal and external networks. 
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and 
are used under licence. British Sky Broadcasting Limited (Registration No. 
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home 
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited 
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky 
Broadcasting Group plc (Registration No. 2247735). All of the companies 
mentioned in this paragraph are incorporated in England and Wales and share the 
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

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


Reply via email to