[ic] help pulling info from URL

Grant interchange-users@icdevgroup.org
Fri Nov 1 12:39:00 2002


>> >On Thu, 31 Oct 2002 21:08:54 -0500
>> >Duncan McGreggor <oubiwann@myrealbox.com> wrote:
>> >
>> >> Well, one of perl's mottos is that there's more than one way
>to do it...
>> >> here's one elementary way:
>> >>
>> >> $last_url = '[data session last_url]';
>> >> @parts = split("/", $last_url);
>> >> # position 0 should be nothing
>> >> # position 1 should be "category"
>> >> # position 2 should be "posters"
>> >> # position 3 should be "p1.html"
>> >> $pstn2 = $parts[2];
>> >> $pstn3 = $parts[3];
>> >
>> >And here a shorter way to do it (also untested):
>> >
>> >($pstn2, $pstn3) = (split("/", $Session->{last_url})[2,3];
>> >
>> >Ciao
>> >        Racke
>>
>> I set this up:
>>
>> [perl] ($pstn2, $pstn3) = (split("/", $Session->{last_url})[2,3]; [/perl]
>> [scratch pstn2], [scratch pstn3]
>>
>> but it returns nothing.  What am I screwing up?
>
>First, one paren is missing.
>
>Second, no program in the world can read your thoughts. Why should
>the Perl variables
>automagically appear in the scratch namespace ? Try:
>
>[perl] ($Scratch->{pstn2}, $Scratch->{$pstn3}) = (split("/",
>$Session->{last_url}))[2,3]; [/perl]
>
>Ciao
>      Racke

Racke and Duncan:
I've got both of your setups set up and neither one is coming through for
me.  I'm sure I'm messing up some mundane detail but I don't know what it
is.  Here's my code:

[data session last_url]
<br />

[perl]
($Scratch->{$pstn2}, $Scratch->{$pstn3}) = (split("/",
$Session->{last_url}))[2,
3];
[/perl]

[perl]
$lasturl = '[data session last_url]';
@parts = split ("/", $last_url);
$Scratch->($pagename) = $parts[2];
$Scratch->($pagenumber) = $parts[3];
[/perl]

[scratch pagename], [scratch pagenumber]
<br />
[scratch pstn2], [scratch pstn3]

and here's my output:

/category/posters/p1.html
2 ,
,

Thanks for your help guys!

- Grant