Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: framechat

by epoptai (Curate)
on Mar 14, 2001 at 05:33 UTC ( [id://64295]=note: print w/replies, xml ) Need Help??


in reply to Re: framechat
in thread framechat

Thank you a, one at a time:

Your first fix to temp didn't work for me, changing the || to "or" worked, but generated a warning about useless use in void context. The following works for me:

if(-d "/tmp"){$temp = "/tmp"} else {$temp = $ENV{TEMP}}
I'll take your advice about checking for uninitialized variables. I was being lazy.

I don't understand your next problem with array refs, and suspect it's related to the last problem you associate with outdated xml modules, but will include your fix to increase compatability.

$content is global because it's used in three subroutines.

Your final problem is troubling. I'd like to know which version of Expat to check for so i could throw a nicer warning with a link to the module on cpan.

ps - Thanks to OeufMayo for the cool xp progress patch.

Replies are listed 'Best First'.
Re: Re: Re: framechat
by a (Friar) on Mar 14, 2001 at 20:43 UTC
    Replies then: the idea was to handle a not filled in ENV TEMP. The || works fine here, e.g. try
    use strict; $ENV{TEMP} = "goo go"; my $temp = $ENV{TEMP} || "/tmp"; print "t $temp\n";
    what do you get when it doesn't work? I guess for max portability, you'd probably want a combo of your and my fix, I was just trying to avoid assuming ENV{TEMP} was valid (as mine wasn't ;-).

    I understand $content is used in 3 places, but isn't it being filled in each time by makelinks? If one sub were filling it in (beside makelinks) and another needing access, global, but it appears its used 'locally' each time it has data in it. A style quibble, really, I just was trying to figure out the array bug and had to poke a bit deeper to see makelinks was filling in $content. It appears, w/ data, by 'magic' otherwise.

    Expat.pm is 2.29, I'll try upgrading things to see if that's the trouble. Huh. Perhaps this ver returns an array ref instead of a string?

    Update: upgraded to Parser 2.30 - same stuff. Both the array ref and the XML as ref problem. I'll keep poking - perhaps a debug box where we could see the xml as it arrives?

    Update 2:Hmm. If I turn off 'fatalsToBrowser' no complaints and it appears the complaint is from Expat doing an eval around:$ioref = *{$arg}{IO}; where $arg is the incoming xml. I gather its supposed to die ($@ is my error msg) but why this floats up to cgi::carp for me and not you ???

    a

      BTW, the suggestion on this that I made in the chatterbox was $ENV{TMPDIR} || $ENV{TMP} || $ENV{TEMP} || "/tmp" (with the possiblity of replacing "/tmp" with File::Spec->tmpdir() if you don't mind requiring Perl 5.6) and then dieing if the resulting directory did not exist.

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

        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")
      a's 4 liner works as expected from the command line, but from CGI in framechat, it doesn't find $ENV{TEMP} on my system, neither does tye's line. So, rather than gamble with the location of $temp it's been made a config variable that defaults to the script directory, so people with restrictive environments can easily set it.

      I see what you mean about the 'magic' $comment global. It's really just an artifact of the development process, it was needed at first but eventually coded out of relevance.

      Update:

      (an obsolete patch that was here has been deleted)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://64295]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-19 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found