On May 7, Craig Moynes/Markham/IBM said:

>Stumped on this problem
>my ( %self );

You're creating a hash above...

>$self->{DF_SPEC} = {

And then populating a hash reference ($self is not %self).

>        a       => '(Mon|Tue|Wed|Thu|Fri|Sat|Sun)',
>        A       => '(Monday|Tuesday|Wednesday|Thursday|Friday)',
>        b       => '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)',
>        B       =>
>'(January|February|March|April|May|June|July|August|September|October|November|December)',
>        c       => "$self->{DF_SPEC}{a} $self->{DF_SPEC}{b}
>$self->{DF_SPEC}{e}
>$self->{DF_SPEC}{H}:$self->{DF_SPEC}{M}:$self->{DF_SPEC}{S} CUT
>self->{DF_SPEC}{Y}",

You are accessing values before they exist.  You need to build your hash
in stages.  First constants, then those that use constants, then those
that use those, etc.

Here is an example.

  %fields = (
    s => '([0-5]\d)',
    m => '([0-5]\d)',
    h => '([01]\d|2[0-3])',
  );

  $fields{t} = "$fields{h}:$fields{$m}:$fields{s}";

You might also consider using regex objects instead of quoted strings.

  %fields = (
    s => qr/([0-5]\d)/,
    m => qr/([0-5]\d)/,
    h => qr/([01]\d|2[0-3])/,
  );

  $fields{t} = qr/$fields{h}:$fields{$m}:$fields{s}/;

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734

Reply via email to