in reply to How to use long strings...

if your format is really:

crud_GOOD_crud
Then you can split it out:
#untested for (split("\n", $content) ) # split string to multiple lines { my (undef, $good, undef) = split(/_/, $_); # could also be written as $good = ( split(/_/, $_) )[1]; $seen{$good}++; } for ( keys %seen ) { print "$_ $seen{$_}\n" }

--Bob Niederman, http://bob-n.com

All code given here is UNTESTED unless otherwise stated.

Replies are listed 'Best First'.
Re: Re: How to use long strings...
by zby (Vicar) on Sep 03, 2003 at 09:20 UTC
    The OP described the searched strings as rather "CRUD$left_string_GOOD_$right_stringCRUD" then just "crud_GOOD_crud". So you should split on /${left_string}_|_$right_string/.
Re: Re: How to use long strings...
by khelben (Initiate) on Sep 03, 2003 at 09:30 UTC
    Thank You,
    for (split("\n", $content))
    {
    $good = ( split(/logo_/, $_) )1;
    $good1 = ( split (/_20x/, $good) ) [0];
    $seen{$good1}++;
    }

    for ( keys %seen )
    {
    print "$_ $seen{$_}
    ";
    }
    works.
    Can I sort the output by the numbers?
    In the output is an number, witch i can not find with
    grep logo_ count.html | cut -d\, -f4 | sort | countfirstString.awk | sort -t\, -k2nr | less
      May be, the unknown number are the number of lines, witch do not contain the "/logo" and/or "_20x"?
      How can I fix this?
      Thank You,
      Roman