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

Re: Re: Why does this core? or How am I being a bonehead

by SparkeyG (Curate)
on Mar 16, 2001 at 01:46 UTC ( #64800=note: print w/replies, xml ) Need Help??

in reply to Re: Why does this core? or How am I being a bonehead
in thread Why does this core? or How am I being a bonehead

Brother Stephan,

Your solution in much more elegant than mine, and it works on my data-set.
The one thing that I'd left out was that @bigArr will be a list-of-lists. The following references to $place, a temp var, and making the assignment into a anon array fixes that problem.

my $place=0; foreach my $record ( @dataArr ) { my (@date) = &ParseRecur($record->[3], $base, $start, $stop); foreach my $line (@date) { $bigArr[$place] = [ @$record[0, 1, 2], $line, @$record[4] ]; $place++; } }


Replies are listed 'Best First'.
Re: Re: Re: Why does this core? or How am I being a bonehead
by stephen (Priest) on Mar 16, 2001 at 02:57 UTC
    Brother SparkeyG...

    How about this? (Minor change)

    my @bigArr = (); foreach my $record ( @dataArr ) { foreach my $line ( &ParseRecur($record->[3], $base, $start, $stop) + ) { push(@bigArr, [ @$record[0, 1, 2], $line, @$record[4] ]); } }
    As a general principle: using counting variables like $place can increase program complexity unnecessarily... if you're building a list it's best to use push.

    In the same spirit, I eliminated @date, since it's only used in one place.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://64800]
[shmem]: holli: all of our machinery is more perfect in its realm than any human being in theirs (Günther Anders), which doesn't mean not having fun, albeit dangerous sometimes.
[ww]: That's a big "if", holli.
[holli]: well the google car drove 5 times as far as the average human without an accident didnt it?
[ww]: Less than confident that ai+hardware is up (yet) to randomness and counterintuitive behavior on streets of NY
[ww]: (and having lived both, Boston traffic challenges are even >.
[holli]: the nice thing about ai is that if it had an accident, it can learn and never do the same mistake again
[holli]: also, for megacity traffic, the car is the wrong answer anyway

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (12)
As of 2017-11-21 13:18 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (301 votes). Check out past polls.