Re: What does "=<" means?



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,

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 }
@source_array;

... 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.
:)

-- 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>
wrote:
Xi 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
true
if
the value in $n is equal to 2 or is any value greater than 2, 6 for
example.
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
information)
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)


Relevant Pages

  • Re: Sub document w/ mail merge data
    ... is that using the Master Document feature is a good way to destroy your ... I have letters that go to a person and it lists people and addresses who ... If i use one data source i will have 10 seperate letters to John Smith. ...
    (microsoft.public.word.vba.customization)
  • Re: Le Restaurant Fabrice, Teynham
    ... Is it some in-joke or do you just like to be called "Mr Davies". ... Some might say "Master" would be more appropriate. ... own letters and such menial tasks are delegated to your secretary. ... it's not important for the recipient to take seriously and it's consigned ...
    (uk.local.kent)
  • Re: letters and numbers
    ... master at excel, but i thought i was pretty good. ... >>This works best where an entire range of cells (row, ... >letters with numbers. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Custom page size nightmare
    ... Weylock" wrote: ... > Master of Word. ... > Zoom setting of 50% or less and are seeing as many pages as will fit in your ... Works ok, except the newly merged document, (ie when merge to make letters) ...
    (microsoft.public.mac.office.word)