[25634] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7876 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 10 18:05:51 2005

Date: Thu, 10 Mar 2005 15:05:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 10 Mar 2005     Volume: 10 Number: 7876

Today's topics:
    Re: cant display generated html in browser (perl script <nobull@mail.com>
    Re: DBI and Microsoft Access nathaniel_welch@hotmail.com
    Re: Faster way to execute contents of a perl script? <bhoppe@ti.com>
    Re: Faster way to execute contents of a perl script? <bhoppe@ti.com>
    Re: Faster way to execute contents of a perl script? (Walter Roberson)
    Re: Faster way to execute contents of a perl script? <jgibson@mail.arc.nasa.gov>
    Re: Faster way to execute contents of a perl script? <bhoppe@ti.com>
    Re: Faster way to execute contents of a perl script? (Walter Roberson)
    Re: file name in perl script? (Nico)
        forms suddenly stopped working <bspratt@yahoo.com>
    Re: forms suddenly stopped working <1usa@llenroc.ude.invalid>
    Re: forms suddenly stopped working <sbryce@scottbryce.com>
    Re: gtk + png <zentara@highstream.net>
    Re: HTML::Parser - duplicated text in <h2> .. </h2> ? <geoff.cox@notquitecorrectfreeuk.com>
    Re: include external perl program <nobull@mail.com>
        Module should not work, but works (Bart Van der Donck)
    Re: Module should not work, but works <krevlar.newsgroups@tragetaschen.dyndns.org>
    Re: Module should not work, but works <matternc@comcast.net>
    Re: Module should not work, but works <noreply@gunnar.cc>
    Re: One Liner to reverse sort file <jl_post@hotmail.com>
    Re: Using dot commands in a script <danfperl@yahoo.com>
    Re: Using dot commands in a script <1usa@llenroc.ude.invalid>
    Re: Win32::TieRegistry Logon User Name <jairagoo@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 10 Mar 2005 18:57:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: cant display generated html in browser (perl script)
Message-Id: <d0q4va$jkc$1@sun3.bham.ac.uk>



Piet L. wrote:

> Brian McCauley <nobull@mail.com> wrote in message news:<d0mshq$188$1@sun3.bham.ac.uk>...
> 
>>Piet L. wrote:
>>
>>
>>>>Anyhow this is not the 'right' way to use XSL on the web.  You should 
>>>>simply put a processing instruction in the XML to tell the browser where 
>>>>to fetch the XSLT.
>>>
>>>How do I do that?
>>
>>The processing instruction looks something like this:
>>
>>   <?xml-stylesheet href="whatever.xsl" type="text/xsl"?>
>>
>>How you put such a processing instruction into an XML document would 
>>depend on the tools you are using to generate the XML document.
> 
> Actually my script is like this:
> # create a DBI connection
> my $dbh = DBI->connect("DBI:mysql:myDB",$user,$login);
> 
> # instantiate a new XML::Handler::YAWriter object
> my $handler   = XML::Handler::YAWriter->new(AsString => "-",
> 				Pretty => {PrettyWhiteNewline => 1,
> 					   PrettyWhiteIndent => 1,
> 					   CatchEmptyElement => 1,
> 					   NoProlog => 1});
> my $generator = XML::Generator::DBI->new(
>    Handler => $handler,
>    dbh     => $dbh,
>    Indent  => 1
> );
> 
> my $ select = qq(.....);
> my $xml = $generator->execute($select);
> $dbh->disconnect ();

> So I now have the following questions,
> hope you can answer them.

No, I don't know everything.

> - How do I put your answer in?

You are using SAX.  Sax is a piplining system that works on a serialised 
document tree one bit at a time as a series of events.  You need to 
insert another SAX handler between your XML::Generator::DBI and your 
XML::Handler::YAWriter.

So where now you have

 > my $generator = XML::Generator::DBI->new(
 >    Handler => $handler, # etc
 > );

You will need something like

   my $filter = XML::Filter::PrependProcessingInstruction->new(
     Handler => $handler,
     Instruction => {
       Target => 'xml-stylesheet',
       Data => qq(href="$stylesheet" type="text/xsl"),
     },
   );

   my $generator = XML::Generator::DBI->new(
     Handler => $filter, # etc...
   );

Of course I don't suppose there really is a module called 
XML::Filter::PrependProcessingInstruction but I would be a little 
supprised if there was no SAX module on CPAN that could serve this function.

If not you could always write your own by deriving from XML::SAX::Base 
and overriding start_element to insert a processing_instruction event 
into the stream before the first start_element event that follows the 
start_document event.

I could write this for you, but I've never used XML-SAX and there's no 
point me reading the manuals and building a test harness when I could 
leave that to you.

To get you started, at a guess, and I mean a *guess*, it would look a 
bit like this...

   package XML::Filter::PrependProcessingInstruction;
   use base 'XML::SAX::Base';

   sub start_element {
     my $self = shift;
     $self->processing_instruction($self->{Instruction})
        unless $self->{Seen_start_element}++;
     $self->SUPER::start_element(@_);
   }

   sub start_document {
     my $self = shift;
     delete $self->{Seen_start_element};
     $self->SUPER::start_document(@_);
   }


> - How will it then be displayed in a browser?

Exactly the same as it would if you'd performed the XSL transformation 
server-side.   Give or take bugs in the XSLT engines and anything in 
your XSLT that is ambiguous.

> Do I need an extra command in my script or so?

You need to change the Content-type from 'text/html' to 
'application/xml' or 'text/xml; charset="utf-8"'. Use the 'application' 
content type if your raw XML is not intended to be human-readble and the 
'text' one if you have tried to make your raw XML readable (see RFC3023 
for details).

You do, of course, also need to put the XSL into a directory where it 
can be fetched with a URL (preferably a relative one).  Ideally your web 
server should be configured to serve up documents with a .xsl extension 
as content-type 'application/xslt+xml' but in practice this rarely 
matters.

I don't fully understand why the PI has type="text/xsl" rather than 
type="application/xslt+xml" but all this is really getting very OT for a 
Perl newsgroup.



------------------------------

Date: 10 Mar 2005 13:53:43 -0800
From: nathaniel_welch@hotmail.com
Subject: Re: DBI and Microsoft Access
Message-Id: <1110491623.695799.47000@f14g2000cwb.googlegroups.com>

> What happens when you remove $dbh = DBI->connect("dbi:ODBC:recruit");

> from your code?

 When I remove or comment that line, the code works fine.  It prints
test1 and then test2 to the screen.

And, by the way, the error doesn't change whether I use single or
double quotes around the arguments for the connect.


>
> Len
>
> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet
News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World!
120,000+ Newsgroups
> ----= East and West-Coast Server Farms - Total Privacy via Encryption
=----



------------------------------

Date: Thu, 10 Mar 2005 13:22:27 -0600
From: Brandon Hoppe <bhoppe@ti.com>
Subject: Re: Faster way to execute contents of a perl script?
Message-Id: <d0q6pj$4a2$1@home.itg.ti.com>



Jim Gibson wrote:
> In article <d0q1s7$1h9$1@home.itg.ti.com>, Brandon Hoppe
> <bhoppe@ti.com> wrote:
> 
> 
>>Hi,
>>
>>I'm trying to find a faster way to do this. Right now I have a perl script
>>that contains 
>>function definitions. I have second perl script that contains calls to these
>>functions.
>>
>>Now the first perl script will execute the second perl script hundreds of
>>times, in order 
>>to call these functions.
>>
>>So I have a loop that repeatadly changes global variables and then executes
>>the second 
>>perl script with a do $file; call.
>>
>>This works and all, but its not very fast. It takes about 1 1/2 seconds to
>>execute the 
>>second script, so over hundreds of runs, you can see why it takes forever.
>>
>>I was wondering if there's a faster way to repeatedly re-call all these
>>functions. Like 
>>reading the second script into an array and then "executing" the array. I
>>doubt this is 
>>possible but I was thinking something along this line, to get the file into
>>memory to 
>>execute over and over again which should be faster than to be reading from disk everytime.
> 
> 
> There is no need to repeatedly 'do' the second file containing
> subroutines. After this has been done once, the subroutines may be
> called multiple times by name. Just make sure all of the code you wish
> to execute is really in a subroutine and not on the main branch in the
> second file.

The second file doesn't contain the subroutines, it contains CALLS to the subroutines. 
That's why I have to keep 'do'ing the second file so that it calls the subroutines for me.


------------------------------

Date: Thu, 10 Mar 2005 13:34:07 -0600
From: Brandon Hoppe <bhoppe@ti.com>
Subject: Re: Faster way to execute contents of a perl script?
Message-Id: <d0q7ff$4p9$1@home.itg.ti.com>



Walter Roberson wrote:
> In article <d0q1s7$1h9$1@home.itg.ti.com>,
> Brandon Hoppe  <bhoppe@ti.com> wrote:
> :I'm trying to find a faster way to do this. Right now I have a perl script that contains 
> :function definitions. I have second perl script that contains calls to these functions.
> 
> :Now the first perl script will execute the second perl script hundreds of times, in order 
> :to call these functions.
> 
> :So I have a loop that repeatadly changes global variables and then executes the second 
> :perl script with a do $file; call.
> 
> Don't do that. Use 'use' instead to bring the functionality in once, and then
> just call upon the routines at need. Don't worry, the global variable values that
> will be picked up will be those at execution time, not those at compile time.
> 
> Read the documentation on 'use'; also I suggest you might as well go as far as
> formatting it into a "module" -- perldoc perlmod
> 

Perhaps an example will help to visualize the problem:

#MAIN PERL SCRIPT
#!/usr/local/perl

while(<INPUT>) {
    # read some value from INPUT
    $VALUE = $_;

    do "file.pl";
}

sub function1 {
    # do something
}

sub function2 {
    # do something
}


#FILE.PL SCRIPT
if($VALUE eq "A") {
    &function1(34, 44, 33);
    &function2(22, 33, 44);
}
if($VALUE eq "B") {
    &function1(34, 44, 33);
    &function2(22, 33, 44);
}


As you can see, the main perl script has the subroutine definitions. Now based on some 
logic, the main script will execute either scriptA or scriptB, which just has calls to the 
subroutines.

Scripts A and B are used elsewhere in another flow, so I don't want to modify these files 
or compile them since that would change their behavior. This main perl script is a QUALITY 
CONTROL script that verifies that Scripts A and B have valid data.

I hope I've given enough information as to what I'm needing to do.


------------------------------

Date: 10 Mar 2005 20:27:25 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Faster way to execute contents of a perl script?
Message-Id: <d0qajd$lcj$1@canopus.cc.umanitoba.ca>

In article <d0q7ff$4p9$1@home.itg.ti.com>,
Brandon Hoppe  <bhoppe@ti.com> wrote:
:Perhaps an example will help to visualize the problem:

:As you can see, the main perl script has the subroutine definitions. Now based on some 
:logic, the main script will execute either scriptA or scriptB, which just has calls to the 
:subroutines.

:Scripts A and B are used elsewhere in another flow, so I don't want to modify these files 
:or compile them since that would change their behavior.

I'm not sure why you say that compiling them would change their behaviour?

Perhaps you could proceed as follows:

sub make_sub($$) {
  my ($subname, $filename) = @_;
  open( SUB, $filename ) or die "Cannot find subroutine file $filename\n";
  local $\;
  $subfilecontent = <SUB>;
  close( SUB );
  eval "sub $subname() { $subfilecontent }";
}


This creates a subroutine on the fly that is does whatever the
given file would do, by importing the content of that file.
-- 
Usenet is like a slice of lemon, wrapped around a large gold brick.


------------------------------

Date: Thu, 10 Mar 2005 13:51:12 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Faster way to execute contents of a perl script?
Message-Id: <100320051351123578%jgibson@mail.arc.nasa.gov>

In article <d0q7ff$4p9$1@home.itg.ti.com>, Brandon Hoppe
<bhoppe@ti.com> wrote:

> Walter Roberson wrote:
> > In article <d0q1s7$1h9$1@home.itg.ti.com>,
> > Brandon Hoppe  <bhoppe@ti.com> wrote:
> > :I'm trying to find a faster way to do this. Right now I have a perl script
> > :that contains 
> > :function definitions. I have second perl script that contains calls to
> > :these functions.
> > 
> > :Now the first perl script will execute the second perl script hundreds of
> > :times, in order 
> > :to call these functions.
> > 
> > :So I have a loop that repeatadly changes global variables and then
> > :executes the second 
> > :perl script with a do $file; call.
> > 
> > Don't do that. Use 'use' instead to bring the functionality in once, and
> > then
> > just call upon the routines at need. Don't worry, the global variable
> > values that
> > will be picked up will be those at execution time, not those at compile
> > time.
> > 
> > Read the documentation on 'use'; also I suggest you might as well go as far
> > as
> > formatting it into a "module" -- perldoc perlmod
> > 
> 
> Perhaps an example will help to visualize the problem:
> 
> #MAIN PERL SCRIPT
> #!/usr/local/perl

   do 'file.pl';

> 
> while(<INPUT>) {
>     # read some value from INPUT
>     $VALUE = $_;
> 
>     do "file.pl";

replace the above line with:

      call_functions();

> }
> 
> sub function1 {
>     # do something
> }
> 
> sub function2 {
>     # do something
> }
> 
> 
> #FILE.PL SCRIPT

Is it FILE.PL or file.pl? Case matters.

sub call_functions
{

> if($VALUE eq "A") {
>     &function1(34, 44, 33);
>     &function2(22, 33, 44);
> }
> if($VALUE eq "B") {
>     &function1(34, 44, 33);
>     &function2(22, 33, 44);
> }

}

> 
> 
> As you can see, the main perl script has the subroutine definitions. Now
> based on some 
> logic, the main script will execute either scriptA or scriptB, which just has
> calls to the 
> subroutines.
> 
> Scripts A and B are used elsewhere in another flow, so I don't want to modify
> these files 

These don't look like scripts to me. FILE.PL contains some statements
that can be executed. You either have to modify FILE.PL or duplicate
its functionality in another file. There may be a way to compile
FILE.PL once and call it many times from an external program, but I
don't know what it is.

> or compile them since that would change their behavior. This main perl script
> is a QUALITY 
> CONTROL script that verifies that Scripts A and B have valid data.
> 
> I hope I've given enough information as to what I'm needing to do.

I hope I've given enough information as to what I'm recommending. If
you can't change FILE.PL, I don't have a solution.


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---


------------------------------

Date: Thu, 10 Mar 2005 16:19:04 -0600
From: Brandon Hoppe <bhoppe@ti.com>
To: Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca>
Subject: Re: Faster way to execute contents of a perl script?
Message-Id: <4230C7D8.4010102@ti.com>



Walter Roberson wrote:
> In article <d0q7ff$4p9$1@home.itg.ti.com>,
> Brandon Hoppe  <bhoppe@ti.com> wrote:
> :Perhaps an example will help to visualize the problem:
> 
> :As you can see, the main perl script has the subroutine definitions. Now based on some 
> :logic, the main script will execute either scriptA or scriptB, which just has calls to the 
> :subroutines.
> 
> :Scripts A and B are used elsewhere in another flow, so I don't want to modify these files 
> :or compile them since that would change their behavior.
> 
> I'm not sure why you say that compiling them would change their behaviour?
> 
> Perhaps you could proceed as follows:
> 
> sub make_sub($$) {
>   my ($subname, $filename) = @_;
>   open( SUB, $filename ) or die "Cannot find subroutine file $filename\n";
>   local $\;
>   $subfilecontent = <SUB>;
>   close( SUB );
>   eval "sub $subname() { $subfilecontent }";
> }
> 
> 
> This creates a subroutine on the fly that is does whatever the
> given file would do, by importing the content of that file.

Bingo! I was trying to do this earlier but couldn't figure out how to create a new 
subroutine to include everything in the subfile.

Only thing is that I had to change this  line:

$subfilecontent = <SUB>;

to

@subfilecontent = <SUB>;

Thanks!


------------------------------

Date: 10 Mar 2005 22:55:53 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Faster way to execute contents of a perl script?
Message-Id: <d0qj9p$27q$1@canopus.cc.umanitoba.ca>

In article <d0qajd$lcj$1@canopus.cc.umanitoba.ca>,
Walter Roberson <roberson@ibd.nrc-cnrc.gc.ca> wrote:
:Perhaps you could proceed as follows:

:sub make_sub($$) {
:  my ($subname, $filename) = @_;
:  open( SUB, $filename ) or die "Cannot find subroutine file $filename\n";
:  local $\;

That should be  local $/;  instead.

:  $subfilecontent = <SUB>;
:  close( SUB );
:  eval "sub $subname() { $subfilecontent }";
:}
-- 
   "No one has the right to destroy another person's belief by
   demanding empirical evidence."            -- Ann Landers


------------------------------

Date: 10 Mar 2005 13:23:00 -0800
From: noordhoeknd@hotmail.com (Nico)
Subject: Re: file name in perl script?
Message-Id: <4664273a.0503101323.430ea308@posting.google.com>

Hello Martin,
Thanks again for your advice, it worked!
It's like an old Dos command.
I know what the script is doing, its converting records from a
database format to an other database format. The script has 565 lines,
that's why I only send the first lines, I knew that I only needed to
know how to start the script, and were to put the results, I did not
found the answers in handbooks...
This line: "$outputdir='output';", was a suggestion from an other on
this list.
I apologize for my poor English.

Best regards,
Nico


Martin Kissner <news@chaos-net.de> wrote in message news:<slrnd30aob.9do.news@maki.homeunix.net>...
> Nico wrote :
> 
> Please read http://learn.to/quote to learn how to properly quote in
> usenet. - Thank you.
> 
> > Hi Martin,
> > Thanks for you advice, I can now see the script working and making the
> > changes,however, I can not find the result?
> > I think there must be another command to put the result in a output
> > directory?
> > EI2.pl c:/path/editme.txt ..?
> > I tried this in the script, "$outputdir='output';",but it did not
> > work.
> 
> I think it's a waste of time and effort to add code you do not
> understand (or somthing that looks like code) to a script which you do
> not understand.
> It's like soldering some cables into a TV which does not show the
> desired program, without any clues of electronics.
> 
> > I guess that I must type something at the command line.
> 
> This might be or might not be true.
> If you see the results in the commandline window try
> 
> 	EI2.pl c:/path/editme.txt > c:/path/result.txt
> 
> This is how it would work on Unix then; I have no idea if this works on
> windows, since I do not use it.
> 
> > The creator of the scripts can not be found, otherwise...
> ?
> 
> Best regards
> Martin


------------------------------

Date: 10 Mar 2005 13:47:54 -0800
From: "Bill" <bspratt@yahoo.com>
Subject: forms suddenly stopped working
Message-Id: <1110491274.620222.171670@l41g2000cwc.googlegroups.com>

We have 3 simple submission forms on our website that have worked great
for at least two years. Nothing has changed to my knowledge.  Suddenly
nothing is being delivered. When you send the form in IE the debugger
pops up and points to the following line within the form:  <form
method="post" action="cgi-bin/formmail.pl" onsubmit="return
validateForm(this)">  "object expected or not found"  This is not an
SMTP issue - verified. We were using Matts formmail; so I tried the NMS
formmail (more secure) - the same problem occurred with it also so we
know its not a formmail issue. It must be our actual html (xhtml)
forms. Anyone see anything wrong with the above code? Anything else I
can do to narrow down the issue within the form?  Thanks - Bill



------------------------------

Date: Thu, 10 Mar 2005 21:51:49 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: forms suddenly stopped working
Message-Id: <Xns9615AB8C2CDEEasu1cornelledu@127.0.0.1>

"Bill" <bspratt@yahoo.com> wrote in news:1110491274.620222.171670
@l41g2000cwc.googlegroups.com:

> We have 3 simple submission forms on our website that have worked great
> for at least two years. Nothing has changed to my knowledge.  Suddenly
> nothing is being delivered. When you send the form in IE the debugger
> pops up and points to the following line within the form:  <form
> method="post" action="cgi-bin/formmail.pl" onsubmit="return
> validateForm(this)">  "object expected or not found"  

This group is for discussing Perl only.

Javascript/HTML questions belong in the appropriate groups.

Sinan.


------------------------------

Date: Thu, 10 Mar 2005 14:57:16 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: forms suddenly stopped working
Message-Id: <_sadnU5QhYQmX63fRVn-hg@comcast.com>

Bill wrote:

> We have 3 simple submission forms on our website that have worked great
> for at least two years. Nothing has changed to my knowledge.  Suddenly
> nothing is being delivered. When you send the form in IE the debugger
> pops up and points to the following line within the form:  <form
> method="post" action="cgi-bin/formmail.pl" onsubmit="return
> validateForm(this)">  "object expected or not found"  This is not an
> SMTP issue - verified. We were using Matts formmail; so I tried the NMS
> formmail (more secure) - the same problem occurred with it also so we
> know its not a formmail issue. It must be our actual html (xhtml)
> forms. Anyone see anything wrong with the above code? Anything else I
> can do to narrow down the issue within the form?  Thanks - Bill

It looks to me like a JavaScript problem. You will get better answers in 
a JavaScript newsgroup. When you ask your question there, include the 
URL of the web page, so they can see your code.



------------------------------

Date: Thu, 10 Mar 2005 14:23:40 -0500
From: zentara <zentara@highstream.net>
Subject: Re: gtk + png
Message-Id: <dm4131p3ov4hk153bld1nrk48jcrsr59r7@4ax.com>

On 10 Mar 2005 09:45:33 -0800, "mboso" <mbosowo@gmail.com> wrote:

>I'm writing a gtk-perl application that will allow users to load a an
>image into a window, write text over than image, then save the result
>as a *png file.
>
>I was wondering what widgets would best be suited for this task. I'm
>currently looking through gtk+ documentation for suitable widgets, but
>I thought I would ask here as well.

I'm sure gtk2-perl can do it too, but Tk is simpler for me.

GD and ImageMagick can do it, but you said you want to load
the image into a window first, so you will need to put the
png onto a Canvas.
Here is a simple example. You may need to fix it up to select
fonts, color,  scrolling for huge images, etc.
#########################################################
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::WinPhoto;
use Tk::PNG;
use GD;
require Tk::DialogBox;

my $file = shift || die "Need png $!\n";

my $imagein = GD::Image->newFromPng($file);
my ($width,$height) = $imagein->getBounds();
#print "width->$width\nheight->$height\n";

my $mw = new MainWindow();

$mw->fontCreate('big',
     -family=>'courier',
     -weight=>'bold',
     -size=>int(-18*18/14));

my $image = $mw->Photo(-file => $file);

my $canv = $mw->Canvas(-height => $height,
                       -width => $width,
               )->pack;

my $png = $canv->createImage(0,0,
                -anchor => 'nw',
                -image=> $image,
           );

my $canvbutton = $mw->Button(-text=>'Canvas Capture',
                             -command => \&canv_capture,
                            )->pack;

$mw->Button(-text=>'Exit', -command => sub{exit} )->pack;


$canv->CanvasBind("<Button-1>", [ \&print_xy, Ev('x'), Ev('y') ]);

MainLoop;

########################################################## 

sub canv_capture{

my $image = $mw->Photo(-format => 'Window',
                        -data => oct($canv->id)
                       );

my $pathname = './canvas.'.time.'.png';
$image->write($pathname, -format => 'PNG');

}
############################################################## 

sub print_xy {
  my ($canv, $x, $y) = @_;
    
    my $xc = $canv->canvasx($x);
    my $yc = $canv->canvasy($y);


  my $dialog = $mw->DialogBox(
       -buttons => [qw/Ok Cancel/],
       -title   => "Enter New Value"
    );

    my $dialogE = $dialog->add("Entry");
       $dialogE->pack(qw/-padx 10 -pady 10/);

   my $button = $dialog->Show();
      if ( $button eq "Ok" ) {
        my $letters = $dialogE->get();
        
	$canv->createText($xc,$yc,
	       -text => $letters,
	       -anchor=> 'nw',
	       -fill => 'red',
	       -font => 'big',
	       );	
      }else{return}

}
####################################################
__END__



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


------------------------------

Date: Thu, 10 Mar 2005 20:44:50 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: Re: HTML::Parser - duplicated text in <h2> .. </h2> ?
Message-Id: <obc13110bp640ao164vakc3vu32j28asl9@4ax.com>

On Thu, 10 Mar 2005 09:43:40 +0100, "Tassilo v. Parseval"
<tassilo.von.parseval@rwth-aachen.de> wrote:

>> Because it's an instance-method?
>
>Sorry, rather a class-method actually. But still a method.
>
>Tassilo


Tassilo,

Hope you are well ! My code owes much to your kind help!

Cheers

Geoff



------------------------------

Date: Thu, 10 Mar 2005 19:05:11 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: include external perl program
Message-Id: <d0q5ek$joh$1@sun3.bham.ac.uk>

alythh@netscape.net wrote:

> good hint Tad,
> but I found it slightly irritating in a point: the article dismisses
> any possible use of "local".
> It happens instead that I often find it very useful. The typical
> situation is where a variable globally visible keeps some kind of
> "current state". This var is continuously modified at runtime, but you
> have to restore its value when any given function exits (isnt'it called
> also dynamical scoping?).

Oh yes, there are indeed times when judicous use of a few dynamically 
scoped variables will make your code clearer and more maintainable.

The trouble is that they can make a real mess when abused and some 
people tend to throw the baby out with the bathwater.



------------------------------

Date: 10 Mar 2005 13:31:22 -0800
From: bart@nijlen.com (Bart Van der Donck)
Subject: Module should not work, but works
Message-Id: <b5884818.0503101331.7442350d@posting.google.com>

Hello,

This is a file named p.pl:

  #!/usr/bin/perl
  use strict;
  use warnings;
  use lib '/path/to/mm_e.pm/';
  use mm_e;
  mm::printok();
  printok();
  sub printok { print "ok from p.pl\n"; }

This is a file named mm_e.pm:

  package mm;
  sub printok { print "ok from mm_e.pm\n"; }
  1;

Result:

 % perl -w p.pl
 ok from mm_e.pm
 ok from p.pl
 %

Why does this work fine ? 
Shouldn't "strict" or "warnings" give me at least an error about this
kind of construction ? I 'm on perl 5.8.3 built for i386-freebsd.

-- 
Bart


------------------------------

Date: Thu, 10 Mar 2005 22:48:54 +0100
From: Arne Ruhnau <krevlar.newsgroups@tragetaschen.dyndns.org>
Subject: Re: Module should not work, but works
Message-Id: <d0qfc7$74e$00$1@news.t-online.com>

Bart Van der Donck wrote:
> Why does this work fine ? 
> Shouldn't "strict" or "warnings" give me at least an error about this
> kind of construction ? I 'm on perl 5.8.3 built for i386-freebsd.

Hm, why shouldn't it? You name your package mm, use it, call printok 
residing in the namespace mm, and then you call printok residing in 
main. So, what's the deal?
Maybe you misinterpret the filename and the packagename, which happen to 
be different?

puzzled,

Arne Ruhnau


------------------------------

Date: Thu, 10 Mar 2005 16:50:05 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Module should not work, but works
Message-Id: <8p6dnTI-yZuTXK3fRVn-tw@comcast.com>

Bart Van der Donck wrote:

> Hello,
> 
> This is a file named p.pl:
> 
>   #!/usr/bin/perl
>   use strict;
>   use warnings;
>   use lib '/path/to/mm_e.pm/';
>   use mm_e;
>   mm::printok();
>   printok();
>   sub printok { print "ok from p.pl\n"; }
> 
> This is a file named mm_e.pm:
> 
>   package mm;
>   sub printok { print "ok from mm_e.pm\n"; }
>   1;
> 
> Result:
> 
>  % perl -w p.pl
>  ok from mm_e.pm
>  ok from p.pl
>  %
> 
> Why does this work fine ?
> Shouldn't "strict" or "warnings" give me at least an error about this
> kind of construction ? I 'm on perl 5.8.3 built for i386-freebsd.
> 
Um, what error?  Why would perl complain about that construction?  It's
perfectly proper in every way.  You've declared two subs, &mm::printok
and &main::printok (with main being the default package name; all
globals have a package name, and if you don't write a package statement,
your default package is main.  In mm_e.pm, the default package is
mm, because you put in a package statement).  Then you call them.  
Nothing wrong with any of that.  Note that perl doesn't finish 
parsing your source until it finishes reading your source.  It
doesn't care that you used &main::printok before you defined it.

-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


------------------------------

Date: Thu, 10 Mar 2005 23:14:09 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Module should not work, but works
Message-Id: <39bvd8F623cajU1@individual.net>

Bart Van der Donck wrote:
> 
>   use lib '/path/to/mm_e.pm/';

That line does not help much. @INC is supposed to contain paths to 
*directories* with .pm files, not paths to .pm files directly.

I suppose that the reason why it still works is that mm_e.pm happens to 
be located in the same directory as p.pl, while your @INC includes the 
current directory.

Others have answered your actual question.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


------------------------------

Date: 10 Mar 2005 12:13:23 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: One Liner to reverse sort file
Message-Id: <1110485603.163941.48750@o13g2000cwo.googlegroups.com>

> hogg wrote:
> >
> > I was wondering if there was a one liner that would reverse
> > order a file w/o having to write the output to another file.
> > I can reverse order a file using:
> > awk '{printf "%10d\t%s\n",NR,$0}' <FILE> | sort -nr
> > | cut -f2- >> <FILE2>, but this makes me create another file.
> > I wanted to be able to do it 'on the fly'.
> > Any suggestions?

Ala Qumsieh replied:
>
> Something like this?
>
>    perl -lp0 -i -e '$_ = join "\n" => reverse split /\n/' in.file
>
> or a bit shorter:
>
>    perl -aF"\n" -lp0 -i -e '$_=join$\,reverse@F' in.file


   If I remember correctly, there was an even shorter solution given as
an answer to a problem in Randal L. Schwartz & Tom Phoenix's book
"Learning Perl":

      perl -e "print reverse <>"

   Quite elegant, in my opinion.   :)

   -- Jean-Luc Romano



------------------------------

Date: 10 Mar 2005 12:43:39 -0800
From: "Dan" <danfperl@yahoo.com>
Subject: Re: Using dot commands in a script
Message-Id: <1110487419.536029.320580@l41g2000cwc.googlegroups.com>

I've decided there isn't a way to do what I'm trying to do the way I'm
trying to do it, and since I have a job this isn't an academic
exercise.  :)  I think the best solution for me in this case is to use
dotsh.pl in a module and put the thing to rest.  Sinan, it turns out my
first post never did make it (anyone notice the group was unavailable
for a while?) so it's a good thing I put the second one there.  I was
concerned about the delay in my post showing up, not replies.  Sourcing
the script prior to running it is an option, but that makes another
file to keep track of.

Thanks to everyone for the feedback!

Dan



------------------------------

Date: Thu, 10 Mar 2005 21:12:16 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Using dot commands in a script
Message-Id: <Xns9615A4D723234asu1cornelledu@127.0.0.1>

"Dan" <danfperl@yahoo.com> wrote in news:1110487419.536029.320580
@l41g2000cwc.googlegroups.com:

[ please quote some context when replying ]

> dotsh.pl in a module and put the thing to rest.  Sinan, it turns out my
> first post never did make it 

It is on Google:

http://tinyurl.com/44prf

http://groups-
beta.google.com/group/comp.lang.perl.misc/msg/70c9e9663badc484?
dmode=source

I can also see it in my newsreader.

> (anyone notice the group was unavailable for a while?) 

No.

> so it's a good thing I put the second one there.

I am indifferent.

Sinan


------------------------------

Date: 10 Mar 2005 11:33:00 -0800
From: "darth" <jairagoo@gmail.com>
Subject: Re: Win32::TieRegistry Logon User Name
Message-Id: <1110483180.744857.152590@z14g2000cwz.googlegroups.com>

as a matter of completeness I submitt my code that would extract the
current logon users from the registry with Win32::TieRegistry.  you can
use it to Interrogate all the computer in your subnet (if you have
Admin access to them, that is.)
any further suggestions would be appreciated.

###########CODE#########################
## Enjoy: Jai Ragoo
use Win32::TieRegistry( Delimiter=>"/", ArrayValues=>0 );
use Net::Ping;

my @subnet =qw(4);

foreach $subnet (@subnet) {
    for (my $i=1;$i <5;$i++){
          my $computerName="",$ip="",,$username="";;
    			$ip = qq(192.168.$subnet.$i);
#$ip="venus";    ### you can also check nbt names or FQDN of your
clients
          $p=Net::Ping->new(tcp);
   		if($p->ping($ip)) {

            if($computerName =
$Registry->{"//$ip/LMachine/SYSTEM/CurrentControlSet/"
              ."Control/ComputerName/ComputerName//ComputerName"})
            {}else {print "can't connect get ComputerName $^E";}

            print "$ip => $computerName logged on user(s):\n";

            if ($userData=$Registry->{"//$ip/Users"}){
              foreach $subKey ($userData->SubKeyNames)
                {
                  if ($subKey=~/(\d+-\d+-\d+-\d+)_Classes/)
                    {
                     if
($username=$Registry->{"//$ip/Users/S-1-5-21-$1/Software/Microsoft/"
                        ."Windows/CurrentVersion/Explorer//Logon User
Name"})
                       {     print "\t$username\n"; }
                     else {print "no user found";}
                     }
                  }
             } # if ($userData=$Registry->{"//$ip/Users"}){
       } #for (my $i=1;$i <5;$i++){
    } #for (my $i=1;$i <5;$i++){
} # foreach $subnet (@subnet) {
#########END OF CODE#######



------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7876
***************************************


home help back first fref pref prev next nref lref last post