gammaman64
Programmer
I need the following segment of code to have the system look at the file which the user types into the entry widget. The only thing it does write now is store the click into a variable. I know it doesnot work because when executed there is no output on the dos window. Please help.
sub check {
my $check = $mw->DialogBox(
-background => 'red',
-title => 'Type the file you wish to check',
-buttons => [ 'OK', 'Cancel' ],
-default_button => 'OK',
);
my $txt;
my $entry = $check->Entry (
-textvariable => \$txt,
)->pack;
my $click = $check->Show();
return unless $click eq 'OK';
foreach $txt (@ARGV){
print ("Checking $txt\n");
if (-f $txt)
{
print ("The file $txt is:");
print ("readable")if(-r $txt);
print ("writable")if(-w $txt);
print ("executable") if (-x $txt);
}
elsif (-d $txt)
{
print ("$txt is a directory");
my @time = timeconv(-A $txt);
print "The file was last accessed at $time[0] days, ",
"$time[1] hours, $time[2] minutes ",
"and $time[3] seconds.\n";
}
}
}
sub timeconv{
my $time = shift();
my $days = int ($time);
$time = ($time - $days) * 24;
my $hours = int ($time);
$time = ($time - $hours) * 60;
my $minutes = int ($time);
$time = ($time - $minutes) * 60;
my $seconds = int ($time);
return ($days, $hours, $minutes, $seconds);
}
sub check {
my $check = $mw->DialogBox(
-background => 'red',
-title => 'Type the file you wish to check',
-buttons => [ 'OK', 'Cancel' ],
-default_button => 'OK',
);
my $txt;
my $entry = $check->Entry (
-textvariable => \$txt,
)->pack;
my $click = $check->Show();
return unless $click eq 'OK';
foreach $txt (@ARGV){
print ("Checking $txt\n");
if (-f $txt)
{
print ("The file $txt is:");
print ("readable")if(-r $txt);
print ("writable")if(-w $txt);
print ("executable") if (-x $txt);
}
elsif (-d $txt)
{
print ("$txt is a directory");
my @time = timeconv(-A $txt);
print "The file was last accessed at $time[0] days, ",
"$time[1] hours, $time[2] minutes ",
"and $time[3] seconds.\n";
}
}
}
sub timeconv{
my $time = shift();
my $days = int ($time);
$time = ($time - $days) * 24;
my $hours = int ($time);
$time = ($time - $hours) * 60;
my $minutes = int ($time);
$time = ($time - $minutes) * 60;
my $seconds = int ($time);
return ($days, $hours, $minutes, $seconds);
}