Web Analytics Made Easy -
StatCounter Multi dimensional array piece of cake for a guru? - CodingForum

Announcement

Collapse
No announcement yet.

Multi dimensional array piece of cake for a guru?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multi dimensional array piece of cake for a guru?

    Ok, I tried to do this all by myself for a week now but, oh well. I am really stuck.

    I have a flatfile datafile delimited with "|".
    Like this:
    01|0ne|One2a||One3a|note
    02|20ne|One2b||One3b|note
    03|30ne|One2c||One3c|note
    04|40ne|One2d||One3d|note
    05|Club Med|9pm|1am|This club rocks, every night!|note
    (all the way to line 31)
    31|||||note

    I would like to be able to set a local var to a specific row and column.
    Specifically I want:
    $day
    $club
    $start_time
    $end_time
    $desc
    $note
    foreach line.

    I was able to get the clubs (2nd field) like this...

    my %clubs;
    open (FH, "$datafile");
    while (<FH>) {
    chomp;
    my ($key,$value) = split(/\|\s?/);
    $clubs{$key} = $value;
    }
    $club1="$clubs{'01'}";$club2="$clubs{'02'}";$club3="$clubs{'03'}";$club4="$clubs{'04'}";$club5="$clu bs{'05'}";
    $club6="$clubs{'06'}";$club7="$clubs{'07'}";$club8="$clubs{'08'}";$club9="$clubs{'09'}";$club10="$cl ubs{'10'}";
    $club11="$clubs{'11'}";$club12="$clubs{'12'}";$club13="$clubs{'13'}";$club14="$clubs{'14'}";$club15= "$clubs{'15'}";
    $club16="$clubs{'16'}";$club17="$clubs{'17'}";$club18="$clubs{'18'}";$club19="$clubs{'19'}";$club20= "$clubs{'20'}";
    $club21="$clubs{'21'}";$club22="$clubs{'22'}";
    $club23="$clubs{'23'}";$club24="$clubs{'24'}";$club25="$clubs{'25'}";
    $club26="$clubs{'26'}";$club27="$clubs{'27'}";$club28="$clubs{'28'}";$club29="$clubs{'29'}";$club30= "$clubs{'30'}";
    $club31="$clubs{'31'}";
    close(FH);

    Then I was able to pull in $club14 or whatever later on in the script.

    But, since I am obviously making a calendar, I would like to have all the vars from the one datafile into a multi dimensional array.
    This will allow me to grab any piece of data I want.

    Dammit Jim, I am a musician not a perl coder!

    Thanks so much in advance for showing me how to do this.
    Last edited by bourbonmaster; Feb 17, 2004, 08:39 PM.
Working...
X