For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > May 2006 > strange - get(url) changes local variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author strange - get(url) changes local variable
zorro

2006-05-29, 8:03 am

Hello,

I've only been doing perl for two ws so this might be a newbie
problem, yet this error still is kind of strange. I'm fetching an xml
file with get(), and it changes the value of a local variable named
$url - could it be that $url is a reserved word?


$url = $FORM{'someUrl'}; // just some url

if($FORM{'shopInfoUrl'}) // fetching xml file
{
use Socket;
my $xml="";

# when i do a trace here, $url is what it should be

$xml = &get($FORM{'shopInfoUrl'});

# when i do a trace here, $url now equals the fetched url
# while $FORM{'someUrl'} still has the original value

}

Any idea what's going on?

DJ Stunks

2006-05-29, 7:03 pm

zorro wrote:
> Hello,
>
> I've only been doing perl for two ws so this might be a newbie
> problem, yet this error still is kind of strange. I'm fetching an xml
> file with get(), and it changes the value of a local variable named
> $url - could it be that $url is a reserved word?
>
>
> $url = $FORM{'someUrl'}; // just some url
>
> if($FORM{'shopInfoUrl'}) // fetching xml file
> {
> use Socket;
> my $xml="";
>
> # when i do a trace here, $url is what it should be
>
> $xml = &get($FORM{'shopInfoUrl'});
>
> # when i do a trace here, $url now equals the fetched url
> # while $FORM{'someUrl'} still has the original value
>
> }
>
> Any idea what's going on?


it is impossible to tell from your snippet.

please follow the posting guidelines for this group and post a _short_
but _complete_ script (including use strict and use warnings) which
demonstrates your issue and someone will be glad to help you debug it.
remember to copy and paste this script in - don't just write it on the
fly.

-jp

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com