Mike Flannigan wrote:

> I was wondering if you could help me get this script
> tied to one of my Perl programs on my Win2000 box.
> After much experimentation, I've changed the line
> open(C, "./read-own-stdout-piper 2>&1 |") or warn $!;
> to
> open(C, "round2.bat 2>&1 |") or warn $!;
>
> round2.bat is a DOS batch file with a single line:
> perl round2.pl    # (that is the way I run perl programs)
>
> round2.pl has:
>
> use strict;
> use warnings;
> my $number = 5.6278;
> my $rounded = sprintf '%.2f', $number;
> print "$rounded\n";
> $|++;                           # << SHOULD THIS LINE BE HERE?
>
> AND IT ALL WORKS!
>
> I can't just do
> open(C, "round2.pl 2>&1 |") or warn $!;
> because then it just opens round2.pl in my text editor,

> since that is the association I have ".pl" set to.

Why?!?!  Why screw with something that works, unscrewed with, just fine?  The
asscociations set up
by the ActivePerl install are the appropriate ones for making Perl run.  If you
want associations to your
preferred editor, then:
Open Windows Explorer, or the abonminable kindergarten version My Computer
Click Folder Options on the Tools menu
Select File types
Find the PL extension.
Click the Advanced button.
Restore the Open association with the perl executable.  The Open action should
read:

"C:\Perl\bin\perl.exe" "%1" %*

presuming that Perl is installed to the default location for Windows

Create an Edit action tied to your editor.

Changing the primary association is a bad hack, and a bad habit to be in as you
start learning a programming
language.

Actually, once you right-click on any registered file type in Win2K, and use the
Open with... option option to
select an alternate handler, that handler will thereafter be available on a list
under the Open with menu item.

In brief, there is no good reason to mess with a working file association

>  I tried
> open(C, "'perl round2.pl' 2>&1 |") or warn $!;
> but that didn't work either.

open(C, "perl round2.pl 2>&1 |") or warn $!;
or simply:
open(CHILD, "perl round2.pl | ") or warn "Could not open pipe from child
process: $!";

>
> That "Got:" prompt isn't too cool,  but I'm sure I'll
> learn how to turn that off later.
>
> Also, it's unfortunate that copy and paste don't work
> in that TK box.

If it is a Text widget, copy and paste will indeed work.  Can you provide more
detail on
why you think it doesn't?

> Anyway, thanks a bunch.  If there are other posts
> on the NG related to this, I'll see them when I get
> home.
>
> Mike Flannigan
> Houston, TX

Mike, I think you have a conceptual problem here.  Seeking STDIN from a GUI
widget, hacking
and breaking working file associations, etc.  indicate a bad habit that will
hobble your programming
efforts if unaddressed.  *Let working systems be*, don't fix what ain't broke.

Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to