On Jul 30, Larry Steinberg said:

>How can I replace the literal "nlf" with a variable in the code below?

This was asked and answered in CLPM, but I'll answer anyway.

>sub parseLogLine {
>    $line = $_;
>
>    %searchInfo = ();
>    @searchInfo = split / +/, $line;
>
>    # found any listings?
>    $numListings = $searchInfo[8];
>    $numCategories = $searchInfo[10];
>
>    # did I detect any errors or exceptions
>    ($err) = ( $line =~ / ERR (\w+) /i );
>
>    if ( $err ne "") {
>        $err =~ tr/A-Z/a-z/;
> if ($err eq "nlf") {
>     $NLFerr++;
> }
> elsif ($err eq "cat") {
>     $CATerr++;
> }

You'll want to make a hash, %count let's call it:

  if ($err ne "") {
    $count{lc $err}++;
  }

You should use lc() instead of tr/A-Z/a-z/.

>    }

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to