Pb de fichier

Pb de fichier - Perl - Programmation

Marsh Posté le 05-05-2004 à 12:28:50    

Salut a tous.
 
j'aimerais savoir comment lire juste une ligne d'un fichier en l'occurrence la premiere.  
 
Merci.

Reply

Marsh Posté le 05-05-2004 à 12:28:50   

Reply

Marsh Posté le 05-05-2004 à 15:51:13    

truc tout bête :
 

Code :
  1. open(FICHIER, "mon_fichier" );
  2. while(<FICHIER> )
  3. {
  4.     if ($. == 1)   # $. indique le n° de la ligne lue
  5.     { # tu récupères ta ligne ici
  6.     }
  7. }
  8. close(FICHIER);


---------------
Samsung Galaxy S1 -> Samsung Galaxy S2 -> Samsung Note 2 -> Huawei Ascend Mate 7 -> ZTE Axon 7 -> OnePlus 6T -> Oppo Find X2 PRO -> Google Pixel 9 PRO XL
Reply

Marsh Posté le 05-05-2004 à 15:56:12    

my $ligne = <FICHIER> tout simplement

Reply

Marsh Posté le 05-05-2004 à 23:53:02    

Taz a écrit :

my $ligne = <FICHIER> tout simplement


 
en étant un peu plus explicite si le mec connait pas trop trop perl
 

Code :
  1. open(FENT, $monfichier);
  2. my $line = <FENT>;
  3. close FENT;


---------------
http://www.boincstats.com/signature/user_664861.gif
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed