Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6375315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:35:57+00:00 2026-05-25T01:35:57+00:00

Within an Perl object’s method I would like to call another method on a

  • 0

Within an Perl object’s method I would like to call another method on a list of variables. Using map like so does not work:

($open, $high, $low, $close) 
    = map( $self->adjust_for_factor, ($open, $high, $low, $close) );

….

sub adjust_for_factor {
    my $self = shift;
    my $price = shift;

    return $price *  $self->get_factor ;
}

This works, however its ugly and doesn’t scale. I’m sure it must be possible to use map here:

($open, $high, $low, $close) 
= (  $self->adjust_for_factor($open)
, $self->adjust_for_factor($high)
, $self->adjust_for_factor($low)
, $self->adjust_for_factor($close) );

I guess it’s an issue of referencing self in the correct way. I’m having trouble conceptualizing how it all fits together.

Thanks to all who take the time to consider/ leave feedback.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:35:58+00:00Added an answer on May 25, 2026 at 1:35 am

    As @tchrist said, you forgot to pass $_ to your method. The correct way would be

    ($open, $high, $low, $close)    
        = map $self->adjust_for_factor($_), $open, $high, $low, $close;
    

    You can also modify the method so that it can accept a list:

    sub adjust_for_factor {
        my ($self, @prices) = @_;
    
        return map $_ * $self->get_factor, @prices;
    }
    
    ($open, $high, $low, $close)      
         = $self->adjust_for_factor($open, $high, $low, $close);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any method within Perl which would allow me to get the object
I would like to get the current filename and line number within a Perl
how to build a perl regular expresion that would match a pattern like this
So, in Perl, I have an array within an object (so, a reference to
I have Perl on Mac, Windows and Ubuntu. How can I tell from within
Within a stored procedure, another stored procedure is being called within a cursor. For
I'm using Damian Conway's inside-out objects as described is his wonderful book Perl Best
I wrote a perl script using Tie::Handle::CSV to process a bunch of data in
I am writing a Perl script that needs to transfer files between computers using
So I have some perl code that goes something like: use strict; use XML::XPath;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.