Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

You win the prize sir! My ability to find modules leaves a lot to be desired, but I just knew something this common must exist. That said, I have always loathed object oriented code (I'm still bad at that too).

use strict; use warnings; use Normalize; my @not_normalized = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); my @are_normalized = @not_normalized; my $norm = Normalize->new(); $norm->normalize_to_max(\@are_normalized); printf "%.2f ", $_ foreach (@not_normalized); print "\n@are_normalized\n";

UPDATE: I do get the module to come up right away of course when I search CPAN for "normalize", but I originally tried Googling "cpan normalize array" and that doesn't seem to get anywhere close. Also, I still don't understand for the life of me why I need to call the constructor for a new object just so I can use a method of that object on the array like I do here. Certainly I'm just ignorant when it comes to object oriented code, there must be a way to use the method without actually having to create an object, or to otherwise use an "anonymous" object method call if that's even the right terminology. Did I mention I loathe (a.k.a. need to learn better) object oriented code? :-)

I love it when things get difficult; after all, difficult pays the mortgage. - Dr. Keith Whites
I hate it when things get difficult, so I'll just sell my house and rent cheap instead. - perldigious

In reply to Re^4: returnong array in custom subroutine by perldigious
in thread returning array in custom subroutine by dovah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (1)
As of 2022-07-07 10:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?