I have even built a module, building on the work of others, that allows you
to use the actual DOS (NT) command as a built-in perl function, i.e.:

copy("file1.txt file2.txt");

The code for the module is as follows:

# Dos.pm 11/24/2000.
# This package will execute Dos shell commands transparently within perl.

package Dos;

# Define pragmas.
use diagnostics;
use English;
use warnings;

sub import()
{
    my $Self = shift;
    my $Caller = caller();
    my @EXPORT = ();
    if (@_) {@EXPORT = @_;}
    else {@EXPORT = 'AUTOLOAD';}
    foreach (@EXPORT)
    {
        # Create a reference in the calling package's symbol table to the
        # names that are exported from this package.
        *{"${Caller}::$_"} = \&{"Dos::$_"};
    }
}

sub AUTOLOAD()
{
    my $Cmd = $AUTOLOAD;
    # Remove the package name from the command.
    $Cmd =~ s/.*:://;
    # Get the command arguments.
    my $Arg = shift;
    # Change all "/" to "\".
    $Arg =~ s/\//\\/g;
    # Change all "!" to "/".
    $Arg =~ s/!/\//g;
    print("\n$Cmd $Arg\n");
    system($Cmd,$Arg);
}

# Package return value.
return(1);

In your script, use:

use Dos:

I find this method very handy.

Dirk Bremer - Systems Programmer II - AMS Department - NISC
636-922-9158 ext. 652 fax 636-447-4471

<mailto:[EMAIL PROTECTED]>

----- Original Message -----
From: "Quinn, Colleen" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "Christophe Lejeune" <[EMAIL PROTECTED]>; "'Bill Duncan'"
<[EMAIL PROTECTED]>
Sent: Thursday, January 04, 2001 5:04 PM
Subject: RE: Changes in filenames & regular expressions in Win95


> I have found a lot of success w/NT w/rather a bare implementation;
> system set; #shows ENV variables
> system pause; #pauses
> system cls;       #clear the screen
> OR even....
> system "xcopy *.* c:\\build_proj /s >bom.txt"; #for a bom / bill of
> materials for a build.
>
> TMTOWTDI - always
> > Colleen Quinn
> > SHARP LABORATORIES OF AMERICA, INC
> > SCM Engineer
> > Digital Imaging Systems
> > 360-817-8516


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activeperl

Reply via email to