Re: Newbie questions, migrating from c++
From: Kåre Olai Lindbach (barbr-en_delete__at_online.no.invalid)
Date: 12/12/04
- Next message: A. Sinan Unur: "Re: Newbie questions, migrating from c++"
- Previous message: Steve May: "Re: sprintf rounding puzzlements"
- In reply to: gg500_at_lycos.com: "Re: Newbie questions, migrating from c++"
- Next in thread: Kåre Olai Lindbach: "Re: Newbie questions, migrating from c++"
- Reply: Kåre Olai Lindbach: "Re: Newbie questions, migrating from c++"
- Reply: gg500_at_lycos.com: "Re: Newbie questions, migrating from c++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 12 Dec 2004 19:25:46 +0100
On 12 Dec 2004 10:14:47 -0800, gg500@lycos.com wrote:
>K? Olai Lindbach wrote:
>> $_ = ' string with spaces first';
>> s/^\s+//;
>> print "$_\n";
>
>But the code you propose cuts the spaces from the beginning of the line
>and does not solve the problem. I was posing a problem which I needed
>to know how many spaces there were.
Sorry, I got so upset with earlier questions in this thread that I
didn't get this question/problem correctly... ;-)
use strict;
$_ = ' string with spaces first';
if(/^(\s+)/) {
print length($1),"\n";
}
or using a decent variable name:
$atext = ' string with spaces first';
if($atext =~ /^(\s+)/) {
print length($1),"\n";
}
This is not the most concise way, I believe.
-- mvh/Regards Kåre Olai Lindbach (News: Remove '_delete_' and '.invalid') (HTML-written email from unknown will be discarded)
- Next message: A. Sinan Unur: "Re: Newbie questions, migrating from c++"
- Previous message: Steve May: "Re: sprintf rounding puzzlements"
- In reply to: gg500_at_lycos.com: "Re: Newbie questions, migrating from c++"
- Next in thread: Kåre Olai Lindbach: "Re: Newbie questions, migrating from c++"
- Reply: Kåre Olai Lindbach: "Re: Newbie questions, migrating from c++"
- Reply: gg500_at_lycos.com: "Re: Newbie questions, migrating from c++"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|