in reply to Shell commands on Win32

Try using backticks` ` until you read more about what Perl built-in's and modules can do for you. You can capture the response into a scalar or an array and then process it using the power of Perl's regular expressions. You can also use the system command if you don't want to process any return stuff from Win32 shell but just want to execute it.
use strict; use warnings; my @shell_rtn_val; print "Enter name of file to copy: "; my $file = <STDIN>; # open STDIN and get input chomp $file; # remove the \n $file =~s /\\/\\\\/g; # Convert to Win32 Shell path sep $file =~s /\//\\\\/g; # Use Unix path's too :-) @shell_rtn_val = `copy $file $file."bak"`; foreach(@shell_rtn_val){ #Let's look for interesting stuff and process it # $_ is implicitly searched for in each if # just like you wrote: $_ =~ m/regex-pattern/ if ( /(\d) file\(s\) copied/ ){ my $num = $1;print "You copied $num files"; } if ( /cannot find/ ){ print "System can't find a file by that name"; } if ( /syntax/ ){ print "Bad syntax"; `copy /?`; } }
There are modules which can make system interaction trivial...like File::Find for instance, or if you want to capture key strokes in Win32 you will need Term::ReadKey. The list is really endless, and the guys in here are smart as all get out.. they only ask that you do some homework and show some code before you ask a question! :) Cheers, James