What does $base)->abs do?

N

nntp

I checked the document, but its statement means nothing. I also did the
test, no difference at all.

my $base = $response->base;
@output = map { $_ = url($_, $base)->abs; } @output;

my $base = $response->base;
@output = map { $_ = $base } @output;

Both act the same.
 
B

Brian McCauley

nntp said:
Subject: What does $base)->abs do?

Nothing - it is not a meaining full code fragment.

EXPR->abs

Evaluates an expression and then attempts a method call 'abs' on the
result. If the result of

I checked the document, but its statement means nothing.

The document? Which document? The document that is the documentation
from the class of the object that the expression is retunring?
I also did the test, no difference at all.

my $base = $response->base;
@output = map { $_ = url($_, $base)->abs; } @output;

my $base = $response->base;
@output = map { $_ = $base } @output;

Both act the same.

In that case, without knowing anything about the url() function (because
I don't know what module you are getting) I can make two totally
random stabs in the dark simply by guessing at the functinality.

1) Maybe you've got the arguments of url() transposed.

2) Maybe all the elements in @output were initially empty strings.

Oh and:

@foo = map { $_ = somefunction($_) } @foo;

is affected and confusing. Say instead:

$_ = somefunction($_) for @foo;

or

@foo = map { scalar somefunction($_) } @foo;

Of course scalar() can be omitted id somefunction() is a scalar function
(my terminolgy for a function that returns in a LIST context a single
element with the value of the function in a scalar context).
 
B

Brian McCauley

nntp wrote:

[ Attribution to (e-mail address removed) not included by nntp ]
I copied the code from linkextor, it uses
use URI::URL;

Well, then that seems to support option 2.
 
T

Tad McClellan

[ snip 45 lines, with no attributions ]
I copied the code from linkextor, it uses
use URI::URL;


Please learn how to properly compose a followup.

Please do this soon before you become widely auto-ignored.


Provide attributions when you quote someone.

Quote only enough to establish the context for your comment.

Have you seen the Posting Guidelines that are posted here frequently?
 
J

Joe Smith

nntp said:
I checked the document, but its statement means nothing. I also did the
test, no difference at all.

Perhaps you did not use meaningful data in the test.
my $base = $response->base;
@output = map { $_ = url($_, $base)->abs; } @output;

my $base = $response->base;
@output = map { $_ = $base } @output;

Both act the same.

They act quite differently with @output contains relative URLs,
absolute URLs on the current host, and URLs pointing to a different host.

@output = qw(img/foo.gif /cgi-bin/env http://www.example.com/index.html);

If you understand how <head><base href="http://www.example.com/q/"></head>
works, then you'll understand how $base works.
-Joe
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,427
Latest member
HildredDic

Latest Threads

Top