For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > July 2006 > new to perl file esist









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author new to perl file esist
sivga

2006-07-28, 9:56 pm

hello all iamnew toperl and iknow this qustion is asked many times. but
stili coul dnot getit working this is wat i have


$home= "$parse/audit/$check/system/report.out";

chomp($home);

if (-e $home) {

print " file exist ";

}else {

print "file does not exist";
}

The file exist in the directory but it always prints it does not exist
..I tried in a test program but when i plug in to the main program it
does not work any help pls


thnks

kenslaterpa@hotmail.com

2006-07-28, 9:56 pm


sivga wrote:
> hello all iamnew toperl and iknow this qustion is asked many times. but
> stili coul dnot getit working this is wat i have
>
>
> $home= "$parse/audit/$check/system/report.out";
>
> chomp($home);
>
> if (-e $home) {
>
> print " file exist ";
>
> }else {
>
> print "file does not exist";
> }
>
> The file exist in the directory but it always prints it does not exist
> .I tried in a test program but when i plug in to the main program it
> does not work any help pls
>
>
> thnks


You need to provide a complete script that exhibits the problem.
Otherwise, I can only speculate on what is wrong.
If your test program works, but your main program doesn't, that is
probably a sign that the variable '$home' does not contain the value
you think it does.
Ken

usenet@DavidFilmer.com

2006-07-28, 9:57 pm

sivga wrote:

> $home= "$parse/audit/$check/system/report.out";


> The file exist in the directory but it always prints it does not exist


Change your print statement to be more informative, such as:

print "file '$home' does not exist";

Now Perl will tell you the name of the file it is looking for. Does it
match the name you think it is looking for? (especially the first part
of the path, which comes from $parse, which might not contain what you
think it contains).

--
David Filmer (http://DavidFilmer.com)

jeevs

2006-07-31, 3:57 am

yes i had da same prob two days ago...
just check the filename and path u r looking for is correct as Mr.
David said.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com