On Wednesday, May 22, 2002, at 01:41 , José Nyimi wrote:
[..]
> Which will look like:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
> my $mydir=$ENV{MY_DIR};
>
> unless(&check_w($mydir)){
>  #Continue the job whithout stress ...
>  print "I do";
> }
>
[..]

is there a reason that you want to pass the name of
a directory through the 'environment' - rather that
at the command line???

This is a really 'bad idea' unless you are trying to
keep what the 'code does' a form of secret....

[jeeves:~] drieux% setenv MY_DIR /tmp/drieux ; thatCoolCode
I do have /tmp/drieux
[jeeves:~] drieux% setenv MY_DIR /tmp/joeBobBrigs ; thatCoolCode
I do not have directory :/tmp/joeBobBrigs:
[jeeves:~] drieux%

so you will also need to do something like:

        my $mydir=$ENV{MY_DIR};
        if( $mydir) {   # since you will need to check that it is set at all
                                        # so as not to throw the exception....
                if ( -w $mydir ){
                        #Continue the job whithout stress ...
                        print "I do have $mydir\n";
                } else {
                        print "I do not have directory :$mydir:\n";
                }
        } else {
                        print "\$mydir not set\n";
        }

you may really want to become good friends with Getopt::Std
since that will make passing arguements a bit simpler....


ciao
drieux

---


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to