Perl code -need some understanding.

Posted by benjamin button on Stack Overflow See other posts from Stack Overflow or by benjamin button
Published on 2010-04-28T07:38:23Z Indexed on 2010/04/28 7:43 UTC
Read the original article Hit count: 238

Filed under:
|

Hi i have a perl code below:

foreach (@tmp_cycledef)
{
    chomp;
    my ($cycle_code, $close_day, $first_date) = split(/\|/, $_,3);
    $cycle_code =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
    $close_day =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;
    $first_date =~ s/^\s*(\S*(?:\s+\S+)*)\s*$/$1/;

    #print "$cycle_code, $close_day, $first_date\n";
    $cycledef{$cycle_code} = [ $close_day, split(/-/,$first_date) ];
}

the value of tmp_cycledef comes from output of an sql query:

select cycle_code,cycle_close_day,to_char(cycle_first_date,'YYYY-MM-DD')
  from cycle_definition d
  order by cycle_code;

can anybody tell me what exactly is happening inside the for loop? thanks in advance.

© Stack Overflow or respective owner

Related posts about perl

Related posts about unix