in reply to Re^3: How Do I Get Batch Input to Work in DOS?
in thread How Do I Get Batch Input to Work in DOS?
Input data file:#! Perl ###################################################################### +######################################### # # input_demo.pl - Requires Active Perl 5.8.9 Or Higher # # ###################################################################### +######################################### #require 5.8.9; # Use Version 5.8.9 of Perl #use lib "D:/Perl_510/lib/core "; use English '-no_match_vars'; use File::Copy; use IO::Handle; use Win32; use Win32::File qw/GetAttributes SetAttributes/; my $runnum = 0; my $program = 1; if( $runnum < 1) { $cwd = Win32::GetCwd(); $prgmdir = $cwd; # $prgmpth = "$prgmdir\\"; print "\nProgram thinks it is located in the following directo +ry:\n"; print "\t$cwd\n"; print "if incorrect (PATH has spaces)! Enter full path or ret +urn\n\n"; chomp ($prgmd = <STDIN>); if( $prgmd =~ /^([a-zA-Z];\\).+$/ ) { $prgmdir = $prgmd; } else { $prgmdir = $cwd; } $prgmdir =~ /^(\w:).*/; $prgmdrv = $1 . ":"; print "\nProgram: $program, leaves you in directory: $prgmdir\t y +our input is: $prgmd \n"; } RECYCLE: print "\nTo quit enter 0\n"; chomp( $program = <STDIN>); #Quit or rerun program if ( $program == 0 ) { exit 1;} goto RECYCLE; #exit 1;
Run Results: Manual run in DOS window:c:\temp 1 1 0
Run with input file:>dos_input_test.pl Program thinks it is located in the following directory: D:\data\Rx Utils if incorrect (PATH has spaces)! Enter full path or return c:\temp Program: 1, leaves you in directory: D:\data\Rx Utils your input is: c:\temp To quit enter 0 1 To quit enter 0 1 To quit enter 0 0
-------end of run data ---------- Your help is most appreciated! Thanks, JMK>dos_input_test.pl < pl_input.txt Program thinks it is located in the following directory: D:\data\Rx Utils if incorrect (PATH has spaces)! Enter full path or return Program: 1, leaves you in directory: D:\data\Utils your input is: To quit enter 0 >
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: How Do I Get Batch Input to Work in DOS?
by BrowserUk (Patriarch) on Mar 02, 2012 at 01:42 UTC |