strange behavior of URI inside a package 
Author Message
 strange behavior of URI inside a package

I'm trying to use the URI module inside a package I'm making but it
fails to produce what I'm expecting.

Example:

use URI;
$u1 = new URI ("www.foo.com", "http");
print $u1->as_string;

Result: www.foo.com

duh... I was expecting http://www.*-*-*.com/

Can someone help or tell me why it behaves like that?

Thanks.

Sebastien Nadeau



Mon, 21 Oct 2002 03:00:00 GMT  
 strange behavior of URI inside a package

Quote:
>> On Thu, 04 May 2000 16:07:22 GMT,

> I'm trying to use the URI module inside a package I'm
> making but it fails to produce what I'm expecting.
> Example:
> use URI; $u1 = new URI ("www.foo.com", "http"); print
> $u1->as_string;
> Result: www.foo.com

There's something in "perldoc URI" about relative paths

    $uri = URI->new( $str, [$scheme] )

       The $scheme argument is only used when $str is a
       relative URI.  It can either be a simple string that
       denotes the scheme, a string containing an absolute
       URI reference or an absolute `URI' object.

This URL is absolute.

Quote:
> duh... I was expecting http://www.foo.com

    use strict;
    use URI;

    my $u1 = new URI;

    $u1->scheme('http');
    $u1->host('www.foo.com');
    $u1->path('/');

    print $u1->as_string, "\n";

    my $u2 = new URI 'a/b/c';

    my $u3 = $u2->abs($u1);

    print $u3->as_string, "\n";

outputs:

        http://www.foo.com/
        http://www.foo.com/a/b/c

hth
t



Mon, 21 Oct 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Alias Creation

2. IBMCOM.PAS - The missing file.

3. strange behavior from cgi inside protected directory

4. Packaging effect on SORT -strange behavior

5. Using a package identifier inside a package

6. weird behavior with URI::URL

7. Scripting Language ...

8. Behavior of focus on an Entry inside a Canvas - Help please

9. Strange $n behavior

10. Strange behavior in sort_by_field

11. strange behavior of shift under 5.005

12. Strange behavior with NET:Ftp under Cron

 

 
Powered by phpBB® Forum Software