Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: My 'perldar' tells me there is a 'better' solution for this list operation

by DigitalKitty (Parson)
on Nov 04, 2006 at 03:34 UTC ( #582212=note: print w/replies, xml ) Need Help??

in reply to My 'perldar' tells me there is a 'better' solution for this list operation

Hi OfficeLinebacker,

In order to reduce the 'noise factor' of your array definitions, you could also construct each as follows:

#!/usr/bin/perl use warnings; use strict; my ( @l1, @l2 ); @l1 = qw(Date IndexID Maturity OnTheRun CompositePrice CompositeSpread ModelPrice ModelSpread Depth Heat); @l2 = qw(OnTheRun CompositePrice CompositeSpread Depth); # More code here...

By declaring your variables, arrays, hashes, etc. at an earlier stage in the program, it reduces, in my experience, a portion of the frustration inherently present in the debugging process.

Hope this helps,

  • Comment on Re: My 'perldar' tells me there is a 'better' solution for this list operation
  • Download Code

Replies are listed 'Best First'.
Re^2: My 'perldar' tells me there is a 'better' solution for this list operation
by Jenda (Abbot) on Nov 04, 2006 at 17:20 UTC

    I don't think you gain anything this way. Except that you exercise your fingers more. And I don't think it's good to predeclare your variables. You should keep the scope of all variables as small as posible, declaring them only as you intend to start using them. Sometimes it's even good to introduce a block into the code just so that you could specify the scope of a variable, if you want to use it just in those ten lines and not anywhere else. Everything is IMHO of course.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://582212]
[LanX]: (not a high priority bug because I can use some HTML entities in the second string)
[Corion]: base64 is padded to a multiple of 4 chars (or something)
[LanX]: misunderstanding, I joined them before converting to base64
[Corion]: Also, I would be wary of encodings and try to make really sure that both input strings are UTF-8. Maybe join the input strings from one source together to see whether they decode as bad or not
[Corion]: LanX: Then the problem should persist without encoding to base64 too ;)
[LanX]: I think it's a flag problem ... I'll produce a reprodocable example for SOPW
[Corion]: "flag problem" to me sounds like "contains UTF-8 bytes but was never properly decoded to an UTF-8 string"
[LanX]: not my code ...
[choroba]: yeah, sounds like one of the strings is not flagged as UTF-8
[choroba]: which usually means its input wasn't handled correctly

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-01-16 13:55 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (150 votes). Check out past polls.