Re: $escalar = @array? and regexs
- From: Mirco Wahab <wahab@xxxxxxxxxxxxxxxxxxx>
- Date: Thu, 07 Dec 2006 23:58:49 +0100
Thus spoke Dr.Ruud (on 2006-12-07 13:19):
for my $i ( 0 .. int( ($#var - 1) / 2 ) )
{
++$bad if lc $Var[$i] ne lc $Var[-1 - $i]
}
If there are 8 elements, then $# is 7, so elements 0..3 need to be
compared with 7..4.
If there are 9 elements, then $# is 8, so elements 0..3 need to be
compared with 8..5.
(I think the int() is implicit, but it doesn't harm much.)
OK, I checked the code, modified it slightly
and put it into my snippets dir:
my $var = 'Reliefpfeiler'; # something german
my @Var = split '', $var;
print "p'drome"
if not grep lc $Var[$_] ne lc $Var[@Var-1-$_], 0..@Var/2;
Regards & thanks
M.
.
- Follow-Ups:
- Re: $escalar = @array? and regexs
- From: Dr.Ruud
- Re: $escalar = @array? and regexs
- From: John Bokma
- Re: $escalar = @array? and regexs
- References:
- $escalar = @array? and regexs
- From: Winston
- Re: $escalar = @array? and regexs
- From: Mirco Wahab
- Re: $escalar = @array? and regexs
- From: John Bokma
- Re: $escalar = @array? and regexs
- From: Dr.Ruud
- $escalar = @array? and regexs
- Prev by Date: Re: unknown error
- Next by Date: Re: Perl storing huge data(300MB) in a scalar
- Previous by thread: Re: $escalar = @array? and regexs
- Next by thread: Re: $escalar = @array? and regexs
- Index(es):
Relevant Pages
|