[SP-pm] [Fwd: duvidas]

Daniel de Oliveira Mantovani daniel.oliveira.mantovani at gmail.com
Fri May 29 06:24:30 PDT 2009


2009/5/28 Alexei Znamensky <russoz em gmail.com>

>
>
> 2009/5/28 Andre Carneiro <andregarciacarneiro em gmail.com>
>
>> [...]
>>
>>
>>
>
>> Só implemente essa linha acima, se o seu arquivo for realmente muito
>> pequeno. Caso contrário você pode fazer:
>>
>> <code>
>>
>> #$fh é o filehandle que eu sugeri mais acima...
>> my $line = '';
>> my $lnumber = 0;#contador de linhas.
>> while(<$fh>) {
>>      $line = $_; $_
>>      if($line =~ m{$keyword}){
>>           print "\nACHEI! - $lnumber";
>>      }
>>      $lnumber++;
>> }
>>
>> </code>
>>
>> Esse while pode ficar mais legível assim:
>>
>> <code>
>> .
>> .
>> .
>> $lnumber = 0;
>> while($line = readline($fh)){
>>    if($line =~ m{$keyword}){
>>       print "\nACHEI! - $lnumber";
>>    }
>>    $lnumber++;
>> }
>> .
>> .
>> .
>> </code>
>>
>
> Ou menos legível assim ;-)
>
> <code>
>
> while(<$fh>) {
>   print "\nACHEI! - $." if /$keyword/;
> }
>
> </code>
>

Ou menos legível ainda assim :P

<code>

perl -E 'map{say if $a == 10;++$a }<>' a

</code>


> --
> Alexei Znamensky [russoz_gmail_com] [russoz.wordpress.com] [
> www.flickr.com/photos/alexeiz]
> "Though we live in trying times, we're the ones who have to try"
>
> _______________________________________________
> SaoPaulo-pm mailing list
> SaoPaulo-pm em pm.org
> http://mail.pm.org/mailman/listinfo/saopaulo-pm
>



-- 
http://mantovanihouse.blogspot.com/
This is my poney:
-------(\_------------_/)-----------
-------)--(----------)--(-----------
------(----(---------)----)----------
-------)----(-------)----(-----------
-------(----(-------)----)-----------
--------\_-(\\.---.//)-_/------------
----------\)' -8--8- '(/--------------
-----------/------------\---------------
----------(--)--------(--)--------------
------------(_c__c_)----------------
----------------------------------------
perl -MLWP::Simple -le 'grep{ print $1 if /href="(http.+?)"/}split($/,get("
http://www.perl.org.br"))'
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20090529/10935a90/attachment-0001.html>


More information about the SaoPaulo-pm mailing list