Hi Stuart,
Thanks for the tricky batch and perl all in the same file script.
This is really fascinating.
What I am looking is sort of the other way around, in that I have a batch
script that I want to make PERL understand.
Does that make sense?
Richard.
From: "stuart arnold" <[EMAIL PROTECTED]>
To: "'Richard Thomas'"
<[EMAIL PROTECTED]>,<[email protected]>
Subject: RE: .bat to .pl
Date: Sun, 4 Sep 2005 09:41:25 -0400
MIME-Version: 1.0
Received: from sccrmhc11.comcast.net ([63.240.76.21]) by
mc6-f10.hotmail.com with Microsoft SMTPSVC(6.0.3790.211); Sun, 4 Sep 2005
06:41:22 -0700
Received: from oak (c-24-99-104-44.hsd1.ga.comcast.net[24.99.104.44])
by comcast.net (sccrmhc11) with SMTP id
<2005090413412101100t0q1ke>; Sun, 4 Sep 2005 13:41:21 +0000
X-Message-Info: JGTYoYF78jEHjJx36Oi8+Z3TmmkSEdPtfpLB7P/ybN8=
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook, Build 10.0.2627
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
Return-Path: [EMAIL PROTECTED]
X-OriginalArrivalTime: 04 Sep 2005 13:41:22.0422 (UTC)
FILETIME=[565DD160:01C5B156]
Ok, I saw various responses, and, if what you want is a "batch" file to
invoke PERL, you cannot do it as ".bat", rather, a very old trick is to
make the fike a ".cmd" and have it assoc'd as a .bat file. (or closely
there of). From a script that someone VERY generously gave me back 15
yrs ago(and I still use) is this:
1) you make it LOOK like a BAT file
2) invoke PERL.
Here's a working snipplet to do HELLO WORLD. I'll walk thru it
afterwords:
@rem = '
@echo off
perl -S %0.cmd
goto endofperl
@rem ';
# this came from A VERY Clever person years ago....(no galaxies)
print "Hello World\n";
exit (0);
# end script.
# these lines required.
__END__
:endofperl
Ok, what this does is tell the BAT file that:
@rem = '
Lets the script(BAT) act as a DOS script.
The other '@' are escaping things,
Then it invokes your PERL script (whatever.cmd)
When PERL invokes this EXACT script, it thinks '@rem' and other stuff
are vars and exits. It then proceedes to execute!
To run this example, just save it (eg thingy.cmd) and type "thingy"
(since .cmd is part of the invocation)
Seriously cool trick (from some JEDI-PERL dude(wich I new who it was) in
a galaxy near you!)
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Richard Thomas
Sent: Sunday, September 04, 2005 7:13 AM
To: [EMAIL PROTECTED]
Cc: [email protected]
Subject: Re: .bat to .pl
Hi,
Thanks for all your replies.
A few points about the batch file I would like to convert is that it has
the
following:
1) labels and goto's
2) if statements
3) variables
I tried the first suggestion on the following batch file that uses
labels
and gotos:
goto.bat
======
:begin
echo hello world
goto begin
goto.pl
=====
use strict;
use warnings;
my $command;
$command=':begin';
system ($command);
$command='echo hello world';
system ($command);
$command='goto begin';
system ($command);
This shows that it's not just about transferring the commands from .bat
to
.pl.
What's needed is something that understands DOS batch labels and goto's,
if
statements and variables.
Would it still be helpful if I got the actual batch file I am would like
to
convert?
I WHISH I had written it in PERL to begin with........
Thanks,
Richard.
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Richard Thomas
Sent: Saturday, September 03, 2005 4:22 PM
To: [email protected]
Subject: .bat to .pl
Hi,
Does anyone know of a way to convert an MS-DOS batch script (.bat) into
a
PERL script (.pl) automatically, without having to start writing the
PERL
script from scratch?
Thanks in advance
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs