[12148] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5748 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 21 20:07:19 1999

Date: Fri, 21 May 99 17:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 21 May 1999     Volume: 8 Number: 5748

Today's topics:
    Re: A du type function? (I R A Aggie)
    Re: can someone help me with locking??? <sugalskd@netserve.ous.edu>
    Re: Dereferencing a filehandle. (Larry Rosler)
    Re: Dereferencing a filehandle. <anand@my-dejanews.com>
    Re: Dynamic Thumnail Generation?? (Benjamin Franz)
        File exist on remote host <Pete_Parker@dot.state.ak.us>
    Re: File exist on remote host <tchrist@mox.perl.com>
    Re: Grab string from STDIN <johnny@pahv.xerox.com>
    Re: how can I make this code more programmatic? <aperrin@mcmahon.qal.berkeley.edu>
    Re: how can I make this code more programmatic? <uri@sysarch.com>
    Re: how can I make this code more programmatic? <tchrist@mox.perl.com>
    Re: how can I make this code more programmatic? <aperrin@mcmahon.qal.berkeley.edu>
        How to check for ASCII? <rp5280@email.sps.mot.com>
    Re: How to create a non-blocking UDP server on Win32 <orock@curiouspictures.com>
        Measuring space on a share <a-damont@microsoft.com>
    Re: Need Perl interpreter <news@thebeaches.to>
    Re: Passsing Input From Form 2 Form via Perl/CGI <cassell@mail.cor.epa.gov>
    Re: Perl "constructors" <emschwar@rmi.net>
        Perl/Tk and updating Text question <carvdawg@patriot.net>
        Sharing Horror Stories of Perl server crashes? <ocfernan@rochester.rr.com>
        SSI problem about including text file that doesn't in t (Ryan Ngi)
    Re: Sys::Syslog doesn't work in Perl5.005_03 :-( (Juergen Heinzl)
    Re: Utterly poor perl!! (using index) (Larry Rosler)
    Re: Utterly poor perl!! (using index) (Larry Rosler)
    Re: Web page redirect - Not working ?perl problem?  Pls <dukat@flash.net>
    Re: Web page redirect - Not working ?perl problem?  Pls <kirasa@oz.net>
    Re: Web page redirect - Not working ?perl problem?  Pls <kirasa@oz.net>
    Re: while ( <FILE> && /match/ ) (I R A Aggie)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: 21 May 1999 22:30:26 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: A du type function?
Message-Id: <slrn7kbnpg.csm.fl_aggie@thepentagon.com>

On Fri, 21 May 1999 14:40:29 -0700, Curt Cranfield <curt@vphos.net>, in
<3745D2CD.A400C0E@vphos.net> wrote:

+ Any thoughts?

Yah, ppt. <url:http://language.perl.com/ppt/src/du/>.

James


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

Date: 21 May 1999 23:36:48 GMT
From: Dan Sugalski <sugalskd@netserve.ous.edu>
Subject: Re: can someone help me with locking???
Message-Id: <7i4qmg$7q6$1@news.NERO.NET>

David Cassell <cassell@mail.cor.epa.gov> wrote:
: Cameron Dorey wrote:
:> 
:> [cc'd to md]
:> 
:> Marc Dietrich wrote:
:> >
:> > try the flock mechanism. See perldoc -f flock or man flock. This only
:> > works on Unix Systems.
:> 
:> BRAAAK! Wrong! Next contestant spin the Wheel, please. flock works on
:> WinNT, but not on Win9x. I believe I have also seen that it works on
:> VMS, but have had no experience with that OS since 1982.

: There may still be some problems with the VMS implementation.
: Ask Dan Sugalski.

flock doesn't work on VMS, but it's normally not needed. VMS does
mandatory file locking for you.

					Dan


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

Date: Fri, 21 May 1999 15:45:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Dereferencing a filehandle.
Message-Id: <MPG.11af81c8a9164093989ae0@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <FC3Kqy.Eoy@news.boeing.com> on Fri, 21 May 1999 19:28:10 
GMT, Charles DeRykus <ced@bcstec.ca.boeing.com> says...
> In article <7i3q8b$ccp$1@bmerhc5e.ca.nortel.com>,
> Keith <keithp@comnet.ca> wrote:
> >Can anyone tell me how to show the value of a filehandle in my output?
> >I have something like this:
> >print "FILE: $_\n";
> >
> >Where FILE is the filehandle defined earlier in the program.
> >I want FILE to show up as the real file name.
> 
> Don't use a bareword filehandle: 
> 
> my $fh = '/path/to/file';
> open($fh, $fh) or die $!;
> print "$fh: $_\n"; 

Oh.  Wow!  Yeah!!  Why not!!!  Thanks!!!!

It's even simpler than that, at least for reading the file:

  use vars '$fh';
  $fh = '/path/to/file';
  open $fh or die $!;
  print "$fh: $_\n"; 

open FILEHANDLE,EXPR 
open FILEHANDLE 

Opens the file whose filename is given by EXPR, and associates it with 
FILEHANDLE. If FILEHANDLE is an expression, its value is used as the 
name of the real filehandle wanted. If EXPR is omitted, the scalar 
variable of the same name as the FILEHANDLE contains the filename. (Note 
that lexical variables--those declared with my()--will not work for this 
purpose; so if you're using my(), specify EXPR in your call to open.) 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 21 May 1999 23:34:05 GMT
From: Anand <anand@my-dejanews.com>
Subject: Re: Dereferencing a filehandle.
Message-Id: <7i4qhd$jnk$1@nnrp1.deja.com>

In article <FC3Kqy.Eoy@news.boeing.com>,
  ced@bcstec.ca.boeing.com (Charles DeRykus) wrote:
> In article <7i3q8b$ccp$1@bmerhc5e.ca.nortel.com>,
> Keith <keithp@comnet.ca> wrote:
> >Can anyone tell me how to show the value of a filehandle in my
output?
> >I have something like this:
> >print "FILE: $_\n";
> >
> >Where FILE is the filehandle defined earlier in the program.
> >I want FILE to show up as the real file name.
>
> Don't use a bareword filehandle:
>
> my $fh = '/path/to/file';
> open($fh, $fh) or die $!;
> print "$fh: $_\n";

Newbie: Can you tell how $fh acts both as a string variable and as well
as a directory handle at the sametime?

In "open($fh,$fh)" do both $fh refer to the same thing or are they in
different namespaces?

Thanks
Anand


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


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

Date: Fri, 21 May 1999 22:35:50 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: Dynamic Thumnail Generation??
Message-Id: <adl13.36578$ny.2627704@typhoon-sf.snfc21.pbi.net>

In article <3745CD59.5C9992A4@mediaone.net>,
PropART  <propart@mediaone.net> wrote:
>bob wrote:
>
>> Does anyone know if there is a perl script or equivalent way to create
>> 'thumbnails on the fly'...any help is very much appreciated.
>>
>> thanks,
>> robert
>
>Randal Schwartz did a column on thumbnailing in Perl for the Jan. '99 Web
>Techniques. The code is posted on his website.
>
>try http://www.stonehenge.com/merlyn/WebTechniques/

A better program is http://www.nihongo.org/snowhare/utilities/htmlthumbnail/

-- 
Benjamin Franz


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

Date: Fri, 21 May 1999 13:57:14 -0800
From: Peter Parker <Pete_Parker@dot.state.ak.us>
Subject: File exist on remote host
Message-Id: <3745D6BA.2AE0B4DA@dot.state.ak.us>

Does anyone have a solution to determining if a file resides on a remote
host from within Perl?
In other words, I want to know if SOMEFILE.TXT exist on a machine other
that the one the script is running on.
Thanks in advance
Peter Parker.,]



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

Date: 21 May 1999 16:22:18 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: File exist on remote host
Message-Id: <3745dc9a@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Peter Parker <Pete_Parker@dot.state.ak.us> writes:
:Does anyone have a solution to determining if a file resides on a remote
:host from within Perl?

Just as you'd do it without Perl.

    % rsh somehost ls -l somefile.text

--tom
-- 
"A ship then new they built for him/of mithril and of elven glass" 
    --Larry Wall in perl.c from the v5.0 perl distribution,
	citing Bilbo from Tolkien's LOTR


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

Date: Fri, 21 May 1999 15:33:12 -0700
From: "Hall, Johnny" <johnny@pahv.xerox.com>
Subject: Re: Grab string from STDIN
Message-Id: <3745DF28.9C8BFC12@pahv.xerox.com>

Thanks all!  It works!  Now all I have to do is append the tar.Z to each
and wget away.  Anyway, here is what it looks like in case anyone is
interested.

open(SCAN, "rsh $HOST /soft/support/sunscan/sunscan|") or die "Johnny:
$!";
           while (<SCAN>)
           {
                next unless /^\d{6}-\d{2}/;
                @PATCH = my ($PATCHNUM) = split(/:\s*/);
                foreach $PATCH (@PATCH)
                  {
                    print "$PATCH\n";
                  }
           }

May not be pretty but...

and the output...

johnny@PHOENIX>>>test.pl
Enter Target Host: hawaii
104854-02
104820-01
104822-01
104824-01
104873-01
105701-02
104976-03
104977-01
104816-01
106563-04
104818-01
105016-01
105675-03
104995-01
104918-01
107524-01


Thanks Again, and if anyone has pointers on how to get .tar.Z appended I
would be happy to listen.  :)  Actually I have a couple of scripts
laying around somewhere another guy wrote, so I better get looking.


Johnny



David Cassell wrote:
> 
> Anand wrote:
> >
> > In article <37459B84.2DE0954D@pahv.xerox.com>,
> >   "Hall, Johnny" <johnny@pahv.xerox.com> wrote:
> > > I
> > > don't know how to (a) open the output of sunscan in the script (b)
> > > snatch the patch number from the list.  Here is a sample from the
> >
> > Warning: Newbie's reply.
> 
> Hey Anand, just because you're not The Larry doesn't mean
> you need to qualify your replies so self-deprecatingly.
> We all make mistakes in this ng sooner or later.  As long as
> you tested your code before posting, you should be in good
> shape.  And if someone comes along and corrects you, you
> learn something.  Just like I learn things from being corrected
> by the experts in this ng.
> 
> > open(SCAN, "sunscan|");
> 
> Always check the status of your open(), even when it's a pipe.
> 
> > while (<SCAN>) {
> 
> As I understand the output of sunscan [which is admittedly
> a weak understanding and not a grok], the lines with patches
> are the only lines with the following format, so this only
> splits when we *have* a patch number:
> 
>      next unless /^\d{6}-\d{2}/;
> 
> >    ($patchnum, $os, $patch) = split(/:\s*/);
> 
> And use 'my' so you don't accidentally trample on some poor
> variable to be used later.
> 
>      my ($patchnum, $os, $patch) = split(/:\s*/);
> 
> >    # Now $patchnum contains the patch number. Ex: 104854-02
> >    # Ex. $os = SunOS 5.5.1
> >    # Ex. $patch = troff macro patch.
> > }
> >
> > [snip]
> 
> HTH,
> David
> --
> David Cassell, OAO                     cassell@mail.cor.epa.gov
> Senior computing specialist
> mathematical statistician

-- 
"All you need is ignorance and confidence; then success is sure." --
Mark Twain


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

Date: Fri, 21 May 1999 15:06:00 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: tbrannon <brannon@quake.usc.edu>
Subject: Re: how can I make this code more programmatic?
Message-Id: <3745D8C8.C4677785@mcmahon.qal.berkeley.edu>

[courtesy copy sent via e-mail]

I'm not entirely sure what you're trying to do, but I'll hazard a guess that
for each of a.dat, b.dat, and a+b.dat, you want to generate an array named
after the filename, consisting of all the 'words' in the file, split by
whitespace. Here's some code.

#!/usr/local/bin/perl -w

use strict "no refs"; #because you wanted them in arrays named after
themselves, the
                            # easiest way is to use ugly, non-strict, soft
refs.

my(%files)=(   # set up a hash of array names => filenames.
 'A' => 'a.dat',
 'B' => 'b.dat',
 'S' => 's.dat'
      );

$/=undef; # make perl slurp the whole file into one string using <>.

foreach (keys %files) {
  open (FILEIN, $files{$_}) or do {
    print STDERR "Couldn\'t open $files{$_}: $!\n"; #don't die just because
one file fails.
    next;
  };
  @$_=split(/\s+/, <FILEIN>); #create an array using the hash key as the
name, and
  close $_;                                # populate by splitting the whole
file on whitespace.
}



tbrannon wrote:

> As you can see, the same thing is being done, but I simply need it
> done with A,B, and S. How might I make this task more programmatic and
> less of a cut-and-paste job?
>
> open A, 'a.dat';
> open B, 'b.dat';
> open S, 'a+b.dat';
>
> @A=<A>;
> @a=split '\s+', $A[1];
> @B=<B>;
> @b=split '\s+', $B[1];
> @S=<S>;
> @s=split '\s+', $S[1];
>
> --
>    Terrence Brannon  * brannon@lnc.usc.edu * http://lnc.usc.edu/~brannon
>                 (213) 740-3397 [office] (323) 294-3028 [home]



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
     http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: 21 May 1999 18:27:22 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: how can I make this code more programmatic?
Message-Id: <x7zp2y6otx.fsf@home.sysarch.com>

>>>>> "AP" == Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu> writes:


  AP> use strict "no refs"; #because you wanted them in arrays named after
  AP> themselves, the
  AP>                             # easiest way is to use ugly, non-strict, soft
  AP> refs.

  AP>   @$_=split(/\s+/, <FILEIN>); #create an array using the hash key as the

die 'evil symbolic ref user!' ;

:-)

just use a hash of hashes like everyone always says when asked to create
dynamically named vars. i won't code it here but the idea is for each
key, you have a hash ref which has keys of file name, file handle and
file lines. very basic and useful to know.

read perldsc, the cookbook for more on this.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 21 May 1999 16:34:57 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: how can I make this code more programmatic?
Message-Id: <3745df91@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    tbrannon <brannon@quake.usc.edu> writes:
:As you can see, the same thing is being done, but I simply need it
:done with A,B, and S. How might I make this task more programmatic and
:less of a cut-and-paste job?

Learn how to write real data structures.

=head2 How can I use a variable as a variable name?

Beginners often think they want to have a variable contain the name
of a variable.

    $fred    = 23;
    $varname = "fred";
    ++$$varname;         # $fred now 24

This works I<sometimes>, but it is a very bad idea for two reasons.

The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether.  Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.

Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.

The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes.  By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash.  The solution is to
use your own hash or a real reference instead.

    $fred    = 23;
    $varname = "fred";
    $USER_VARS{$varname}++;  # not $$varname++

There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables.  This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one.  Instead of
reading a string and expanding it to the actual contents of your program's
own variables:

    $str = 'this has a $fred and $barney in it';
    $str =~ s/(\$\w+)/$1/eeg;		  # need double eval

Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:

    $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

That's faster, cleaner, and safer than the previous approach.  Of course,
you don't need to use a dollar sign.  You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.

    $str = 'this has a %fred% and %barney% in it';
    $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes.  For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.

    $name = "fred";
    $$name{WIFE} = "wilma";     # set %fred

    $name = "barney";           
    $$name{WIFE} = "betty";	# set %barney

This is still a symbolic reference, and is still saddled with the
problems enumerated above.  It would be far better to write:

    $folks{"fred"}{WIFE}   = "wilma";
    $folks{"barney"}{WIFE} = "betty";

And just use a multilevel hash to start with.

The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table.  This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.

In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table.  For example:

    @colors = qw(red blue green yellow orange purple violet);
    for my $name (@colors) {
        no strict 'refs';  # renege for the block
        *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
    } 

All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.

So, sometimes you might want to use symbolic references to directly
manipulate the symbol table.  This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
-- 
    No, I'm not going to explain it.  If you can't figure it out, you didn't
    want to know anyway...  :-)
            --Larry Wall in <1991Aug7.180856.2854@netlabs.com>


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

Date: Fri, 21 May 1999 15:47:57 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: how can I make this code more programmatic?
Message-Id: <3745E29D.9939322E@mcmahon.qal.berkeley.edu>

Fair 'nuff -- just responding to what the poster wanted. Granted a hash of arrays is
the Right Solution.

ap

Uri Guttman wrote:

> >>>>> "AP" == Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu> writes:
>
>   AP> use strict "no refs"; #because you wanted them in arrays named after
>   AP> themselves, the
>   AP>                             # easiest way is to use ugly, non-strict, soft
>   AP> refs.
>
>   AP>   @$_=split(/\s+/, <FILEIN>); #create an array using the hash key as the
>
> die 'evil symbolic ref user!' ;
>
> :-)
>
> just use a hash of hashes like everyone always says when asked to create
> dynamically named vars. i won't code it here but the idea is for each
> key, you have a hash ref which has keys of file name, file handle and
> file lines. very basic and useful to know.
>
> read perldsc, the cookbook for more on this.
>
> uri
>
> --
> Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
> uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
> Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
> The Best Search Engine on the Net -------------  http://www.northernlight.com



--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
     http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Fri, 21 May 1999 16:15:55 -0700
From: Mike Garcia <rp5280@email.sps.mot.com>
Subject: How to check for ASCII?
Message-Id: <3745E915.28518DD3@email.sps.mot.com>

This is a multi-part message in MIME format.
--------------9056B8938522749AB84150D3
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit

Hello,

I'm developing a program and there is a check I need to do for a non
numeric value on a variable.  Is there an easy way to do this in Perl 5?

Thanks for any suggestions!

Please email me at rp5280@email.sps.mot.com

Mike

--------------9056B8938522749AB84150D3
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mike Garcia
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Mike Garcia
n:              Garcia;Mike
org:            Motorola BMC CIM
adr;dom:        ;;2200 W. Broadway Rd. ;AZ09 Maildrop M150;Mesa, Arizona  85202;Pager 888 464-6689;
email;internet: rp5280@email.sps.mot.com
title:          Synergy Administrator
tel;work:       (602) 655-2871
tel;fax:        (602) 855-5135
x-mozilla-cpt:  ;1
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------9056B8938522749AB84150D3--



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

Date: Fri, 21 May 1999 19:45:44 -0400
From: Oliver Rockwell <orock@curiouspictures.com>
Subject: Re: How to create a non-blocking UDP server on Win32
Message-Id: <3745F028.EA59A757@curiouspictures.com>

Although there is a lot of documentation on using sockets in perl many of the examples do not work
under Win32.   The O'reilly examples use the alarm() function which is only for unix.  I found
timing out a UDP socket to be pretty ugly to code and difficult to find an example of with what
should be a  high level module like IO::Socket but as many will tell you it can be done with the
select() function -- just not very elegantly. Basically you use the timeout capability of select to
bypass the lack of timeout ability of recv().

Here is how I am timing out on a UDP IO::Socket under Win32.  This code has been tested for a few
weeks now and seems very stable.  The use of the vec() call and the select() call below were lifted
from various sources in newsgroups and docs.

use IO::Socket;
 .....
 $sock = IO::Socket::INET->new(Proto => 'udp', PeerPort => $port, PeerAddr => $server);
 .....
 vec($rin, fileno($sock), 1) = 1;
 if (select($rout=$rin, undef, $eout=$rin, $timeout)) {    ## is a message waiting
    $sock->recv($message, $maxlen) or die "getMessage - socket recv: $!";
}

-- Oliver

Michel Dalle wrote:

> In article <926612299.737412@zeppelin.svr.home.net>, "Jalil Feghhi" <jalil@corp.home.net> wrote:
> >I am setting up a UDP server on a Win32 system and trying to make it
> >non-blocking so that when I go to recv call it either times out  or returns
> >immediately (real non-blocking).
> >
> >I have tried two things so far. One is to use the Timeout arg to
> >IO::Socket::INET->new call, which did not work (I still block on a
> >subsequent recv call) and also tried to use fcnl() which is not implemented
> >on Win32.
> >
> >I dont mind using the low leve socket functions here if that is the only way
> >to do this.
> >
> >Could anybody tell me how to do this?
>
> Have you had a look at select() ? That's how I usually check whether there
> is something to read on a socket. And it doesn't rely on potentially
> unimplemented socket options...
>
> Have you looked at perlipc yet ? There is an example there for UDP that
> does just about what you want :
>
> socket();
> bind();
> ..
> send();
> ..
> while (select()) {
>         recv();
> }
> close();
>
> I'm sure you can do the same thing with IO::Socket too,
>
> Michel.



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

Date: Fri, 21 May 1999 15:55:06 -0700
From: "Damon Torgerson" <a-damont@microsoft.com>
Subject: Measuring space on a share
Message-Id: <7i4nvp$aji@news.dns.microsoft.com>

Hello all,

I'd like to measure the free space on a series of shares.  I'm new to Perl
and I was wondering if anyone has any recommendations for doing this.

Thanks for your help,
Damon




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

Date: Fri, 21 May 1999 19:21:57 -0400
From: "Jim The Perl Guy" <news@thebeaches.to>
Subject: Re: Need Perl interpreter
Message-Id: <7i4pr9$fho$1@news.auaracom.net>

www.perl.com



anonymous wrote in message <37457f4b.639307@nntp.ix.netcom.com>...
>Where's the best place to get a Perl interpreter for Windows 98?  Can
>I download one for free from anywhere?
>
>- j




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

Date: Fri, 21 May 1999 15:03:37 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Passsing Input From Form 2 Form via Perl/CGI
Message-Id: <3745D839.4E003214@mail.cor.epa.gov>

zzzipper wrote:
> 
> Can someone explain how to accomplish or point me in the direction of an
> example for doing the following with forms using CGI and a series of Perl
> scripts:
> 
> I have a form for initial input (name, address, etc).  I want to pass this
> info between a series of 4 forms as a page header.  After the Ist form is
> read, I am able to display form 1's  input on the second form's header.
> However when I submit the 2nd form and try to read the header data inserted
> (name, etc) I receive no data.
> 
> I am using forms with hidden input fields, but trying to place OnClick
> values into these fields seem fruitless.  Please help or advise.

Okay, here are a couple pieces of advice.
[1] use CGI;  # that's a Perl module 
[2] ask CGI questions in the cgi newsgroups, and only ask
Perl questions here.

#2 is really important.  Since you're not posting any Perl
code, there's no way any Perl expert can provide you with
assistance.  But your problem as stated is one of coping
with the CGI protocol.  So it's more appropriate for
   comp.infosystems.www.authoring.cgi
than here.  Now, if you had posted your Perl code [say,
10 to 30 lines showing the key points and illustrating
your problem] and wanted help fixing the Perl parts,
then it might be relevant here.

I hope you don't think I'm being rude, but there is an
important distinction here.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 21 May 1999 16:02:43 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Perl "constructors"
Message-Id: <xkfvhdmgjy4.fsf@valdemar.col.hp.com>

ada@fc.hp.com (Andrew Allen) writes:
> Eric The Read (emschwar@rmi.net) wrote:
> : It's not only that, though.  Perl really only has one type of exception:
> : $@.  It's not even *possible* for Perl to automatically propogate
> : "uninteresting" exceptions, because there's only one kind.  Another
> : annoying thing is that a subroutine can raise an exception, and the
> : caller is not forced to deal with it.  This severely limits the
> : usefulness of eval/die as an exception handling mechanism, to my mind.
> 
> Baloney. Just takes a little bit of creativity. Graham Barr's Error.pm
> wraps the following idea up in a neat little package (along with the
> try/catch example from perlsub):

<snip>

Okay, that's a neat trick, and one that's likely to get me using eval/die 
more often.  But it doesn't change the fact that *Perl* doesn't have more 
than one kind of exception.  

Until something like that's folded into the language itself, there's
still no way to automatically propagate exceptions.  Right now, Perl
can't assume that $@ has been blessed at all, much less into what
hierarchy.

And there's *still* no way to automatically die on an uncaught exception.

-=Eric


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

Date: Fri, 21 May 1999 19:37:13 +0100
From: Marquis de Carvdawg <carvdawg@patriot.net>
Subject: Perl/Tk and updating Text question
Message-Id: <3745A7D9.9A3293B6@patriot.net>

I'm using AS build 509 on NT workstation 4.0 SP3
I have a Perl/TK script that has a bunch of widgets...when one
of the buttons is pressed, a subroutine is called to do some
work.  Within that subroutine, I have $text->insert() calls that
are not being completed.  All of the "work" gets done, and the calls
are made _after_ it's all done...

I can't post all the code here...b/c it's a LOT, and it's copyrighted.
However, the point is that prints to filehandles, and doing the actual
work in the subroutine is going well...I just need a visual way to show
the progress of the subroutine, and I am doing that by writing to a
Text widget.  However, the inserts (see below for the example) are not
working correctly.

Any thoughts are appreciated.

Thanks
Carv

Here's an example of what I am working with:

$mw->new MainWindow;
 .
 .
 .
$button = $buttonBar->Button(-command => sub {mySub()})
                                   ->pack();
 .
 .
 .
sub mySub {
/*
   create an HTML file
*/

$text->insert("end","some text");

/*
  open a file, so do some work
  write to the file
  call other subroutines
*/

$text->insert("end","some more text");
}

MainLoop;






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

Date: Fri, 21 May 1999 19:27:16 -0400
From: "Orlando C. Fernando" <ocfernan@rochester.rr.com>
Subject: Sharing Horror Stories of Perl server crashes?
Message-Id: <3745EBD4.9B59E71A@rochester.rr.com>

I'm just getting into learning Perl and I've kept hearing about if you
do poor coding, you can really tie up a server. Can any of you share
some "horror stories" of what caused such rucouses on your server (even
if you didn't do it yourself). I'm trying to get a flavor for the sort
of things to watch out for when coding. And I can't imagine testing Perl
code of a web form to one e-mail address (mine) could have potential for
major problems/crashes.

--
                                        -OCF
Home Page-
http://home.rochester.rr.com/ocfernan
                        last updated: May 9 99




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

Date: Sat, 15 May 1999 22:52:52 GMT
From: ryanngi@hotmail.com (Ryan Ngi)
Subject: SSI problem about including text file that doesn't in the same directory as the html
Message-Id: <373df98b.28233379@news.inet.co.th>

How to include a file via SSI if it isn't in the same directory as the
html is.... i use

      <!--#include file="/BBS/display.dat"-->

but it's not work......... ;~~~


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

Date: Fri, 21 May 1999 23:08:29 GMT
From: juergen@monocerus.demon.co.uk (Juergen Heinzl)
Subject: Re: Sys::Syslog doesn't work in Perl5.005_03 :-(
Message-Id: <slrn7kbpp6.cu.juergen@monocerus.demon.co.uk>

In article <ciechowski-ya023280002105992308060001@news.nacamar.de>,
Ingo Ciechowski wrote:
>Hi folks,
>
>I've got a problem using the Sys::Syslog package on my linux 2.0.36 system
>with Perl Perl5.005_03...

You must run syslogd with -r on Linux, give it a try.

Cheers,
Juergen

-- 
\ Real name     : J|rgen Heinzl                 \       no flames      /
 \ EMail Private : juergen@monocerus.demon.co.uk \ send money instead /


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

Date: Fri, 21 May 1999 15:31:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Utterly poor perl!! (using index)
Message-Id: <MPG.11af7eaa5cb746f9989adf@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <7i48o0$728$1@nnrp1.deja.com> on Fri, 21 May 1999 18:30:23 
GMT, John Porter <jdporter@min.net> says...
> In article <7i4097$pp$1@nnrp1.deja.com>,
>   Richard Lawrence <ralawrence@my-dejanews.com> wrote:
> > Here is some utterly poor code to take each line from a file txt.txt
> > and see if that line contains the words on the command line ie.
> >
> > prog.pl fish          -- will list all lines with fish in it
> > prog.pl fish chips    -- will list all lines with fish AND chips in it
> >
> > Two problems:
> >
> > 1. Its case sensitive - the only way I can think of making it case
> > insensitive is by copying both bits of text to temp variables,
> > lowercasing them and then compairing but that is HORRIBLE. Can anyone
> > suggest a better solution?
> >
> > 2. Is there any better way to do this code? In the end there won't be
> > the input from the command line, just an array of words (like
> > @requests).
 ...
> while (<>) {
>   my $match = 0;
>   for my $w ( @requests ) {
>     /\Q$w\E/i and $match++;
>   }
>   $match and print "$.: $_";
> }

The problem conditions require printing a match only if *every* item in 
@requests is matched.  So:

    $match == @requests and print "$.: $_";

However...  Is this the same John Porter who cares about the efficiency 
of sorting???

You present an algorithm that recompiles a regex (N [words in the input 
data] * M [requests]) times.  Such code is described as the epitome of 
extreme inefficiency in perlfaq6:  "How do I efficiently match many 
regular expressions at once?" 

I prefer something like perlfaq4:  "How can I tell whether a list or 
array contains a certain element?".  I've never deleted a hash slice 
before.  Fun problem!

> > 2. Is there any better way to do this code?

#!/usr/local/bin/perl -w
use strict;

my @requests = map lc, qw( FISH Chips ale );

while (<DATA>) {
    my %requests;
    @requests{@requests} = ();
    delete @requests{map lc, /\w{3,}/g};
    print "$.: $_" unless %requests;
}
__END__
I'll have FISH and more FISH and stALE CHIPS  # 2 matches
without salsa
 ...
Oh, I want ale and ale with my fish and chips # 3 matches
 ...
or perhaps "ale" with my FISH and Chips!      # 3 matches

> > 2. Is there any better way to do this code?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 21 May 1999 16:08:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Utterly poor perl!! (using index)
Message-Id: <MPG.11af87457854117b989ae1@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3747d0e4.6995412@news.skynet.be> on Fri, 21 May 1999 
21:57:25 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> Richard Lawrence wrote:
> >Here is some utterly poor code to take each line from a file txt.txt
> >and see if that line contains the words on the command line ie.
> >
> >prog.pl fish          -- will list all lines with fish in it
> >prog.pl fish chips    -- will list all lines with fish AND chips in it
> 
> Hmm... I like to build Perl code on the fly, "eval" it to get a working
> tester sub, and then apply this sub to every line. Oh: the //i modifier
> makes the test case insensitive.
> 
> So my stab at this is:
> 
>     my @request = @ARGV; #for now
>     my $code = join ' && ', map { "/\\b\Q$_\E\\b/i" } @request;
>     my $sub = eval "sub { $code }";
>     defined $sub or die "Improper query: $code";
>     while(<DATA>) {
>         $sub->() #call sub
>           and print "Got a match ($.): $_";
>     }
> __DATA__
> Data courtesy of Andrew Johnson :-)
> blah fish and chips
> blah just fish
> ChiPs blah fish blah
> 
> Eek! It works!

And it's a lot faster than my hash solution, at least for two requests!  
I wonder how it would scale to many requests.


#!/usr/local/bin/perl -w
use strict;
use Benchmark;

my @requests = map lc, qw( FISH chips );

my $code = join ' && ', map { "/\\b\Q$_\E\\b/i" } qw/fish chips/;
my $sub = eval "sub { $code }";
defined $sub or die "Improper query: $code";
my @data = <DATA>;

sub Regex { for (@data) { $sub->() } }

sub Hash {
  for (@data) {
    my %requests;
    @requests{@requests} = ();
    delete @requests{map lc, /\w{3,}/g};
  }
}

timethese(1 << (shift || 0), {
  Hash  => \&Hash,
  Regex => \&Regex,
});
__DATA__
Data courtesy of Andrew Johnson :-)
blah fish and chips
blah just fish
ChiPs blah fish blah
I'll have Fish and stale chips and FISH again
without salsa
but with plenty of CHIPS!
 ...
Oh, I want ale with my fish and chips
 ...
or perhaps "ale" with my FISH and Chips!

Benchmark: timing 16384 iterations of Hash, Regex...
      Hash: 18 wallclock secs (17.19 usr +  0.00 sys = 17.19 CPU)
     Regex:  5 wallclock secs ( 4.91 usr +  0.00 sys =  4.91 CPU)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 21 May 1999 22:02:24 GMT
From: Eric Miller <dukat@flash.net>
Subject: Re: Web page redirect - Not working ?perl problem?  Plse help!
Message-Id: <3745D7D1.D394CBA8@flash.net>

"Kira S. Anastasia" wrote:
>   What I am *trying* to do:  Take input from an HTML form,
> process the data and generate a new page and THEN go to it
> when the script finishes.  Everything works, but the
> re-direct doesn't.
> 
>
> Sigh, *what* have I missed here?

Your script has output a complete Content-type header before your
Location header - and that's why you see the Location header in the
browser window.  

Eric Miller


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

Date: Fri, 21 May 1999 15:50:55 -0700
From: "Kira S. Anastasia" <kirasa@oz.net>
Subject: Re: Web page redirect - Not working ?perl problem?  Plse help!
Message-Id: <3745E34F.1E1A1970@oz.net>

Hi Jane and thanks!

> print "Content-type: text/html\n\n";
> 
> make this the second line in your script.

Did so:
[ ... ]
print "Location: $url\n\n";
print "Content-type: text/html\r\n\r\n";
[ ... ]

same results... ?!

Take care, Kira.
--
Respectfully, Kira Anastasia,  kirasa@oz.net
Without adventure, civilization is in full decay. Alfred
Whitehead


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

Date: Fri, 21 May 1999 15:54:40 -0700
From: "Kira S. Anastasia" <kirasa@oz.net>
Subject: Re: Web page redirect - Not working ?perl problem?  Plse help!
Message-Id: <3745E430.AC15359E@oz.net>

Hi Eric and thanks!

> "Kira S. Anastasia" wrote:
> >   What I am *trying* to do:  Take input from an HTML form,
> > process the data and generate a new page and THEN go to it
> > when the script finishes.  Everything works, but the
> > re-direct doesn't.
> >
> >
> > Sigh, *what* have I missed here?
> 
> Your script has output a complete Content-type header before your
> Location header - and that's why you see the Location header in the
> browser window.

Sigh :-)...

Just tried Janes suggesion above - no change.

Then removed that and checked the source and I am *not*
putting out any content type header at all.

Starting to wonder if I don't have some other problem, I'm
really confused / perplexed.

THanks & Take care, Kira.
--
Respectfully, Kira Anastasia,  kirasa@oz.net
Without adventure, civilization is in full decay. Alfred
Whitehead


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

Date: 21 May 1999 22:40:22 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: while ( <FILE> && /match/ )
Message-Id: <slrn7kboc4.csm.fl_aggie@thepentagon.com>

On Fri, 21 May 1999 13:38:05 -0700, Larry Rosler <lr@hpl.hp.com>, in
<MPG.11af64038e11e13e989ade@nntp.hpl.hp.com> wrote:

+ One seldom ought to pick on coding style, but as this thread has to do 
+ with ugliness, your attempt to correct that ugliness is fair game.

Agreed.

+       last unless /match/;

'unless' is my downfall. What can I say? My perl is better, but it is
still heavily accented by fortran.

James



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5748
**************************************

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