File "expression_ancien3.pl"
Full Path: /home/analogde/www/XTRAIL/andre/PERL/expression_ancien3.pl
File size: 1.81 KB
MIME-type: text/x-perl
Charset: 8 bit
#!/usr/bin/perl
use OLE;
use Spreadsheet::WriteExcel;
@tablo = ("Barney", "Homer", "Marge", "Bart", "Lisa", "Maggie", "Moe", "Flanders");
@table = ();
$table[0]='3trois';
$table[1]='1un';
$table[2]='2deux';
$table[3]='4quatre';
@tri=sort(@table);
print $tri[0];
print "\n";
print $tri[1];
print "\n";
print $tri[2];
print "\n";
print $tri[3];
print "\n";
$taille=@table;
print "le tableau comporte $taille cases \n";
excel();
##############################################################
sub excel
{
$xl_file ="i:\\workarea\\perl\\test.xls";
# OLE - Excel Connexion
# Creation d'un objet OLE - Pointeur d'application Excel
$xl_appli = CreateObject OLE 'Excel.Application' || die $!;
# paramtrage
# 0 = non visible
# 1 = visible
$xl_appli->{'visible'} = 0;
# ouvre un fichier Excel
$workbook = $xl_appli->Workbooks->Open($xl_file);
# active la feuille de travail
$worksheet = $workbook->Worksheets(1);
# revoie des valeurs
$cellA2 = $worksheet->Range("A2")->{'Value'};
$cellB1 = $worksheet->Range("B1")->{'Value'};
my $array = $worksheet->Range("A1:A10")->{'value'};
foreach my $ref_array (@$array)
{
foreach my $scalar (@$ref_array)
{ print "$scalar\t";
}
print "\n";
}
# fermeture
$xl_appli->ActiveWorkbook->Close(0);
$xl_appli->Quit();
}
##############################################################
sub recherche
{
print "Quel nom voulez-vous reprer ?\n";
$nom = <stdin>;
chomp $nom;
for ($i=0; $i<@tablo; $i++){
if($tablo[$i] =~ /$nom/){
print "$nom est en position $i\n";
}
}
$chaine = "L'ge du capitaine est de 28 ans.";
if($chaine =~ /\d+/){
print "L'ge est $& ans\n";
}
}
##############################################################