Bonjour,
je souhaiterais recuperer la premiere partie d'une chaine qui peut contenir des chifres ou des lettres sans savoir leur position ou la quantite !
$bonne_partie = catalyst356048PS OBJECT IDENTIFIER ::= { ciscoProducts 564 } -- Catalyst 3750 48 10/100 ports with In-Line Power + 4 Gigabit SFP ports fixed configuration Layer 2/Layer 3 Ethernet Switch.(SFP Small Formfactor Pluggable)
Merci d'avance Jules
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 #!/usr/bin/perl use strict; my $num_cisco; my $bonne_ligne; my $numero="564"; my $Ligne_Fichier; my $bonne_partie; open(Fichier_mib_cisco,"<CISCO-PRODUCTS-MIB.my") || die ("Vérifiez la présence du fichier resultat.txt ou son chemin à la ligne :\n $! "); while ($Ligne_Fichier = <Fichier_mib_cisco>) { $bonne_ligne = $Ligne_Fichier if ( $Ligne_Fichier =~ m/^(.*{ ciscoProducts $numero }.*)$/) ; } $bonne_partie = $bonne_ligne if ($bonne_ligne =~/^(\S)/); print "\n $bonne_partie";
Partager