Re: What does "=<" means?
- From: jdriselvato@xxxxxxxxx (John Riselvato)
- Date: Fri, 30 Dec 2011 11:54:59 -0500
in this code what is the
$n =~ /$b/i;
On Fri, Dec 30, 2011 at 11:53 AM, John Riselvato <jdriselvato@xxxxxxxxx>wrote:
in this code what is the
$n =~ /$b/i;
On Fri, Dec 30, 2011 at 10:51 AM, Igor Dovgiy <ivd.privat@xxxxxxxxx>wrote:
Oh my, of course it should be...
my @repeated = grep { /some regex here/ && ++$seen{$_} > N }
@source_array;
... to work properly.
-- iD
2011/12/30 Igor Dovgiy <ivd.privat@xxxxxxxxx>
Hi Xi,@source_array;
You're looking only for 'p' letters, not D and O? Why?
Anyway, generic solution will be something like...
my %seen;
my @repeated = grep { /some regex here/ && $seen{$_} > N }
:)
... where N is how many times the symbols should appear in the source
array to be counted as duplicate.
and 'some regex' is, well, some regex to filter the symbols if needed.
wrote:
-- iD
2011/12/30 Xi Chen <cxde515@xxxxxxxxx>
Yes, I agree the code looks strange. Do you have any idea to do this
with a clear code? I mean to find two same letters, "p" in @a?
Xi
On Thu, Dec 29, 2011 at 10:17 PM, John W. Krahn <jwkrahn@xxxxxxx>
trueXi Chen wrote:
Hello everyone,
I saw a code below to get two same letters "p" in @a.
@a = qw (D D p O H p A O);
foreach $b (@a){
$n =~ /$b/i;
if($n>= 2){
$m = $b;
}
}
But I don't know what does ">=" mean. Thank you!
It means "greater than or equal to". The expression "$n >= 2" is
information)if
the value in $n is equal to 2 or is any value greater than 2, 6 forexample.
If the value in $n is less than 2 then the expression is false.
Your algorithm looks weird though because you are testing $n for the
presence of alphabetic characters (and then not using that
and
then using $n in a numerical context.
John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction. -- Albert Einstein
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/
--
"Its the Othello of programming languages: a minute to learn, a lifetime
to master" - mwn3d (RosettaCode irc)
--
"Its the Othello of programming languages: a minute to learn, a lifetime to
master" - mwn3d (RosettaCode irc)
- References:
- What does "=<" means?
- From: Xi Chen
- Re: What does "=<" means?
- From: "John W. Krahn"
- Re: What does "=<" means?
- From: Xi Chen
- Re: What does "=<" means?
- From: Igor Dovgiy
- Re: What does "=<" means?
- From: Igor Dovgiy
- What does "=<" means?
- Prev by Date: Re: What does "=<" means?
- Next by Date: Review: Perl for Perl Newbies Part 5 - Good Programming Practices
- Previous by thread: Re: What does "=<" means?
- Next by thread: Review: Perl for Perl Newbies Part 5 - Good Programming Practices
- Index(es):
Relevant Pages
|