On approximately 8/5/2003 1:56 PM, came the following characters from
the keyboard of Chien-Lung Wu:
Hi,
In the bash, I can test a file or a directory by following:
if [ ! (-f a_filename)]; then
do_something_for_this_file
fi
if [ ! (-d a_dirname)]; then
do_something_for_this_dir
fi
How can I do the same functions in perl?
Approximately the same way. Look for the named unary operators in
perlop, and -X in perlfunc (the first in the Alphabetical listing of
perl functions).
Another question:
In the unix/linux system, we have the path, for instance,
/usr/local/bin/perl
However, in the Window/NT system, I have installed
perl in g:\perl\bin\perl.exe
How can I reference the path for perl.exe?
Is it g:\perl\bin\perl.exe or something else?
Windows does things differently than unix. Since #! is a comment to
perl, but a directive to Unix, you can leave your favorite path to Unix
perl in your cross-platform scripts. But in order to associate a
script with its engine on Windows, a file must have a suffix. The usual
suffix for perl scripts is .pl. Installing ActiveState will set up
the association by default. If you use a different distribution or
compile your own, the following commands will do it for you
ftype Perl=C:\Perl\bin\perl.exe %1 %*
assoc .pl=Perl
If you installed perl.exe somewhere else, that is what to use in the
ftype command... the path shown is the default path for ActiveState.
So your cross platform script could be name foo.pl and start with
#!/usr/local/bin/perl -w
or, you can invent your own technique.
--
Glenn -- http://nevcal.com/
===
Like almost everyone, I receive a lot of spam every day, much of it
offering to help me get out of debt or get rich quick. It's ridiculous.
-- Bill Gates
___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs