th3monk3y has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,
this might be a tricky one... here is my problem... I have a php script for my jabber online status indicator... hardwired it looks like this... calls to the script with args....

http://mydomain.com/chatmonk3y/online_indicator/webber.php?jid=monkeyboy@mydomain.com

I have been able to pull it into my perl script and make it work as long as it is hardwired!!

my $online_indicator = "http://mydomain.com/chatmonk3y/online_indicator/webber.php?jid=monkeyboy\@mydomain.com";

etc... etc... then print to the page...
$content=~ s/<!-ONLINE_INDICATOR-->/$online_indicator/;

now, just as soon as i replace "monkeyboy" with my $scalar($seller)...it no longer works!

my $online_indicator = "http://mydomain.com/chatmonk3y/online_indicator/webber.php?jid=$seller\@mydomain.com";

It's almost like perl is writing in the scalar after the fact! Is there a way to force perl to fill in the $scalar before it does the request? It's wierd because on my output page it shows a broken image, but if I right click and view the properties, the "path" to the image is correct! When I say "path" I mean the $scalar has been filled in...I can actually copy and paste that path into the browser and then hit my target just fine...

I have tried using LWP::SIMPLE with get("myurl") but as soon as there are any html tags in the script (output)... it displays my image as a bunch of garlbled text!!

Replies are listed 'Best First'.
Re: pulling php into perl
by Coruscate (Sexton) on Jun 21, 2003 at 19:50 UTC

    I see the 'Not Online' image just fine. I suggest you try clearing your browser cache. You may have an old, broken image saved there... :)

    It's because the URL you are putting for the image doesn't output an image. It outputs an html page that contains an image. You'd need to use an iframe for this thing, or else get the html from that URL and use that for output instead of trying to use an image.

    Oooh... as well, you may wish to be more careful with user-supplied data: dangerous ya know :)


    If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, please reply to this node or /msg me to inform me as to what is wrong with the post, so that I may update the node to the best of my ability.

      no, the one you see in the sellers box is straight up a linked image(until i get this working) the broken image is further down the page on the left hand side.. :)
        "Oooh... as well, you may wish to be more careful with user-supplied data: Cross-scripting attacks are possible ya know :) " Yikes, How do I edit my posts????
Re: pulling php into perl
by little (Curate) on Jun 21, 2003 at 18:01 UTC
    you might try
    my $online_indicator = 'http://mydomain.com/chatmonk3y/online_indicato +r/webber.php?jid=' . $seller . '@mydomain.com'; # or more abstract # my $online_indicator = $protocol . $hostname . $pathToScript . $argu +mentList;

    Note that double quotes force content negotiation whereas single quotes don't (which slightly speeds up the script as some parsing isn't needed).

    Have a nice day
    All decision is left to your taste

    Update
    But what does my $scalar($seller) do? Where do you use that?
    Might be helpfull to post some more code to better document the context of the problem.

      Same thing... still broke :(

      http://www.bidmonkey.com/cgi-bin/th3monk3y/itemtest.pl?item=17027

      scroll down the page about midway to where you see the hit counter and on the left hand side and you will see the broken "test" image. if you view the properties you will see the following: Click on this link and it works...

      http://bidmonkey.com/chatmonk3y/online_indicator/webber.php?jid=mhuka@bidmonkey.com

       

      "But what does my $scalar($seller) do?"

      sorry about that.... What I meant was that my scalar is named $seller

      What I don't understand is, why is it that when I hard code monkeyboy instead of $seller, it works?????

      Maybe I need to force perl to do the variable before it does the request??? just as if it was hard coded... Is there a way to do this?

      Regards,

      -Paul

Re: pulling php into perl
by fglock (Vicar) on Jun 21, 2003 at 18:57 UTC

    Print out $online_indicator just after defining it. This will tell you what you really got.

      print "$online_indicator";

      http://bidmonkey.com/chatmonk3y/online_indicator/webber.php?jid=mhuka@bidmonkey.com

      heh...ah man.... this sucks... this doesn't make it any easier when it shows it's doing what it is supposed to be doing ... "mhuka" above is the $seller