Home > Archive > PERL Beginners > January 2006 > file :: find problem
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 |
file :: find problem
|
|
| Manoj Thakkar 2006-01-10, 4:01 am |
| Hi,
I have writtena simple file find perl script but i am getting the following problem
"Can't cd to (C:/) System Volume Information: Permission denied"
here is my code
use warnings;
use File::find;
sub wanted
(
if (/albd_server/)
print "$File:Find:name;
)
find(\&wanted, "c:\\"
i have checked the file permission the permission on the C: drive everything looks ok
Please suggest
Thanks in advance
Manoj
________________________________
| |
| Charles K. Clarkson 2006-01-10, 4:01 am |
| Manoj Thakkar, Noida <mailto:manoj.thakkar@hcl.in> wrote:
: "Can't cd to (C:/) System Volume Information: Permission denied"
:
: here is my code
Add:
use strict;
: use warnings;
: use File::find;
:
: sub wanted
: (
: if (/albd_server/)
You have a syntax error here. An 'if' statement requires a code block.
if ( /albd_server/ ) {
# do something;
}
: print "$File:Find:name;
You have a syntax error here. There is no need for the double quote.
print $File:Find:name;
: )
:
: find(\&wanted, "c:\\"
The file separator in perl is '/', not '\\', functions parenthesis
must match, and you should use single quotes by default.
find( \&wanted, 'c:/' );
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
| |
| Charles K. Clarkson 2006-01-10, 4:01 am |
| Timothy Johnson <tjohnson@zone.checkpoint.com> almost bottom posted:
: (quote from below): "The file separator in perl is '/', not '\\'"
:
: That's not necessarily true.
Using '\\' as the file separator makes your script more
platform dependent than using '/'. AFAIK, '\\' will not work in a
unix or Mac environment where '/' will.
To an advanced perl programmer you are correct, but to a
beginner who cannot even post a proper message to a technical
email list, it is poor advice. The only separator he needs to know
about right now is '/'. Any other separator will force him to
write OS specific software. That is generally a Bad Thing.
: It depends on the module and the context. Many modules will
: take the path in either format. In this case Perl was
: interpreting their code correctly, because otherwise it would
: not have given the error indicated by the OP.
The code the OP gave did not compile. It was not the same
code he was using to get the error he described. IMO, learning to
copy & paste his scripts to technical email lists is the real
important lesson the OP needs to learn. Much more important than
the question he asked.
When he can post coherent, well thought out questions the
beginner will have more skills at hand to solve future programming
problems. I chose to deliberately ignore his intentioned question
and point out his syntactical errors in an effort to enforce why
proof-reading posts before hitting send is so important.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
| |
| Timothy Johnson 2006-01-10, 4:01 am |
|
First of all, you're assuming a context that may or may not be there.
You're assuming that the OP is creating a script that can be used on
multiple operating systems, regardless of the file separator. In any
case, it's good advice to use the '/' separator wherever possible, but
to tell someone that the file separator in Perl is '/', not "\\" is
wrong, and in fact there are many Win32 modules out there that require
the use of the backslash as a file separator.
As to the issue of posting code that is not the same code that generated
the error (and in fact does not compile), of course that was an
egregious error on the OP's part, but if you're going to volunteer your
time to help beginners, why not actually say something helpful? If you
had just said what you meant, you wouldn't have ended up giving the
beginner wrong information.
-----Original Message-----
From: Charles K. Clarkson [mailto:cclarkson@htcomp.net]=20
Sent: Tuesday, December 27, 2005 6:03 AM
To: beginners@perl.org
Subject: RE: file :: find problem
Timothy Johnson <tjohnson@zone.checkpoint.com> almost bottom posted:
: (quote from below): "The file separator in perl is '/', not '\'"
:=20
: That's not necessarily true.
Using '\' as the file separator makes your script more
platform dependent than using '/'. AFAIK, '\' will not work in a
unix or Mac environment where '/' will.
To an advanced perl programmer you are correct, but to a
beginner who cannot even post a proper message to a technical
email list, it is poor advice. The only separator he needs to know
about right now is '/'. Any other separator will force him to
write OS specific software. That is generally a Bad Thing.
: It depends on the module and the context. Many modules will
: take the path in either format. In this case Perl was
: interpreting their code correctly, because otherwise it would
: not have given the error indicated by the OP.
The code the OP gave did not compile. It was not the same
code he was using to get the error he described. IMO, learning to
copy & paste his scripts to technical email lists is the real
important lesson the OP needs to learn. Much more important than
the question he asked.
When he can post coherent, well thought out questions the
beginner will have more skills at hand to solve future programming
problems. I chose to deliberately ignore his intentioned question
and point out his syntactical errors in an effort to enforce why
proof-reading posts before hitting send is so important.
HTH,
Charles K. Clarkson
--=20
Mobile Homes Specialist
254 968-8328
--=20
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
| |
| Manoj Thakkar 2006-01-10, 4:01 am |
| Thanks a lot guys,
I got my problem solved after long search on Google.
Th error message about the "Can't cd to (C:/) System Volume Information: Permission denied" was because there is a volume partition in case of NTFS not allowed to access by anyone.
The rest ofthe program run fine i can find the string i was looking for.
Regards
Manoj
________________________________
From: Timothy Johnson [mailto:tjohnson@zone.checkpoint.com]
Sent: Wed 12/28/2005 1:05 AM
To: Charles K. Clarkson; beginners@perl.org
Subject: RE: file :: find problem
First of all, you're assuming a context that may or may not be there.
You're assuming that the OP is creating a script that can be used on
multiple operating systems, regardless of the file separator. In any
case, it's good advice to use the '/' separator wherever possible, but
to tell someone that the file separator in Perl is '/', not "\\" is
wrong, and in fact there are many Win32 modules out there that require
the use of the backslash as a file separator.
As to the issue of posting code that is not the same code that generated
the error (and in fact does not compile), of course that was an
egregious error on the OP's part, but if you're going to volunteer your
time to help beginners, why not actually say something helpful? If you
had just said what you meant, you wouldn't have ended up giving the
beginner wrong information.
-----Original Message-----
From: Charles K. Clarkson [mailto:cclarkson@htcomp.net]
Sent: Tuesday, December 27, 2005 6:03 AM
To: beginners@perl.org
Subject: RE: file :: find problem
Timothy Johnson <tjohnson@zone.checkpoint.com> almost bottom posted:
: (quote from below): "The file separator in perl is '/', not '\'"
:
: That's not necessarily true.
Using '\' as the file separator makes your script more
platform dependent than using '/'. AFAIK, '\' will not work in a
unix or Mac environment where '/' will.
To an advanced perl programmer you are correct, but to a
beginner who cannot even post a proper message to a technical
email list, it is poor advice. The only separator he needs to know
about right now is '/'. Any other separator will force him to
write OS specific software. That is generally a Bad Thing.
: It depends on the module and the context. Many modules will
: take the path in either format. In this case Perl was
: interpreting their code correctly, because otherwise it would
: not have given the error indicated by the OP.
The code the OP gave did not compile. It was not the same
code he was using to get the error he described. IMO, learning to
copy & paste his scripts to technical email lists is the real
important lesson the OP needs to learn. Much more important than
the question he asked.
When he can post coherent, well thought out questions the
beginner will have more skills at hand to solve future programming
problems. I chose to deliberately ignore his intentioned question
and point out his syntactical errors in an effort to enforce why
proof-reading posts before hitting send is so important.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>
|
|
|
|
|