Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

(tye)Re2: framechat

by tye (Sage)
on Mar 15, 2001 at 20:35 UTC ( #64702=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: Re: framechat
in thread framechat

Here is one way to do the above while giving a decent error message:

my $env; my $tmpdir= $ENV{$env="TMPDIR"} || $ENV{$env="TMP"} || $ENV{$env="TEMP"} || ($env="","/tmp"); if( ! -d $tmpdir ) { die "Invalid temporary directory ($tmpdir)", $env ? " (taken from \$ENV{$env})" : "(please set TMPDIR, TMP, or TEMP in your environment)", "\n"; }

        - tye (but my friends call me "Tye")

Replies are listed 'Best First'.
Re: (tye)Re2: framechat
by merlyn (Sage) on Mar 15, 2001 at 21:14 UTC
    Too much repeated code.
    my $tmpdir; for (qw(TMPDIR TMP TEMP)) { next unless $tmpdir = $ENV{$_}; last if -d $tmpdir; die "Invalid temporary directory $tmpdir from \$ENV{$_}\n"; } $tmpdir ||= "/tmp"; # if this is busted, you got troubles...

    -- Randal L. Schwartz, Perl hacker

      $tmpdir ||= "/tmp"; # if this is busted, you got troubles...

      I guess you've never heard of the existance of other operating systems, eh? (:

              - tye (but my friends call me "Tye")
        He has, that's why he can say it's trouble. :)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://64702]
[reisinge]: 'push @foo, @bar' is the same as '@foo = (@foo ,@bar)' ?
[shmem]: yes, at least for the result in @foo
[shmem]: but the results of both operations are different.
[shmem]: result := the discarded result (what's leftmost of the statement)

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (9)
As of 2017-04-27 11:35 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (503 votes). Check out past polls.