Hi John W. Krahn, you wrote:

Thanks for taking the time for this detailed explanation!

>If I understand you correctly then this will do what you want:
>
>$str =~ tr/ //s;
>
>Or if you want a slower method:
>
>$str =~ s/ +/ /g;

This might sound a strange question, but why is the first one faster?

>Or if you want to do it the hard way:
>
>$str = join ' ', split ' ', $str;

This just confuses me!

>By the way, the /i option is for a case insensitive match.

*snip*

Aye, I saw that as soon as I hit the post button!  However, your
additional comments were useful anyway.  I think I'm confusing myself
though with matches and expressions.

I thought that I could remove lines from the data by matching whether
the first character was a letter by using the 'if' statement as :

  if(substr($line,0,1) eq [a-zA-Z])

...but this doesn't work.  Neither does :

  if($line eq [\s\d])

...to try and find if it's just contain numbers and spaces.

Obviously I'm missing the point on the syntax but just can't see what
and the perldocs read like stereo instructions! :)
-- 
Dale


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to