[25604] in Perl-Users-Digest
Perl-Users Digest, Issue: 7848 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 3 03:05:38 2005
Date: Thu, 3 Mar 2005 00:05:22 -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, 3 Mar 2005 Volume: 10 Number: 7848
Today's topics:
@_ uninitialized value mbosogrp@gmail.com
@_ uninitialized value mbosogrp@gmail.com
Re: @_ uninitialized value <pilkowsk@informatik.uni-marburg.de>
Re: combining two arrays <tgiles@gmail.com>
Re: Converting Word Control characters to an ASCII form <murali@muralichari.com>
Re: Drag and drop <newspost@kohombanDELETE.net>
Re: Drag and drop <pilkowsk@informatik.uni-marburg.de>
Re: IO::Scalar insanity <flavell@ph.gla.ac.uk>
Re: Need to download 20000 pdf files <yyusenet@yahoo.com>
Re: Need to download 20000 pdf files <nospam@bigpond.com>
Re: odd socket behavior with ZoneAlarm <yyusenet@yahoo.com>
Re: odd socket behavior with ZoneAlarm <kalinaubears@iinet.net.au>
Re: odd socket behavior with ZoneAlarm <vek@station02.ohout.pharmapartners.nl>
Re: perl commands <notvalid@email.com>
Re: perl commands <tadmc@augustmail.com>
Re: perl commands <emschwar@pobox.com>
Re: perl commands <pilkowsk@informatik.uni-marburg.de>
Re: PERL WEB PROGRESS BAR <yyusenet@yahoo.com>
Re: Questions about Perl for Windows <newspost@kohombanDELETE.net>
Re: Questions about Perl for Windows <newspost@kohombanDELETE.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 2 Mar 2005 21:38:15 -0800
From: mbosogrp@gmail.com
Subject: @_ uninitialized value
Message-Id: <1109828294.972311.74860@o13g2000cwo.googlegroups.com>
I'm writing a small Gtk2 program to convert between bases. I'm getting
a strange error when i run my code:
Use of uninitialized value in exponentiation (**) at ./radix line 216.
Use of uninitialized value in exponentiation (**) at ./radix line 190.
The strange thing is, sometimes I get it, sometimes I don't. Anyone
have any insight into what's causing it?
Second question. How do you append text to a textbuffer without
overwriting it?
Also, while I'm here, I wouldn't mind some constructive criticism on my
coding style. Any input would be appreciated.
Here is the offending code.
#!/usr/bin/perl -w
use strict;
use Gtk2;
set_locale Gtk2;
init Gtk2;
my $true=1;
#####superfluous variable declarations cut out #####
my $vscrollbar;
my %radixFrameHash =( 'Decimal:'=>$decOut,
'Binary:' =>$binOut,
'Hex:' =>$hexOut,
'Octal:' =>$octOut,
'ASCII:' =>$asciiOut,
);
my $num_rows = 5;
my $num_columns = 10;
my $homogeneous = $true;
$window = new Gtk2::Window("toplevel");
$window->signal_connect("delete_event",sub{Gtk2->main_quit;});
$window->set_default_size(470, 650 );
$window->set_title( "Radix" );
$vbox = new Gtk2::VBox($true,0);
$window->add($vbox);
$hbox = new Gtk2::HBox($false,0);
#Create Entry label and inputbox
$label = new Gtk2::Label('Input: ');
$entry = new Gtk2::Entry();
$entry->signal_connect("activate", \&input_callback, $entry);
$entry->set_editable($true);
$entry->show();
$label->show();
#Start packing that box. hehehe. dirty perl.
$hbox->pack_start($label,$false,$true,5);
$hbox->pack_start($entry,$true,$true,0);
$button = new Gtk2::Button("enter");
$button->signal_connect("clicked",\&input_callback,$button);
$hbox->pack_start($button,$false,$true,3);
$button->show();
$hbox->show();
$button = new Gtk2::Button("clear");
$button->signal_connect("pressed",sub{$entry->set_text("");},$button);
$hbox->pack_start($button,$false,$true,3);
$vbox->pack_start($hbox,$false,$false,0);
$button->show();
$vbox->show();
$vbox->pack_start(&popOutputFrame,$true,$false,0);
#Create Message/Error Text Box
$text_view = new Gtk2::TextView();
$buffer = new Gtk2::TextBuffer();
$buffer = $text_view->get_buffer;
$buffer->set_text("Testing");
$frame = new Gtk2::Frame("Messages");
$frame->show();
#$vscrollbar = new Gtk::VScrollbar( $text->vadj );
$text_view->set_editable ($false);
$text_view->show();
$frame->add($text_view);
$vbox->pack_start($frame,$true,$true,0);
$vbox->show();
$window->show();
main Gtk2;
exit(0);
#-----------------Sub routines--------------------#
#-------------Main Conversion Routine-------------#
sub input_callback{
my $dec = $entry->get_text();
my $virgin = $dec;
my @binary;
if ($dec==0){
unshift @binary,0;
}
else{
while ($dec >= 1 ){
if ($dec==0){
unshift @binary,0;
last;
}
if ($dec==1){
unshift @binary,1;
$dec = $dec / 2;
last;
}
if ($dec % 2){
unshift @binary, 1;
$dec = $dec / 2;
}
else{
unshift @binary, 0;
$dec = $dec / 2;
}
}#while
}#top else
$radixFrameHash{'Binary:'}->set_text("@binary");
$radixFrameHash{'Decimal:'}->set_text("$virgin");
$radixFrameHash{'Octal:'}->set_text(&bin2oct(@binary));
$radixFrameHash{'Hex:'}->set_text(&bin2hex(@binary));
$radixFrameHash{'ASCII:'}->set_text(chr $virgin);
#$text_view->set_buffer ("converting decimal number to binary");
}#input callback
#-------------Main Conversion Routine-------------#
#-------------Create and fill Frames--------------#
sub popOutputFrame{
my $table = new Gtk2::Table( $num_rows, $num_columns, $homogeneous);
my $frame = new Gtk2::Frame("Output");
my $vbox = new Gtk2::VBox($false,0);
my $key;
my $value;
my $temp;
my $j =0;
my $row = \$j; #row contains pointer to value stored in $j
my $spacing = 10;
while(($key,$value) = each %radixFrameHash){
$hbox = new Gtk2::HBox($false,0);
$label = new Gtk2::Label($key);
$radixFrameHash{$key} = new Gtk2::Entry();
$temp = $radixFrameHash{$key};
$label->show();
$temp->show();
$hbox->show();
$table->attach_defaults( $label, 0, 1, $j, $j+1 );
$table->attach_defaults( $temp, 1, 10, $j, $j+1 );
$table->set_row_spacing ($$row, $spacing);
$j++;
}
$frame->add($table);
$table->show();
$frame->show();
return ($frame);
}
#-------------Create and fill Frames--------------#
#-------------Binary 2 Hex--------------#
sub bin2hex{
my $sum;
my $base;
my $loop;
my $hex = " ";
$buffer->set_text("printing b2h inital \@_: @_");
while(@_){
$loop=1;
$sum=0;
while($loop < 9){
$sum += ($loop) * (pop (@_)**2);
$loop *= 2;
}
if($sum > 9){
$sum = chr($sum + 55);
}#unless
$hex = $sum.$hex;
}#outer while
return("0x".$hex);
}#bin2hex
#-------------Binary 2 Hex--------------#
#-------------Binary 2 Octal--------------#
sub bin2oct{
my $sum;
my $base;
my $loop;
my $oct = " ";
$buffer->set_text("printing b20 inital \@_: @_");
while(@_){
$loop=1;
$sum=0;
while($loop < 5){
$sum += ($loop) * (pop (@_)**2);
$loop *= 2;
}
$oct = $sum.$oct;
}#outer while
return("0".$oct);
}
#-------------Binary 2 Octal--------------#
------------------------------
Date: 2 Mar 2005 21:40:43 -0800
From: mbosogrp@gmail.com
Subject: @_ uninitialized value
Message-Id: <1109828443.889923.150820@z14g2000cwz.googlegroups.com>
I'm writing a small Gtk2 program to convert between bases. I'm getting
a strange error when i run my code:
Use of uninitialized value in exponentiation (**) at ./radix line 216.
Use of uninitialized value in exponentiation (**) at ./radix line 190.
this is the line of code that generates the warning in both instances:
$sum += ($loop) * (pop (@_)**2);
The strange thing is, sometimes I get it, sometimes I don't. Anyone
have any insight into what's causing it?
Second question. How do you append text to a textbuffer without
overwriting it?
Also, while I'm here, I wouldn't mind some constructive criticism on my
coding style. Any input would be appreciated.
Here is the offending code.
#!/usr/bin/perl -w
use strict;
use Gtk2;
set_locale Gtk2;
init Gtk2;
my $true=1;
#####superfluous variable declarations cut out #####
my $vscrollbar;
my %radixFrameHash =( 'Decimal:'=>$decOut,
'Binary:' =>$binOut,
'Hex:' =>$hexOut,
'Octal:' =>$octOut,
'ASCII:' =>$asciiOut,
);
my $num_rows = 5;
my $num_columns = 10;
my $homogeneous = $true;
$window = new Gtk2::Window("toplevel");
$window->signal_connect("delete_event",sub{Gtk2->main_quit;});
$window->set_default_size(470, 650 );
$window->set_title( "Radix" );
$vbox = new Gtk2::VBox($true,0);
$window->add($vbox);
$hbox = new Gtk2::HBox($false,0);
#Create Entry label and inputbox
$label = new Gtk2::Label('Input: ');
$entry = new Gtk2::Entry();
$entry->signal_connect("activate", \&input_callback, $entry);
$entry->set_editable($true);
$entry->show();
$label->show();
#Start packing that box. hehehe. dirty perl.
$hbox->pack_start($label,$false,$true,5);
$hbox->pack_start($entry,$true,$true,0);
$button = new Gtk2::Button("enter");
$button->signal_connect("clicked",\&input_callback,$button);
$hbox->pack_start($button,$false,$true,3);
$button->show();
$hbox->show();
$button = new Gtk2::Button("clear");
$button->signal_connect("pressed",sub{$entry->set_text("");},$button);
$hbox->pack_start($button,$false,$true,3);
$vbox->pack_start($hbox,$false,$false,0);
$button->show();
$vbox->show();
$vbox->pack_start(&popOutputFrame,$true,$false,0);
#Create Message/Error Text Box
$text_view = new Gtk2::TextView();
$buffer = new Gtk2::TextBuffer();
$buffer = $text_view->get_buffer;
$buffer->set_text("Testing");
$frame = new Gtk2::Frame("Messages");
$frame->show();
#$vscrollbar = new Gtk::VScrollbar( $text->vadj );
$text_view->set_editable ($false);
$text_view->show();
$frame->add($text_view);
$vbox->pack_start($frame,$true,$true,0);
$vbox->show();
$window->show();
main Gtk2;
exit(0);
#-----------------Sub routines--------------------#
#-------------Main Conversion Routine-------------#
sub input_callback{
my $dec = $entry->get_text();
my $virgin = $dec;
my @binary;
if ($dec==0){
unshift @binary,0;
}
else{
while ($dec >= 1 ){
if ($dec==0){
unshift @binary,0;
last;
}
if ($dec==1){
unshift @binary,1;
$dec = $dec / 2;
last;
}
if ($dec % 2){
unshift @binary, 1;
$dec = $dec / 2;
}
else{
unshift @binary, 0;
$dec = $dec / 2;
}
}#while
}#top else
$radixFrameHash{'Binary:'}->set_text("@binary");
$radixFrameHash{'Decimal:'}->set_text("$virgin");
$radixFrameHash{'Octal:'}->set_text(&bin2oct(@binary));
$radixFrameHash{'Hex:'}->set_text(&bin2hex(@binary));
$radixFrameHash{'ASCII:'}->set_text(chr $virgin);
#$text_view->set_buffer ("converting decimal number to binary");
}#input callback
#-------------Main Conversion Routine-------------#
#-------------Create and fill Frames--------------#
sub popOutputFrame{
my $table = new Gtk2::Table( $num_rows, $num_columns, $homogeneous);
my $frame = new Gtk2::Frame("Output");
my $vbox = new Gtk2::VBox($false,0);
my $key;
my $value;
my $temp;
my $j =0;
my $row = \$j; #row contains pointer to value stored in $j
my $spacing = 10;
while(($key,$value) = each %radixFrameHash){
$hbox = new Gtk2::HBox($false,0);
$label = new Gtk2::Label($key);
$radixFrameHash{$key} = new Gtk2::Entry();
$temp = $radixFrameHash{$key};
$label->show();
$temp->show();
$hbox->show();
$table->attach_defaults( $label, 0, 1, $j, $j+1 );
$table->attach_defaults( $temp, 1, 10, $j, $j+1 );
$table->set_row_spacing ($$row, $spacing);
$j++;
}
$frame->add($table);
$table->show();
$frame->show();
return ($frame);
}
#-------------Create and fill Frames--------------#
#-------------Binary 2 Hex--------------#
sub bin2hex{
my $sum;
my $base;
my $loop;
my $hex = " ";
$buffer->set_text("printing b2h inital \@_: @_");
while(@_){
$loop=1;
$sum=0;
while($loop < 9){
$sum += ($loop) * (pop (@_)**2);
$loop *= 2;
}
if($sum > 9){
$sum = chr($sum + 55);
}#unless
$hex = $sum.$hex;
}#outer while
return("0x".$hex);
}#bin2hex
#-------------Binary 2 Hex--------------#
#-------------Binary 2 Octal--------------#
sub bin2oct{
my $sum;
my $base;
my $loop;
my $oct = " ";
$buffer->set_text("printing b20 inital \@_: @_");
while(@_){
$loop=1;
$sum=0;
while($loop < 5){
$sum += ($loop) * (pop (@_)**2);
$loop *= 2;
}
$oct = $sum.$oct;
}#outer while
return("0".$oct);
}
#-------------Binary 2 Octal--------------#
------------------------------
Date: Thu, 3 Mar 2005 09:01:41 +0100
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: @_ uninitialized value
Message-Id: <MPG.1c90e2cba5e0034c9898bb@news.individual.de>
* mbosogrp@gmail.com wrote:
>
> I'm writing a small Gtk2 program to convert between bases. I'm getting
> a strange error when i run my code:
>
> Use of uninitialized value in exponentiation (**) at ./radix line 216.
> Use of uninitialized value in exponentiation (**) at ./radix line 190.
>
> this is the line of code that generates the warning in both instances:
> $sum += ($loop) * (pop (@_)**2);
>
> The strange thing is, sometimes I get it, sometimes I don't. Anyone
> have any insight into what's causing it?
Within your sub bin2oct() you have two encapsulated while-loops. The
outer one tests if there is *one* element in array @_. The inner one
pops *three* elements from @_. Thats why your programm prints no
warning if you pass 3, 6, 9, 12 etc elements (binary digits) to your
sub. In other cases pop will return undef (if @_ is already empty) and
the exponentation will cause an error. Try out
$sum += $loop * ( pop @_ || 0 ** 2 );
to use 0 whenever pop returns undef. Pay attention at the operators
precedence or, to be on the safe side, write it as
$sum += $loop * ( (pop(@_)||0) ** 2 );
Btw, I think your subs bin2oct() and bin2hex() could be smarter. I would
not write down such an *self-made* algorithm rather than:
sub bin2oct {
my $bin = join '', @_;
my $dec = oct( "0b$bin" );
return sprintf '0%o', $dec;
}
sub bin2hex {
my $bin = join '', @_;
my $dec = oct "0b$bin";
return sprintf '0x%X', $dec;
}
>
> Second question. How do you append text to a textbuffer without
> overwriting it?
The Docs on CPAN refer to the "GTK+ Reference Manual" where the
corresponding C API is described. Try to read
http://developer.gnome.org/doc/API/2.0/gtk/GtkTextBuffer.html
to get an overview about "GtkTextBuffer". The method you're currently
using seems to be gtk_text_buffer_set_text(). Perhaps you can use
$buffer->insert() or $buffer->insert_at_cursor(). I think it's not too
hard for you to try out which parameters these methods are expecting in
the perl interface for GTK+.
regards,
fabian
------------------------------
Date: 2 Mar 2005 16:13:09 -0800
From: "tgiles" <tgiles@gmail.com>
Subject: Re: combining two arrays
Message-Id: <1109808789.281137.154640@z14g2000cwz.googlegroups.com>
Forgot to take the time to update this. Please forgive me.
Looks like Mr. Gibson struck gold. Was able to use the code snippet to
finish up my little script and it runs like a dream. Mr. Lalli, that
looks pretty intriguing as well. I might plug it in and see where it
gets me. I appreciate your input as well!
Anyway, thanks so much for the assist, guys. Slugged it for three days
and it just didn't seem to click. One post and I went from zero to
finished.
Thanks to all the responses. Here's hoping that it will help someone
else down the line.
Cheers!
tom
------------------------------
Date: 2 Mar 2005 19:24:36 -0800
From: "Murali" <murali@muralichari.com>
Subject: Re: Converting Word Control characters to an ASCII format
Message-Id: <1109820276.639542.306310@g14g2000cwa.googlegroups.com>
I found out that http://www.fourmilab.ch/webtools/demoroniser/
offers an excellent Perl-based solution. (Thanks for all who replied.)
-Murali
------------------------------
Date: Thu, 03 Mar 2005 10:07:05 +0800
From: GreenLeaf <newspost@kohombanDELETE.net>
Subject: Re: Drag and drop
Message-Id: <38n9stF5od644U1@individual.net>
Tino wrote:
> I would like to be able to drag and drop files onto a .pl file in the same
> way I can drop files onto a .bat file. I made a .bat which can do this but
> if I try to do the same thing with a .pl file I find the .pl file isn't able
> to accept files for drag and drop operations, the cursor changes to the "not
> allowed operation" symbol when the file being dropped is over the .pl file.
> What do I have to do to the .pl file to make it work like the .bat file?
>
> Example of .bat file onto which a file can be dropped:
>
> @echo off
> :plot_loop
> print.pl p=1 %1
> shift
> if not "%1"=="" goto plot_loop
>
>
> Example of .pl file that I would like to do the same as the .bat file:
>
> use strict;
> use warnings;
>
> foreach (@ARGV) {
> system("print.pl p=1 $_");
> }
>
>
Not the exact answer to your question; but if you just need to _get the
job done_, two alternatives are
1. use the following one-liner batch file that calls the perl script in
turn.
@perl "path\to\script\thescript.pl" %*
2. consider compiling the perl script in to a Windows executable.
------------------------------
Date: Thu, 3 Mar 2005 06:27:11 +0100
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: Drag and drop
Message-Id: <MPG.1c90be9c39b020a69898b9@news.individual.de>
* Tino wrote:
>
> I would like to be able to drag and drop files onto a .pl file in the same
> way I can drop files onto a .bat file. I made a .bat which can do this but
> if I try to do the same thing with a .pl file I find the .pl file isn't able
> to accept files for drag and drop operations, the cursor changes to the "not
> allowed operation" symbol when the file being dropped is over the .pl file.
> What do I have to do to the .pl file to make it work like the .bat file?
If you've a version of ActiveState's Perl installed have a look into its
bin-directory. You will find a small tool named "pl2bat.bat" which wrap
your perl code into a batch file.
Otherwise you can add a new key to your windows registry to imitate the
behavior of batch files. Then you can drag and drop your files directly
to you perl script. Just create the key
HKEY_CLASSES_ROOT\Perl\shellex\DropHandler\
with default value set to "{86C86720-42A0-1069-A2E8-08002B30309D}".
Don't ask something about this CLSID, for me this works on a german
winxp machine. Perhaps you wanna compare this with your own system
settings. I've copied this value from
HKEY_CLASSES_ROOT\batfile\shellex\DropHandler\
regards,
fabian
------------------------------
Date: Wed, 2 Mar 2005 23:03:42 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: IO::Scalar insanity
Message-Id: <Pine.LNX.4.61.0503022258480.18061@ppepc56.ph.gla.ac.uk>
On Wed, 2 Mar 2005, kj wrote:
> In <Pine.LNX.4.61.0503021614590.17689@ppepc56.ph.gla.ac.uk> "Alan J. Flavell" <flavell@ph.gla.ac.uk> writes:
>
> >On Wed, 2 Mar 2005, kj wrote, quoting me:
>
> >> >Anyone who's expert enough to produce a safe and reliable
> >> >implementation that doesn't use CGI.pm will have no difficulty in
> >> >solving that problem without any help from us.
> >>
> >> The OP didn't specify whether he was debugging his own code, or
> >> that what he was debugging was a "safe and reliable" anything.
>
> >And what conclusion would you draw from that?
>
> See my previous posts on this thread.
Thank you for offering me the opportunity to review your contributions
this thread. I've done so, and I don't see anything which relates to
the issue of safe and reliable CGI scripts.
If you're of the opinion that it doesn't matter whether CGI scripts
are safe or reliable, then there's this guy called Matt who you might
like to meet.
OTOH if you'd care to read Lincoln Stein's web security FAQ, I think
you might find there's quite a lot of pratfalls lying in wait for
those who don't take the issues seriously.
ttfn
------------------------------
Date: Wed, 02 Mar 2005 22:23:28 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: Need to download 20000 pdf files
Message-Id: <d0670g$is9$1@news.xmission.com>
Hemant wrote:
> I am working on a project that requires me to have access to more than
> 20000 pdf files. Any suggestions on how to go about searching over the
> internet and be able to download the files?
>
Hmm... You haven't been very descriptive. Do you want to create a
spider that will start at a web site and try to extract every .pdf link?
Or are all of the links in one folder, in one place? Because then all
you would have to do is just download them in a loop.
--
k g a b e r t (at) x m i s s i o n (dot) c o m
*Support Mozilla Firefox*!
http://www.spreadfirefox.com/?q=user/register&r=71209
------------------------------
Date: Thu, 03 Mar 2005 17:58:22 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Need to download 20000 pdf files
Message-Id: <38nucvF5mkflvU2@individual.net>
Hemant wrote:
> I am working on a project that requires me to have access to more than
> 20000 pdf files. Any suggestions on how to go about searching over the
> internet and be able to download the files?
Assuming one directory tree:
http://www.gnu.org/software/wget/wget.html
gtoomey
------------------------------
Date: Wed, 02 Mar 2005 17:10:30 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: odd socket behavior with ZoneAlarm
Message-Id: <d05kll$4ci$1@news.xmission.com>
AC wrote:
> "phaylon" <phaylon@dunkelheit.at> wrote in message
> news:pan.2005.03.02.14.59.28.191943@dunkelheit.at...
>
>>D. Marxsen wrote:
>>
>>
[sniped for size]
>>
>>--
>>http://www.dunkelheit.at/
>>codito, ergo sum.
>>
>
>
> I try to be really sensitive to off-topic posts and get irritated by others
> who do it. So I did not post to this group lightly.
>
> My original question stands. This problem is an odd interaction between Perl
> and some third pary product. If I post in the ZoneAlarm forums, folks either
> say "I don't know Perl" or "This is a Perl problem". If I post here, some
> folks say "this is off topic." I did a search for the newsgroup
> *firewallsperl* but couldn't find it. ;-)
>
>
>
I understand why you think it would not be off topic, and I can
understand your frustration at being pushed around from group to group
with everybody claiming that it is the other persons' problem.
However, a lot of people (including me) have never used ZA. If you want
Perl-related help on your problem, please provide us with a basic
informative guide on how ZA works. Does ZA block programs from
contacting other computers by blocking <SOCK>? Have the ZA people just
forgotten to block another method (recv)? Is the Perl script *and* the
Perl compiler inside of the exceptions list in ZA?
--
k g a b e r t (at) x m i s s i o n (dot) c o m
*Support Mozilla Firefox*!
http://www.spreadfirefox.com/?q=user/register&r=71209
------------------------------
Date: Thu, 03 Mar 2005 06:51:29 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: odd socket behavior with ZoneAlarm
Message-Id: <4226c389$0$11051$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
AC wrote:
> This is very strange and I'm posting it here in case someone else runs into
> this problem. ZA (ZoneAlarm) messes up Perl applications that read from
> sockets using the syntax
>
> my $line = <SOCK>;
>
> causing them to hang indefinately, even if the server closes the socket. You
> can get past this by using the following code snippet instead:
>
> my $line = "";
> if (defined (recv(SOCK, $line, 1024, 0))) {
> print $line;
> }
>
> Does anyone know what ZoneAlarm might be doing? Is it messing with the line
> terminator that the server uses? The internal XP firewall does not interfere
> with Perl programs this way.
>
I have ZA installed on a Windows 2000 box - that runs a simple (perl)
client that connects to a server on a linux box. But I can't duplicate
the problem. Do you have a complete (preferably minimal) script that
demonstrates the problem ?
I use IO::Socket and find that the following works fine:
@lines = <$socket>;
If I do :
$line = <$socket>;
then $line returns only the first line of the response from the server
(but it certainly doesn't hang).
I suspect that you might be using the Socket module, which perhaps
behaves differently.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: 03 Mar 2005 08:01:29 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: odd socket behavior with ZoneAlarm
Message-Id: <slrnd2dh2p.50e.vek@station02.ohout.pharmapartners.nl>
On Wed, 02 Mar 2005 17:10:30 -0700,
YYusenet <yyusenet@yahoo.com> wrote:
>
> However, a lot of people (including me) have never used ZA. If you want
> Perl-related help on your problem, please provide us with a basic
> informative guide on how ZA works. Does ZA block programs from
> contacting other computers by blocking <SOCK>? Have the ZA people just
> forgotten to block another method (recv)? Is the Perl script *and* the
> Perl compiler inside of the exceptions list in ZA?
>
The only difference I see is that <SOCK> needs a newline before returning
whereas recv doesn't.
Villy
------------------------------
Date: Wed, 02 Mar 2005 23:35:54 GMT
From: Ala Qumsieh <notvalid@email.com>
Subject: Re: perl commands
Message-Id: <u5sVd.2139$C47.324@newssvr14.news.prodigy.com>
Chris Mattern wrote:
> Gabriella wrote:
>> chomp($line);
>
>
> Remove the trailing newline from $line
Or whatever is defined in $/, in case that changed.
>
>> next if ($line =~ /^ *$/m);
>
>
> Skip the rest of this loop iteration if $line is only
> spaces, or empty. The /m is only meaningful if
> $line contains multiple lines, and is pointless here.
Not necessarily. If $/ changed, then $line can contain multiple lines.
There is no way to check, but I doubt that is the case.
--Ala
------------------------------
Date: Wed, 2 Mar 2005 16:51:51 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl commands
Message-Id: <slrnd2cgs7.9ic.tadmc@magna.augustmail.com>
Chris Mattern <matternc@comcast.net> wrote:
> Whoever did this isn't very good.
That sums it up quite well.
It clearly was written my an amateur.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 02 Mar 2005 18:04:03 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: perl commands
Message-Id: <etovf8935h8.fsf@wilson.emschwar>
gabriella@istop.com (Gabriella) writes:
> Could somebody give me the meaning of each line ?
>
> while (<IN>) {
> my $line = $_;
> chomp($line);
> next if ($line =~ /^ *$/m);
> next if ($line =~ /^#.*$/m);
> next if ($line !~ /^[0-9].*$/m);
> #$line =~ s/#.*$//m;
> $line =~ s/ +$//m;
> $line =~ s/^ +//m;
Others have dissected it; here's my attempt at a better rewrite, so
you can see what a proper job might look like:
while(my $line = <IN>) {
chomp($line);
next unless $line =~ /^\d/;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
# ... other stuff goes here
}
The main difference here is that I removed the useless regexes Lars
Eighner commented on, and I reversed the sense of the one that's left.
As a matter of personal style, I tend to avoid the !~ operator because
I feel =~ is easier to read. This isn't a hard and fast rule with me,
but I find it serves me well.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Thu, 3 Mar 2005 05:40:23 +0100
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: perl commands
Message-Id: <MPG.1c90b3a63bbdf5449898b8@news.individual.de>
* Eric Schwartz wrote:
>
> Others have dissected it; here's my attempt at a better rewrite, so
> you can see what a proper job might look like:
>
> while(my $line = <IN>) {
> chomp($line);
> next unless $line =~ /^\d/;
> $line =~ s/^\s+//;
> $line =~ s/\s+$//;
>
> # ... other stuff goes here
> }
Do you think it's required to delete all leading white spaces from a
line starting with a number? It's also required to chomp the line, if a
newline is one of the trailing white spaces? Since you have changed the
original code to delete all trailing *white spaces* ("\s") instead of
*blanks* (" "), you can lessen your code's rewrite:
while ( my $line = <IN> ) {
next unless $line =~ /^\d/;
$line =~ s/\s+$//;
# ...
}
regards,
fabian
------------------------------
Date: Wed, 02 Mar 2005 17:02:03 -0700
From: YYusenet <yyusenet@yahoo.com>
Subject: Re: PERL WEB PROGRESS BAR
Message-Id: <d05k5q$3tc$1@news.xmission.com>
Sebastien wrote:
> Hello,
> I am doing little CGI scripts. Right now I am working on how to upload
> files from a computer to a web site.
> I think I will finish soon that feature. Here are my questions (I'd
> already looked on the web some stuff related to these questions):
> - I would like to create a progression bar while uploading my file. Do
> you know where I can find some basic scripts that can do that?
> - I have already found some text scripts that can do it in my term. Is
> there any scripts that can do that for the web (not using Perl GTK for
> instance)?
>
> Thanx very much for the answers.
>
> Sebastien
The answer is rather easy. Make a new frame (or IFrame) that will
constantly be refreshing, and then if something is changed then it will
cause javascript to change the size of a solid colored image, so that it
gives the illusion of showing the status of a file being updated.
--
k g a b e r t (at) x m i s s i o n (dot) c o m
*Support Mozilla Firefox*!
http://www.spreadfirefox.com/?q=user/register&r=71209
------------------------------
Date: Thu, 03 Mar 2005 09:22:52 +0800
From: GreenLeaf <newspost@kohombanDELETE.net>
Subject: Re: Questions about Perl for Windows
Message-Id: <38n7a0F5rbgkbU1@individual.net>
John Bokma wrote:
> GreenLeaf wrote:
>>I _did_ mean top-level entries directly on context menu, not 'open-with'
>>entries. They can be manually created from within Explorer, but
>
> How? Moreover, how can I remove them from within Explorer?
Going OT - will try to keep it short. :) Feel free to email me.
Open a Windows Explorer window, select from menu Tools > Folder Options,
then go to the 'File Types' tab. Pick the file type, (or create it from
'new') and then click 'Advanced'. You'll have _almost_ everything in
your control. Removing/Setting default too. :-)
> RISC OS has a nice thing: if you shift + double click a file opens in the
> editor. Isn't there a similar thing for Windows?
Shift + right click could you more options in the context menu. One
typical option is 'Open with' in cases it's not there already. Shift
also alters behaviors of others actions such as 'shift+<del>' =
permanently delete bypassing the Recycle Bin.
------------------------------
Date: Thu, 03 Mar 2005 11:04:34 +0800
From: GreenLeaf <newspost@kohombanDELETE.net>
Subject: Re: Questions about Perl for Windows
Message-Id: <38nd8nF5lhgj2U1@individual.net>
Chris Mattern wrote:
>
> No Windows Perl is likely to do too well with a module that
> has C code, or other such code designed to be compiled into a UNIX
> binary.
>
Given that one can get the code to compile somehow with the appropriate
compiler, I don't think there's a notion "designed to to be compiled in
to a UNIX binary" (stress on 'UNIX *binary*'). More so if the module
does not have anything os-specific, which many modules don't do.
ActiveState also has precompiled binaries that you can install with ppm,
for popular modules. No need to compile the modules from the source
yourself.
------------------------------
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 7848
***************************************