Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: framechat

by a (Friar)
on Mar 14, 2001 at 03:38 UTC ( [id://64261]=note: print w/replies, xml ) Need Help??


in reply to framechat

On Solaris 2.5/Apache I got a few troubles. One, ENV{TEMP} wasn't defined, so I did:
my $temp = $ENV{TEMP} || "/tmp"; ... # so then my $today = "$temp/$yr$mo$mday.txt"; my $normfile = "$temp/.norm"; my $cookies = "$temp/.cookies";
I also was getting a few 100 uninit errors so I:
if($i{sexisgood} and $i{'sexisgood'}=~/submit/){&msgsend()} if($i{op} and $i{'op'}=~/message/){&sendit($i{'message'})} if ( $i{n} ) { if($i{'n'}=~/norm/){&norm()} if($i{'n'}=~/self/){&self()} } print header; if ( $i{n} ) { if($i{'n'}=~/hist/){&history()} if($i{'n'}=~/users/){&users()} ... if($i{'n'}=~/help/){&help()} } else { # if $i{n} #unless($i{'n'} ){ print<<HTML; <title>framechat</title> <frameset cols="*,20%" border="$fborder"> ... </frameset> </frameset> HTML } # if ${n} exit
and finally, all my chat/msgs were showing up as arrar refs so I followed all the makelinks calls:
&makelinks($message->{'content'}); if ( ref($content) eq "ARRAY" ) { $content = join("", @{$content}); }
to get back text. I think:
my $content = &makelinks($message->{'content'});
would be a little nicer than the global $content, unless you need to get at it elsewhere. Finally, and, this isn't probably your doing, but all my boxes (behind the black) say:
Can't use string ("<CHATTER><INFO site="http://perl") as a symbol ref while "strict refs" in use at /usr/local/lib/perl5/site_perl/5.005/i86pc-solaris/XML/Parser/Expat.pm + line 451.
I fear my xml isn't up to date. Pretty cool stuff, and well worth all that testing, though I loan you, heck give you the 50 or so extra spaces to use after 'my' ;-> Thanks for the code!

a

Replies are listed 'Best First'.
Re: Re: framechat
by epoptai (Curate) on Mar 14, 2001 at 05:33 UTC
    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 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")
        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://64261]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-03-28 20:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found