On Aug 14, 1:30 pm, [EMAIL PROTECTED] (Rob Dixon) wrote:
> jis wrote:
> > On Aug 13, 7:46 pm, [EMAIL PROTECTED] (John W. Krahn) wrote:
> >> jis wrote:
>
> >>> 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.)
>
> >> Try this:
>
> >> use FindBin '$Bin';
>
> >> my $fil = "$Bin/pdef.txt";
> >> open DEFILE, '<', $fil or die "Couldnt open $fil - $!\n";
>
> > It did not make any difference.
> > it says there is no such file in the $Bin path..
> > Ofcourse there is no such file in that path. i want to look in the
> > path iam executing the code.
>
> > Any one can hep me!
>
> Have you tried what John suggested? It wouldn't say 'there is no such file in
> the $Bin path', as the value of $Bin would be interpolated into the file 
> string.
>
> You have said that your file is in the same path as your script. What FindBin
> does is to let you find out what that path is. The problem is most likely that
> your program's current working directory is not the directory containing the
> program file. You could try this as an alternative
>
>   use FindBin;
>   chdir $FindBin::Bin or die $!;
>
> Rob- Hide quoted text -
>
> - Show quoted text -

I tried what John suggested.
the exact error code is "Couldnt open C:/Program Files/Perl Express/
Debug/pdef.txt - No such file or directory"
(yes, iam using perl express)
i do not want to ask user (who finally uses my executable) to put the
file always on a fixed location..
i want the user to keep the file to read in the same path as
executable is.

Any hopes!!

regards,
jis


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


Reply via email to