in reply to Matching * in a pattern

greping with scalar value returns the number of matches. Thus:
$a = grep /\*/, $the_asterix_string;
and $a would contain the number of *'s so you can call the function with it. you can still do
if ($a) { : }
since if there are no *'s, $a would be undef or 0. Doesnt matter which, if won't return true.

-Nimster
Freelance writer for GameSpy industries LTD. (www.gamespy.com)

Replies are listed 'Best First'.
RE: Re: Matching * in a pattern
by mwp (Hermit) on Jul 26, 2000 at 09:56 UTC
    That's a fair idea Nimster, but here's an even better way.

    $num_matches = $str =~ tr/\*/\*/;

    Alakaboo
    I am the lurker that spams in the night.