Boucle WHILE qui fonctionne pas (débutant)
Résolu/Fermé
bheadman
Messages postés
105
Date d'inscription
samedi 1 septembre 2007
Statut
Membre
Dernière intervention
17 septembre 2008
-
21 juil. 2008 à 10:00
PeterPeterPeter Messages postés 202 Date d'inscription jeudi 17 juillet 2008 Statut Membre Dernière intervention 22 juin 2010 - 21 juil. 2008 à 10:17
PeterPeterPeter Messages postés 202 Date d'inscription jeudi 17 juillet 2008 Statut Membre Dernière intervention 22 juin 2010 - 21 juil. 2008 à 10:17
A voir également:
- Boucle WHILE qui fonctionne pas (débutant)
- Redmi note 10 redemarre en boucle - Forum Xiaomi
- Formation sap débutant pdf ✓ - Forum Études / Formation High-Tech
- Boucle excel sans macro - Forum Excel
- Boucle cmd - Forum Programmation
- Mon pc s'allume et s'éteint en boucle ✓ - Forum Matériel & Système
5 réponses
bheadman
Messages postés
105
Date d'inscription
samedi 1 septembre 2007
Statut
Membre
Dernière intervention
17 septembre 2008
21 juil. 2008 à 10:01
21 juil. 2008 à 10:01
Voici le code et l'erreur
[root@srv41001 root]# ./test2.pl
syntax error at ./test2.pl line 10, near ") {"
syntax error at ./test2.pl line 15, near "}"
Execution of ./test2.pl aborted due to compilation errors.
[root@srv41001 root]# cat test2.pl #!/usr/bin/perl -w # Open the dump file open(PASSWD,"/etc/passwd") || die "Can't open /etc/passwd...$!\n"; my @listepwd = () # Parse out the lines with ip numbers while ( <PASSWD> ) { chomp; if ( $_ =~ /bin/) { push (@listepwd,$_); } } close(IPNUM); print "@listepwd\n"
[root@srv41001 root]# ./test2.pl
syntax error at ./test2.pl line 10, near ") {"
syntax error at ./test2.pl line 15, near "}"
Execution of ./test2.pl aborted due to compilation errors.
bheadman
Messages postés
105
Date d'inscription
samedi 1 septembre 2007
Statut
Membre
Dernière intervention
17 septembre 2008
21 juil. 2008 à 10:02
21 juil. 2008 à 10:02
et voici le cpde qui fonctionne
[root@srv41001 root]# ./test.pl
Adresse ip : 192.78.90.4
Bcast : 192.78.90.255
Masque : 255.255.255.0
[root@srv41001 root]# cat test.pl #!/usr/bin/perl -w # Generate the IP#, router, and subnet mask by running the "ipconfig" command. # Run ipconfig and dump its contents to ipdump. my @t = (); open(IPNUM,"|ifconfig > ipdump") || die "Can't run 'ifconfig'...$!\n"; close(IPNUM); # Open the dump file open(IPNUM,"ipdump") || die "Can't open ipdump...$!\n"; # Parse out the lines with ip numbers while ( <IPNUM> ) { chomp; if ( $_ =~ /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) { push (@ipconf,split(/\D+/,$_)); } } close(IPNUM); my $IPAdws2; my $SubnetMsk2; my $Router2; $IPAdws2 = join(".",@ipconf[1...4]); $SubnetMsk2 = join(".",@ipconf[5...8]); $Router2 = join(".",@ipconf[9...12]); print "Adresse ip : \t$IPAdws2\nBcast : \t$SubnetMsk2\nMasque : \t$Router2\n"
[root@srv41001 root]# ./test.pl
Adresse ip : 192.78.90.4
Bcast : 192.78.90.255
Masque : 255.255.255.0
PeterPeterPeter
Messages postés
202
Date d'inscription
jeudi 17 juillet 2008
Statut
Membre
Dernière intervention
22 juin 2010
30
21 juil. 2008 à 10:08
21 juil. 2008 à 10:08
my @listepwd = ()
T'as oublié ; :)
T'as oublié ; :)
bheadman
Messages postés
105
Date d'inscription
samedi 1 septembre 2007
Statut
Membre
Dernière intervention
17 septembre 2008
21 juil. 2008 à 10:12
21 juil. 2008 à 10:12
GGGRRRrrr
J'ai du mal avec ces ";" !
MERCI
J'ai du mal avec ces ";" !
MERCI
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
PeterPeterPeter
Messages postés
202
Date d'inscription
jeudi 17 juillet 2008
Statut
Membre
Dernière intervention
22 juin 2010
30
21 juil. 2008 à 10:17
21 juil. 2008 à 10:17
De rien, ça saute aux yeux quand t'en as oublié des centaines :)
Amuse toi bien maintenant !
Amuse toi bien maintenant !