On Sun, Jan 20, 2002 at 01:18:17PM +0100, fabrice wrote:
> est ce possible de faire une recherche de correspondance sur le contenu d'1 
> handle file dans perl?(je pense que oui

oui !

> j'expilque
> 
> open IPCONFIG,"IPCONFIG.TXT" or die "can't open file:$!";

oui !

> (<IPCONFIG>)=~ /(dhcp)/i;
> print IPCONFIG;

hmmm .... non : <> signifie : une nouvelle ligne dans l'entre. Donc il
te faut un while pour parcourir ton fichier :

while (<IPCONFIG>) {
        print if /dchp/i;
}

ou encore :

while (<IPCONFIG>) {
        if (/dchp/) {
                print;
        }
}

ou meme :


while ($x = <IPCONFIG>) {
        if ($x =~ /dchp/) {
                print "$x";
        }
}

> me donne rien alors que je voudrais par exemple recuperer disons la chaine 
> DHCP

tout ca peut etre mis sur une ligne grace aux flags de perl :

si je veux trouver les lignes qui contiennent 'comme' dans le fichier
village, je fais :

aurora-borealis:/mnt/home/users/khatar$ perl -ne 'print if /comme/' village 
* Travaille comme si tu n'avais pas  besoin d'argent.
* Aime comme si  personne ne t'avait jamais fait  souffrir.
* Danse comme si personne ne  te regardait.
* Chante comme si  personne ne t'=E9coutait.
*Vis comme si  le paradis =E9tait sur terre.
<BR>* Travaille comme si tu n'avais pas &nbsp;besoin d'argent.
<BR>* Aime comme si &nbsp;personne ne t'avait jamais fait
&nbsp;souffrir.
<BR>* Danse comme si personne ne &nbsp;te regardait.
<BR>* Chante comme si &nbsp;personne ne t'=E9coutait.
<BR>*Vis comme si &nbsp;le paradis =E9tait sur terre.
aurora-borealis:/mnt/home/users/khatar$ 

-------------------------------------------------------------
"Advancing  technology  is not as  important as  fighting for
freedom, but it's still a good thing to do."
                                          Richard M. Stallman
[EMAIL PROTECTED]
http://khatar.phear.org
http://www.phear.org (please do not browse with IE)

Vous souhaitez acquerir votre Pack ou des Services MandrakeSoft?
Rendez-vous sur "http://www.mandrakestore.com";

Répondre à