Prob Perl/Tk

O

Orion93

From the script below I try to make an interface in Perl/Tk to be able to
choose the repertory directly. The initial script count lines for all pl
files in one directory.

Initial Script:
#!/usr/bin/perl
sub recupPages
{
my $nomFic = shift;
my $result = shift;

# Récupération des lignes du fichier
open(F,$nomFic);
open(SORTIE,">> $result");
$i = 0;
while(<F>)
{
$i ++;
}
print SORTIE " $nomFic $i\n";

close F;
close SORTIE;}

my $emplacement = "e:\\Dossier_travail\\stat\\";
my $ficResultat = "e:\\result.txt";
recupPages($_, $ficResultat) for glob 'e:\\Dossier_travail\\stat\\*.pl';


Current script:

#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use diagnostics;

my $main = MainWindow -> new;
$main -> title("Test 1");
$main -> Label(-text=>"Chemin:")->pack();
$main -> Entry()->pack(-padx=>5);
$main->Button(-text=>'Ok',-command=>\my $recupPages)->pack(-side=>'left',
expand=>1);
$main->Button(-text=>"Fermer",-command=>sub {exit;})->pack(-side=>'right',
expand=>1);
MainLoop();

sub recupPages
{
# my $rep= my $resupPages->get();
my $result = shift;
# Récupération des lignes du fichier
open (F,"$recupPages");
open (SORTIE,">> my $result");
my $i = 0;
while(<F>)
{
$i ++;
}
print SORTIE " my $recupPages $i\n";
close F;
close SORTIE;
}
#my $emplacement = @rep;
my $ficResultat = "e:\\result.txt";
recupPages($_, $ficResultat) for glob '$nomFic\*.pl';

I don't understand where are my errors! Please Help me again!
 
T

Tulan W. Hu

Orion93 said:
$main->Button(-text=>'Ok',-command=>\my $recupPages)->pack(-side=>'left',
expand=>1);
?????
what is '-command=>\my $recupPages' ?
check syntax.
-command => sub {...}
-command => &sub_name
-command => [....]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top