Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Perl print statement + HTTP request

by betterworld (Curate)
on Jun 07, 2012 at 11:54 UTC ( #974923=note: print w/replies, xml ) Need Help??

in reply to Perl print statement + HTTP request

What you are thinking of is some kind of a closure, like this:

my $make_output = sub { my ($Registration, $Rank) = @_; return @{ $Data{$Registration}->{Name} }[$Rank], "\t"; }; print $make_output->($Registration1, $Rank1), $make_output->($Registration2, $Rank2);

Though I guess that you might be able to simplify your code by using techniques such as OO.

Update: The following code shows what an OO variant would look like. Maybe you are trying to do something completely different; but according to your short line of code, I imagine that you could probably use this example.

my $data = Data->new( ... ); print $data->make_output($Registration1, $Rank1), $data->make_output($Registration2, $Rank2); # class definition package Data; sub new { # set up data object # ... } sub make_output { my ($self, $Registration, $Rank) = @_; return @{ $self->{$Registration}->{Name} }[$Rank], "\t"; }

Replies are listed 'Best First'.
Re^2: Perl print statement + HTTP request
by Anonymous Monk on Jun 07, 2012 at 15:02 UTC
    Exactly what i was looking for and a straighforward method. Anyone have any idea about the HTTP request part? For me it seems it would not matter but I want to make sure.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://974923]
[LanX]: I remeber M::S (it was dialog driven?) to be buggy
[stevieb]: As far as Dist::Zilla goes, I don't like installing that other than on systems my test platorm runs on. I find it too heavy. I prefer being able to glean a Makefile.PL
[LanX]: what's frustrating me is that a distribution has lots of dupplicated info
[stevieb]: LanX I don't know if it's dialog driven; I just use it in the simplest of terms (just run module-starter at the CLI, and the very last couple of lines are how I use it.
[stevieb]: which dist are you speaking of regarding dups, LanX?
[LanX]: readme version number and so on ...
[stevieb]: with M::S, you can also add other tags, but defaults work... such as --license=perl --eumm
[LanX]: I'm not a big fan of pure make, apparently the auto generated ones are so complicated to be able to work with all possible makes

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2017-08-18 20:54 GMT
Find Nodes?
    Voting Booth?
    Who is your favorite scientist and why?

    Results (310 votes). Check out past polls.