Here's how I would write this -- I don't know if it will work, but you might try
it...

#!perl
use strict;
use warnings;

my $done = 0;
while(!done) {
        display_menu();
        print "==> ";
        my $choice = <>;
        chomp $choice;
        if ($choice eq '00') { $done++; }
        elsif ($choice eq '01') { ; } # do stuff in these brackets
                # and so on...
        elsif ($choice eq '31') {
                print "Copying files...\n";
                my $source = "c:/webstaff3/aliases/";
                my $dest = "c:/last weeks updates/aliases/";
                my $cmd = "xcopy \"$source\" \"$dest\" /Y";
                print "(running '$cmd')\n";
                my $result = system($cmd);      # yes, this isn't quite the same
                                                # as the output from
backticks...
                print "returned: $result\n";
        } else {
                print "Invalid choice: please select again\n";
        }
}

__END__

Actually, though, I would probably bypass the system commands anyways.  If you
know that there are no subdirectories that you are copying, try this (adding in
error checking as needed):

        my $source_dir_text = "c:/webstaff3/aliases/";
        my $dest_dir_text = "c:/last weeks updates/aliases/";
        opendir(my $source_dir, "c:/webstaff3/aliases/");
        my @files = grep { -f "$source_dir_text$_" } readdir $source_dir;
        closedir($source_dir);
        foreach my $file (@files) {
                rename "$source_dir_text$file" "$dest_dir_text$file";
        }

Or, if there are subdirectories, I think there are a bunch of modules on CPAN
that will do what you need...

HTH,
Ricky


-----Original Message-----
From: Mike Reilley [mailto:[EMAIL PROTECTED]]
Sent: Tuesday 07 May 2002 10:40 AM
To: $Bill Luebkert; Carl Jolley; Toby Stuart;
[EMAIL PROTECTED]
Subject: Simple Menu


Sorry I meant to include the fact that I am running
ActivePerl  5.6.0 Build 613
on Windows 98 SE

CODE:

$| = 1; # UNBUFFER THE CONSOLE
while () { 
scrprt();
my $result = <STDIN>;
        chomp $result;
        exit 0 if $result == 0;
if ($result == 31) {  
        print "Copying Files\n\n";
                #$cmd = "xcopy32.exe ";
                $cmd = "xcopy ";
        $cmd = $cmd."\"c:\\webstaff3\\aliases\" ";
        $cmd = $cmd."\"c:\\last weeks updates\\aliases\" /y " ;
        print "CMD == $cmd\n";
        $output = `$cmd`;
        print "output == $output\n";
                           }

         }

        
sub scrprt {
        #system "$ENV{COMSPEC} /C CLS\n";
        print "                    \n";
        print "                    \n";
        print " 00 .. Terminate Menu \n";
        #print "                    \n";
        #print "                    \n";
        print " 31 .. Copy Web files to Last Weeks\n";
        print " \n";
        print " \n";
        print " ";
}
        

It has recently  come to my attention that some people consider my use of
uppercase letters in email as obnoxious, I would like to apologize but in light
of having lost 6 fingers and the use of a seventh that leaves me with just a
thumb and pinky on my left hand and only a thumb on my right hand. Therefore
nothing is meant or implied by my haphazard capitalization.


Mike Reilley
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to