[17199] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4611 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 13 18:10:43 2000

Date: Fri, 13 Oct 2000 15:10:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971475018-v9-i4611@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 13 Oct 2000     Volume: 9 Number: 4611

Today's topics:
        how can I clear all vars at once? (free memory) lalakaka@my-deja.com
    Re: how can I clear all vars at once? (free memory) <jeffp@crusoe.net>
    Re: how can I clear all vars at once? (free memory) <kistler@gmx.net>
    Re: how can I clear all vars at once? (free memory) (David Wall)
    Re: How to extract a patteren from a text file? <yanick@babyl.sympatico.ca>
        How to use .pl csript on IIS to send mail to NT Exchang <tlyn@mail.cccd.edu>
    Re: How to use .pl csript on IIS to send mail to NT Exc <aspina@panix.com>
    Re: How to use bidirectional pipe at perl? <kistler@gmx.net>
        How to use Module when I can not install it <oesterheld@gmx.de>
    Re: How to use Module when I can not install it <Sagar.Shah@sid.cam.ac.uk>
    Re: html syntax check <jeff@vpservices.com>
        installing perl in Win 98 frannyzoo@hotmail.com
    Re: installing perl in Win 98 <aspina@panix.com>
    Re: looking for links to Perl+mysql how-to's - tutorial (Jon S.)
    Re: Maintaining State on a TCP socket <bkennedy@hmsonline.com>
        Need help converting lots of Unix times alphathk@pacbell.net
    Re: Need help converting lots of Unix times <lr@hpl.hp.com>
    Re: Need Urgent help on File reading <bart.lateur@skynet.be>
        NET::FTP and socks and firewall (Thompson_James)
    Re: Perl conditional functions nobull@mail.com
    Re: Perl conditional functions <lr@hpl.hp.com>
    Re: Perl conditional functions <lr@hpl.hp.com>
    Re: Perl conditional functions (Tramm Hudson)
    Re: Perl rules - Pyhton drools <uri@sysarch.com>
        Perl's open command on unix files nandagopalj@hotmail.com
    Re: Perl's open command on unix files (John J. Trammell)
    Re: Plz help - Perl Q <godzilla@stomp.stomp.tokyo>
    Re: Plz help - Perl Q <uri@sysarch.com>
        pod2man and long option names beginning with minus minu (Karl H. Williamson)
    Re: Problem using a module nobull@mail.com
    Re: regex challenge (Tony L. Svanstrom)
    Re: Splitting a scalar in two arrays (Mark-Jason Dominus)
    Re: Splitting a scalar in two arrays <bart.lateur@skynet.be>
    Re: UNIX/PERL question <reddjk@usa.net>
    Re: UNIX/PERL question tltt@my-deja.com
    Re: Win32-API.zip <barbr-en@online.no>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Oct 2000 17:55:26 GMT
From: lalakaka@my-deja.com
Subject: how can I clear all vars at once? (free memory)
Message-Id: <8s7iab$g$1@nnrp1.deja.com>



Hi...

I have a script which creates global vars at runtime, which names are
not know at compile time, i.g. are read from a file, something like
this:

open(FILE, "vars") or die "error opening vars";
while(<File>)
{
  ($name, $value)=split $_, "=";
  $$name=$value;
}
close FILE;

if I run this script with mod_perl I have a big problem with memory
overflow, because the names vary and therefor the symbol table grows and
grows... because of some reasons I don't want to use a hash for these
runtime-created vars.

I see a solution in storing all names of vars created in a hash like

$vars{$name}++;

and clear them by myself at the end of the script with

undef $$_ foreach (keys %vars);

but this looks like useless work to me, because they are stored in the
symbol table anyway.......

so the question is: is there an easy way to clear all vars in the symbol
table?


thanks!

best regards,

Christoph Bergmann


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 13 Oct 2000 14:44:23 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: how can I clear all vars at once? (free memory)
Message-Id: <Pine.GSO.4.21.0010131441420.14163-100000@crusoe.crusoe.net>

[posted & mailed]

On Oct 13, lalakaka@my-deja.com said:

>I have a script which creates global vars at runtime, which names are
>not know at compile time, i.g. are read from a file, something like
>this:

That's a less-than-good way of doing it.  Just use a hash.

>while(<File>)
>{
>  ($name, $value)=split $_, "=";
>  $$name=$value;
>}

  while (<File>) {
    my ($n,$v) = split /=/, $_, 2;  # you had $_ and = backwards
    $VAR{$n} = $v;
  }

This is what hashes are for.  Then you do

  print $VAR{$name};

to access a specific name, and

  %VAR = ();

to clear the hash.

If you want to do symbol table munging, check the Symbol.pm module -- it
offers a function to delete a namespace

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/





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

Date: Fri, 13 Oct 2000 20:21:59 +0200
From: Per Kistler <kistler@gmx.net>
To: lalakaka@my-deja.com
Subject: Re: how can I clear all vars at once? (free memory)
Message-Id: <39E752C7.22C5AC65@gmx.net>

lalakaka@my-deja.com wrote:

> so the question is: is there an easy way to clear all vars in the symbol
> table?

If it would happen within some sub scope then the scope end would
automatically
delete it.
There is also the the use Symbols "delete_package" function, which may
help
as well, if you had it within a class.

Hope that helps, Per.


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

Date: 13 Oct 2000 15:04:14 -0400
From: darkon@one.net (David Wall)
Subject: Re: how can I clear all vars at once? (free memory)
Message-Id: <8FCC90EC6darkononenet@206.112.192.118>

lalakaka@my-deja.com wrote in <8s7iab$g$1@nnrp1.deja.com>:
>I have a script which creates global vars at runtime, which names are
>not know at compile time, i.g. are read from a file, something like
>this:
>
>open(FILE, "vars") or die "error opening vars";
>while(<File>)
>{
>  ($name, $value)=split $_, "=";
>  $$name=$value;
>}
>close FILE;

Unless it's a quick program you're going to use once and then throw away, 
symbolic references like the above are a bad idea. See 
http://www.plover.com/~mjd/perl/varvarname.html for reasons why.  Quick 
summary: symbolic references make hard-to-find bugs easy to create.


[snip other stuff to save space]
>so the question is: is there an easy way to clear all vars in the symbol
>table?

perldoc -q clear

That is, it's in the FAQ list.

-- 
David Wall
darkon@one.net


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

Date: Fri, 13 Oct 2000 20:07:18 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: How to extract a patteren from a text file?
Message-Id: <WXJF5.326464$Gh.9612483@news20.bellglobal.com>

: qureshii@my-deja.com wrote:
:> 
:> Hi I am a new perl student and what I need to do it to write a script
:> which takes in a C++ file and print out all the files listed only in
:> #include<iostream.h>
:> #include<hello.c>

Per Kistler <kistler@gmx.net> wrote:
: #!/usr/bin/perl -n
: $_ =~ s/^\s*#include\s*<(.*?)>.*$/$1/ or next; print;

: Used as:
: prog *.cpp

Or

perl -nle's/^(\s*#include\s*<(.*?)>)?.*/$2/;$_&&print' *.cpp

Or, even better

perl -nle'print $1 if /^\s*#include\s*<(.*?)>/'	*.cpp 

which can be golfed to

perl -nle'/^\s*#include\s*<(.*?)>/&&print$1' *.cpp

Joy,
Yanick

-- 
($_,$y)=("Yhre lo  .kePnarhtretcae\n",   '(.) (.)'  );
$y=~s/\(/(./gwhile s/$y/$2$1/xg;print;       @      !; 
                                     "     `---'    ";


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

Date: Fri, 13 Oct 2000 13:06:16 -0700
From: Tony Lyn <tlyn@mail.cccd.edu>
Subject: How to use .pl csript on IIS to send mail to NT Exchange.
Message-Id: <39E76B38.A849EBF6@mail.cccd.edu>

I am converting the .pl script from Unix to .pl script on the IIS
server. I am using NT Exchange for mail. What do I use in place of
"$mail='/usr/sbin/sendmail -t'.
Thanks



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

Date: Fri, 13 Oct 2000 16:22:47 -0400
From: "Anthony Spina" <aspina@panix.com>
Subject: Re: How to use .pl csript on IIS to send mail to NT Exchange.
Message-Id: <8s7r51$fn8$1@news.panix.com>

use Net::SMTP;
no sendmail required.....


"Tony Lyn" <tlyn@mail.cccd.edu> wrote in message
news:39E76B38.A849EBF6@mail.cccd.edu...
> I am converting the .pl script from Unix to .pl script on the IIS
> server. I am using NT Exchange for mail. What do I use in place of
> "$mail='/usr/sbin/sendmail -t'.
> Thanks
>




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

Date: Fri, 13 Oct 2000 21:05:46 +0200
From: Per Kistler <kistler@gmx.net>
To: Carfield Yim <carfield@programmer.net>
Subject: Re: How to use bidirectional pipe at perl?
Message-Id: <39E75D0A.A220972C@gmx.net>

Extended example. First, what the other poster has mentioned already,
close the
W. But then one can use the IO::Select to get more control:

#!/usr/bin/perl

use IPC::Open2;
use IO::Select;
use IO::Handle;

$pid = open2(\*R, \*W, "wc -w");
$pid || die "did not work as expected:$!";

$io = IO::Select->new();
$io->add(\*R);

$word = "Hello World\n";
print W "$word";
close(W);

while( 1 ) {
        if ( ($who) = $io->can_read(0) ){
                $who->read($what,1000);
                unless( $what ){
                        # Readable but empty means closes
                        print "Connection closed\n";
                        last;
                }
                print $what;
        }
        if ( ($ex) = $io->has_exception(0) ){
                print "Exception: $ex\n";
                last;
        }
}

Per.


Carfield Yim wrote:

> The process is hold and like to wait for something, how can I solve this
> problem?


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

Date: Tue, 10 Oct 2000 19:00:25 +0200
From: Arno Oesterheld <oesterheld@gmx.de>
Subject: How to use Module when I can not install it
Message-Id: <39E34B29.FDA3C3CA@gmx.de>

Hi,

I have a Perlscript which needs Apache::AuthCookieDBI. But on the
Webserver I just have FTP access. So I can not install any new module.
Can I use the module when I put it in my CGI folder and set some
enviroment variables? Which variables must I set? Is there any other
way?

Thank you very much!

Best Regards,

Arno
-- 
    mm-develop  *  Arno Oesterheld  *  Softwareentwicklung
Telefon 02056.921445  *  Fax 02056.921446  *  Mobil 0177.2015492
               http://www.mm-develop.de


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Fri, 13 Oct 2000 22:40:47 +0100
From: "Sagar R. Shah" <Sagar.Shah@sid.cam.ac.uk>
To: Arno Oesterheld <oesterheld@gmx.de>
Subject: Re: How to use Module when I can not install it
Message-Id: <Pine.WNT.4.21.0010132239010.-273677@sscpc44.sid.cam.ac.uk>

> I have a Perlscript which needs Apache::AuthCookieDBI. But on the
> Webserver I just have FTP access. So I can not install any new module.
> Can I use the module when I put it in my CGI folder and set some
> enviroment variables? Which variables must I set? Is there any other
> way?

You can just creat a folder called /lib   (for example, it can be anything u
want)

Then create a folder with in that directorly called Apache and put the
AuthCookieDBI module in there.


Somewhere near the top of your perl script u must say

use lib qw(/lib); 

[or whatever u called the directory]

hope that helps



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

Date: Fri, 13 Oct 2000 10:41:38 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: html syntax check
Message-Id: <39E74952.F887A985@vpservices.com>

Per Kistler wrote:
> 
> Stefan Schubert wrote:
> >
> > does perl have an html-syntax checker and if so how do I aply it?
> 
> use HTML::QuickCheck ();

It looks like that module was last updated in 1995 and that it had perl
5 compatibility issues.  Is it actually any good?

-- 
Jeff


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

Date: Fri, 13 Oct 2000 20:12:59 GMT
From: frannyzoo@hotmail.com
Subject: installing perl in Win 98
Message-Id: <8s7qc4$77t$1@nnrp1.deja.com>

downloaded the msi file and my 98 doesn't seem to know what to do.
Godzilla either.  I see 95 needs a "dcom" and NT a SP4 or better.  No
mention of 98 problems..what to do?

scot


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 13 Oct 2000 16:23:35 -0400
From: "Anthony Spina" <aspina@panix.com>
Subject: Re: installing perl in Win 98
Message-Id: <8s7r6h$fnj$1@news.panix.com>

go back to where you downloaded the msi (activestate)
and get the "windows installer" per the instructions.....

<frannyzoo@hotmail.com> wrote in message news:8s7qc4$77t$1@nnrp1.deja.com...
> downloaded the msi file and my 98 doesn't seem to know what to do.
> Godzilla either.  I see 95 needs a "dcom" and NT a SP4 or better.  No
> mention of 98 problems..what to do?
>
> scot
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Fri, 13 Oct 2000 20:21:43 GMT
From: jonceramic@nospammiesno.earthlink.net (Jon S.)
Subject: Re: looking for links to Perl+mysql how-to's - tutorials etc
Message-Id: <39e76e74.2338206@news.earthlink.net>

On Fri, 13 Oct 2000 10:25:23 -0500, kelli norman
<kellikellin@netscape.net> wrote:

>"Jon S." wrote:
>> 
>> On Sat, 7 Oct 2000 12:00:59 +1000, "Robert Chalmers"
>> <robert@chalmers.com.au> wrote:
>> 
>> >Looking for links to sites with howto's - tutorials - examples - code
>> >examples and so on.
>> >
>> >Does anyone know of a couple of good ones they can recommend. I know - I
>> >could spend hours searching but maybe someone can offer a short cut.
>> 
>> I'm just a newbie, but...
>> 
>> I mainly found links for PHP and MySQL.  My standard places _online_
>> are the OReilly online chapter for the mSQL/MySQL book, the DBI/DBD
>> docs, and www.mysql.com.  You can also try slashcode.com for many
>> examples.  But, they're hard to grok if you're new at it, and not
>> necessarily the best form, etc. by nature.
>> 
>> But, the best tutorial I've found was "Programming the Perl DBI" from
>> OReilly.  A great book for the beginner who knows a little (or a lot?)
>> of Perl already.
>> 
>> Jon
>
>another good place is the mysql manual (located online at
>www.mysql.com).  look under the section entitled 'mysql client tools and
>apis' - there's a subsection entitled 'mysql perl api'.  i'm using mysql
>+ perl to collect and serve info via the web.  good luck.

It's in there!  I just buried it.  Yes.  I have actually printed most
of chapter's 7 and 11 of the mysql online docs to read and learn from
when I'm away from the computer.

For freeware/shareware, mysql.com has some great documentation.  The
writer of the DBI module for mysql also has a listserv that you can
get some great answers from.  Although, last time I checked, the only
way to find it at the mysql.com site is to look in the archives.  It's
not linked on the main mailing list page.  It's a very low volume
list.

Jon


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

Date: Fri, 13 Oct 2000 18:27:19 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Maintaining State on a TCP socket
Message-Id: <buIF5.44356$td5.6866645@news1.rdc2.pa.home.com>


"liliafan" <bmaynard@voodoox.net> wrote in message
news:39e580d4@news.jakinternet.co.uk...
> Looking at this can anyone hazard a guess as to why it closes and stops
> recieving.

Lots of issues -

> while ($remote = $local->accept()) {
>
>         $remote->autoflush(1);
>
>         FORK: {
>
>             my $kid = fork;

now you have two processes executing

>             if (defined($kid)) {

if the fork was successful, you still have both processess running here, as
the values of 0 and the PID of the child process are both defined

>                 my $nread = sysread($remote, $inp, 100000024);

Each process blocks at the above line waiting for data - since you are
probably testing the server via telnet, it slurps in the first character -
because there are now two processes, each one reads from the socket - the
only inprovement over the version without fork is now that two processess
are each slurping one piece of data

>                 chomp($inp); # Remove trailing \n from $inp
>                 if ($inp=~ /901/) { # If $inp is "901" terminate program
>                     close($local);
>                     print "*** Terminate Signal Recieved
> exiting....(exit(1))";
>                     unlink <pid.dat>;
>                     $dbh->disconnect();
>                     exit();
>                 } else {
>                      print "*** $inp\n"; # Else print to screen and
> datasource
>                     database_connect();
>                 }

Now the processing of the data has completed (once for each processes)

>         }
>         elsif ($! =~ /No more process/) {
>             sleep 5;
>             redo FORK;
>         } else {
>             print "Failed!"
>         }
>     }

Now you are looping back to the beginning of the while loop, waiting for
more connections - the script will no longer check the old connection for
data - you should probably investigate not using sysread (use normal
buffered input with < >) and investigate exactly what fork() does.
Something like

while(my $remote = $local->accept) { # new connection
    my $pid = fork();
    if ($pid) { # this is true in the parent process
        next; # go back and accept more connection
    } else { # else you are in the child process (or fork failed)
        while(<$remote>) { # process line input from socket
            # process remote information
        }
        exit; # make sure you don't loop back and listen for connections
    }
}

This should have some more fork() error checking and some zombie avoidance
code, but this should get you on your way

--Ben Kennedy








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

Date: Fri, 13 Oct 2000 12:30:25 -0700
From: alphathk@pacbell.net
Subject: Need help converting lots of Unix times
Message-Id: <39E762D1.3C31B91F@pacbell.net>

Could someone plase point me in the right direction?

Here's what I need to do:
I am collecting network traffic samples with an SNMP collector. The data
is stored with start times and end times in Unix Seconds since 1970
format. I need a script or some direction on how to run these ASCII data
files through a script and convert all of the Unix times into human
readable times. Here is a sample of what the data looks like:

966457078       966457138               459.483
966457138       966457198               49.35
966457198       966457258               17.5637
966457258       966457318               696.7
966457318       966457378               682.067
966457378       966457438               137.967

This is a very small snip-it from one of these files. Each file will
have about 900 of these entries.

Any help is appreciated.
Thanks.

Alphathk



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

Date: Fri, 13 Oct 2000 13:02:32 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Need help converting lots of Unix times
Message-Id: <MPG.14510a34c2c894b998ae35@nntp.hpl.hp.com>

In article <39E762D1.3C31B91F@pacbell.net> on Fri, 13 Oct 2000 12:30:25 
-0700, alphathk@pacbell.net <alphathk@pacbell.net> says...
> Could someone plase point me in the right direction?
> 
> Here's what I need to do:
> I am collecting network traffic samples with an SNMP collector. The data
> is stored with start times and end times in Unix Seconds since 1970
> format. I need a script or some direction on how to run these ASCII data
> files through a script and convert all of the Unix times into human
> readable times. Here is a sample of what the data looks like:
> 
> 966457078       966457138               459.483
> 966457138       966457198               49.35
> 966457198       966457258               17.5637
> 966457258       966457318               696.7
> 966457318       966457378               682.067
> 966457378       966457438               137.967

I assume you know how to read the files one line at a time and split 
each line into fields.

To convert the Unix-epoch time into a fixed-format string or into a list 
of date/time components:

    perldoc -f localtime

To convert the list output of localtime() to a formatted string:

    perldoc POSIX (and look for the 'strftime' function)

    perldoc -f sprintf

I sometimes instead just use substr() to pick apart the fixed-format 
string output of localtime().

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


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

Date: Fri, 13 Oct 2000 20:21:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Need Urgent help on File reading
Message-Id: <hmreusgike91a9tlt733spr46el73vka03@4ax.com>

Anders Lund wrote:

>I think you should buy a good perl book, like "Learning Perl" by Randolph 
>Schwartz.

Is that one or two L's in Randolph?

-- 
	Bart.


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

Date: 13 Oct 2000 20:30:17 GMT
From: jamest@rose.hp.com (Thompson_James)
Subject: NET::FTP and socks and firewall
Message-Id: <8s7rcp$9t5$1@web1.cup.hp.com>

We are having trouble with Net::FTP getting out threw a hole in our firewall.
here is the setup:

host1 sits behind our firewall. There is a hole punched in
the firewall that specifically allows host1 to get out to another
companys server.

We can use unix ftp to connect to the remote server.  socksified ftp
can NOT make the remote connection. The perl script with:
$ftp = Net::FTP->new("$remoteIP");
hangs until it times out with connection refused (same as sockified ftp).

my guess is that the perl script is somehow using the socksified network
libraries to connect to the remote host and is being stopped by the
firewall because it goes out with the proxies IP address rather then
host1 IP address.

so ...
How can I tell if perl is using the socks libraries and if it
is how can I make it use the regular libs. Or if I'm completely
off base what else should I try??

any help would be greatly appreciated.
thanks,

james_thompson@hp.com

~
~


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

Date: 13 Oct 2000 19:11:27 +0100
From: nobull@mail.com
Subject: Re: Perl conditional functions
Message-Id: <u9u2agy5kg.fsf@wcl-l.bham.ac.uk>

lkenny@fisheries.org (Liam) writes:

> Your method worked, but I am still having a slight problem.

Standing on your head perhaps?  Caught is a temporal inversion?

Or is there another reason for posting upside down?

>  Is there any reason why it won't read in my text once I do this.

Maybe it's being interferred with by the temporal inversion.  Have you
tried reversing the order of the satements?  If causes are happening
after effects in your corner of the universe then this may help.

> It will only print the variables with numerci values not 0 or 0.oo,
> but it neglects to print text variables.
> Any ideas?
> 
> 
>             if ($FORM{$name} != 0 || $FORM{$name} != 0.00) {

The numeric constands 0 and 0.00 are thre same.

!= is a numeric comparison operator.  It forces its operands to be
interpreted in a numeric context.  In a numeric context any
string starting with a non-numeric character is 0.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 13 Oct 2000 11:28:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl conditional functions
Message-Id: <MPG.1450f414e492fcd798ae33@nntp.hpl.hp.com>

In article <4fFF5.439$Uy5.30031@news000.worldonline.dk> on Fri, 13 Oct 
2000 16:45:31 +0200, Anders Lund <anders@wall.alweb.dk> says...
> Liam wrote:

 ...

> > In my conditional statement I want any of the variables with the value
> > of '0' to be disregarded from the rest of the program.
> > But I am not sure how to do this.  Is it possible to find out which
> > have the value of zero and remove them?

 ...

> for (keys %FORM) {
>       undef $FORM{$_} if ($FORM{$_} == 0);
> }

That does not remove the keys with value 0; it only replaces the value 0 
by undef, which is surely not what is wanted.

To remove the keys, replace 'undef' by 'delete'.  To do it compactly and 
efficiently, use a hash slice instead of a loop:

    delete @FORM{grep !$FORM{$_} => keys %FORM};

That will remove all 'false' values from the hash.

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


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

Date: Fri, 13 Oct 2000 12:10:09 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl conditional functions
Message-Id: <MPG.1450fdebf0dff9eb98ae34@nntp.hpl.hp.com>

In article <8s7hhn$lhl$1@sloth.swcp.com> on 13 Oct 2000 17:42:15 GMT, 
Tramm Hudson <hudson@swcp.com> says...
> Mark-Jason Dominus <mjd@plover.com> wrote:
> >        my @zeroes;
> >        for (keys %FORM) {
> >          push(@zeroes, $_) if $FORM{$_} =~ /^0+$/;
> >        }
> >        delete @FORM{@zeroes};
> 
> The original poster asked for ones of the form 0.0* to be removed, too.
> So that means that the RE should be /^0+\.0*$/, or something of that form.
> I don't know if 00000.000000 counts as "0" or not.

When stating what 'the original poster asked for', it is helpful 
actually to look, rather than to mischaracterize.

  In my conditional statement I want any of the variables with the value
  of '0' to be disregarded from the rest of the program.
  But I am not sure how to do this.  Is it possible to find out which
  have the value of zero and remove them?

  ...

  if ($FORM{$name} == 0) {
                    # what goes here to get those variables equal to 0

The first part implies the value of the string '0', but the second part 
explicitly states the numerical value 0, so I assume the quotes on '0' 
were intended for display here, not to indicate a string.  Therefore 
regex-based tests for various strings that evaluate to 0 are likely to 
fail.  For example, '0E0' etc.  Your own proposed regex above or the one 
below /^0+\.?0*$/ fail to detect '.0', for example.  What about '0 but 
true', or 'foobar'?

The proper solution requires a numerical test as posted originally 
(though in an earlier post, I used a Boolean test).  I am guessing that 
the values in the hash are all numbers, which makes it trivial.  The 
programmer must decide how to deal with strings that are not pure 
numbers and evaluate numerically to 0, which is not trivial.

 ...

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


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

Date: 13 Oct 2000 20:17:03 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Perl conditional functions
Message-Id: <8s7qjv$ql3$1@sloth.swcp.com>
Keywords: troll, troll, troll your post

Larry Rosler  <lr@hpl.hp.com> wrote:
> Tramm Hudson <hudson@swcp.com> says...
> > Mark-Jason Dominus <mjd@plover.com> wrote:
> > >        my @zeroes;
> > >        for (keys %FORM) {
> > >          push(@zeroes, $_) if $FORM{$_} =~ /^0+$/;
> > >        }
> > >        delete @FORM{@zeroes};
> > 
> > The original poster asked for ones of the form 0.0* to be removed, too.
> > So that means that the RE should be /^0+\.0*$/, or something of that form.
> > I don't know if 00000.000000 counts as "0" or not.
> 
> When stating what 'the original poster asked for', it is helpful 
> actually to look, rather than to mischaracterize.
> 
>   In my conditional statement I want any of the variables with the value
>   of '0' to be disregarded from the rest of the program.
>   But I am not sure how to do this.  Is it possible to find out which
>   have the value of zero and remove them?

The original post included that paragraph, in which, yes, he does
only ask about the value of zero.  In a follow up post,

	<39e728b0.12517378@news.volocom.net>

he posted this bit of code:

|           if ($FORM{$name} != 0 || $FORM{$name} != 0.00) {
|                   $FORM{$name} =~ tr/A-Z/0-9/;
|                   print "$FORM{$name}<br>\n";
|           }

which makes it appear that he might be looking for numbers with
forms other than just "0".  That is where I drew the conclusion that
Liam wanted to trap strings that might evaluate to zero in other
contexts.

> ... The first part implies the value of the string '0', but the second part 
> explicitly states the numerical value 0, so I assume the quotes on '0' 
> were intended for display here, not to indicate a string.  Therefore 
> regex-based tests for various strings that evaluate to 0 are likely to 
> fail.  For example, '0E0' etc.  Your own proposed regex above or the one 
> below /^0+\.?0*$/ fail to detect '.0', for example.  What about '0 but 
> true', or 'foobar'?

Yes, the regular expression form may fail on several values that do
evaluate to zero in numeric context.  As you said, trying to detect all
of them is rather rather difficult, and, in my mind, futile when Perl
supplies a means to directly test the numeric interpretation of a string.

At the heart of it is an underspecified problem.   mjd posted a RE based
solution to what he thought the problem was.  I followed up with an silly
solution that had no whitespace.  I even included headers stating that my
response was likely to be unhelpful.

Tramm
-- 
  o   hudson@swcp.com                  hudson@turbolabs.com   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.323.38.81   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.986.60.75   \ \/\_\  
  0                                                            U \_  | 


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

Date: Fri, 13 Oct 2000 19:33:42 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl rules - Pyhton drools
Message-Id: <x7r95kwn6x.fsf@home.sysarch.com>

>>>>> "JT" == James Taylor <james@NOSPAM.demon.co.uk> writes:

  JT> In article <8s6knk$mb4$1@ctb-nnrp2.saix.net>, Wayne Paterson
  JT> posted a 313K JPEG image which was 431K after UU encoding
  JT> and took a long time to download over my modem. This group
  JT> is not for binaries - post a URL instead. Also, learn how to
  JT> optimise graphics. Just by loading and resaving this JPEG it
  JT> dropped in size from 313K to 109K.

i skipped it just because of the size. what on earth was the image of? 

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 13 Oct 2000 21:05:59 GMT
From: nandagopalj@hotmail.com
Subject: Perl's open command on unix files
Message-Id: <8s7tfh$9u1$1@nnrp1.deja.com>



Hello:


The following error handler in my PERL script does NOT work.


    # Open a handle to the results of the grep
    if (!(open(GREP_H, "grep a $fileName | grep b |")))
    {
        $errorFlag = $FAILURE;
        print "Attempt to grep in file failed!";
    }

This does NOT catch the error if $fileName is unreadable.  The 'grep'
command fails, but the open command returns success.  How do I catch
this error?

Any help is appreciated.

-Thanks,
Nan,


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 13 Oct 2000 21:31:23 GMT
From: trammell@nitz.hep.umn.edu (John J. Trammell)
Subject: Re: Perl's open command on unix files
Message-Id: <slrn8ue5da.su.trammell@nitz.hep.umn.edu>

On Fri, 13 Oct 2000 21:05:59 GMT, nandagopalj@hotmail.com
<nandagopalj@hotmail.com> wrote:
>    if (!(open(GREP_H, "grep a $fileName | grep b |")))
>    {
[snip]
>This does NOT catch the error if $fileName is unreadable.

How about a "-r $filename" before you grep it?

-- 
John J. Trammell
johntrammell@yahoo.com


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

Date: Fri, 13 Oct 2000 11:10:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Plz help - Perl Q
Message-Id: <39E7501E.CED84A37@stomp.stomp.tokyo>

Uri Guttman scribbled with a Crayola crayon:
 
> Godzilla! intelligently articulated:
> > Uri Guttman suffered verbal diarrhea:
> > > Michael Cook wrote:

> > > > I have a Perl question & have read many many FAQs, books, web
> > > > sites (TY Godzilla), newsgroups, etc. I have almost got it, but am

> > > you have a major mistake listed there. you accepted help from
> > > moronzilla. you have to be decontaminated before any regulars can help
> > > you. any help you got from her is wrong and useless.

> > Your claiming Perl Online Documentation to be
> > wrong and useless does help to explain why you
> > know so little about Perl and Perl Programming.
 
> no, i am claiming and proclaiming with complete acclaim from this group
> that anything you say is tainted by your delusional psychosis. even if
> you happen to point someone to a correct source for an answer doesn't
> mean anything since a stopped clock is right twice a day. you could be
> shooting darts at perldoc and sometime hit the target. that doesn't mean
> you know anything.
 
> as for my perl skills, your statement doesn't seem to carry any weight
> here (other than your nutty baggage). i leave it to the group to decide
> if my posts are worthy to read. other than you, i don't seem to get many
> negative flames about them. hmmm, could it be that i have bribed
> everyone here? or could it be that you are a frigging idjit?



There is no doubt all readers of this newsgroup view
you as an appointed and anointed Godsend savior of
all Techno-Geeksters.


Godzilla!
-- 
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class


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

Date: Fri, 13 Oct 2000 19:30:52 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Plz help - Perl Q
Message-Id: <x7u2agwnbm.fsf@home.sysarch.com>

>>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:


  G> There is no doubt all readers of this newsgroup view
  G> you as an appointed and anointed Godsend savior of
  G> all Techno-Geeksters.

that is the first honest and truthful statement you have ever made
here. congratulations! now that you have done that, you can leave this
group in peace. go learn python. they have no modules so you can live in
their little world. they will love you. or even better, learn c# and
plague redmond. that'll teach them a lesson!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 13 Oct 2000 20:26:59 GMT
From: khw@drgpaxon.dr.lucent.com (Karl H. Williamson)
Subject: pod2man and long option names beginning with minus minus
Message-Id: <8s7r6j$jrv@nntpb.cb.lucent.com>

I am having trouble with the output of perldoc on a man page
that has options that begin with minus minus.  The minus
minus is often split at the end of the line with the option
name beginning at the beginning, like --
option.

Is there any way to prevent this?  The problem appears to
be in nroff/troff. I notice that the code generated has
stuff in it to try to create an unbreakable dash, but
I don't see how to get access to that.

Thanks in advance

Karl Williamson
Avaya Inc.
-- 
WilliamsonKH


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

Date: 13 Oct 2000 19:30:07 +0100
From: nobull@mail.com
Subject: Re: Problem using a module
Message-Id: <u9snq0y4pc.fsf@wcl-l.bham.ac.uk>

Don <don@lclcan.com> writes:

> I've downloaded and installed the DBD-XBase-0.161 module on my RedHat
> 6.2 Linux system.
> 
> When I insert the line:
> 
> use XBase;

Why did you do that?  Did the manual tell you to do so?  I'm not
familar with this module but from the name DBD-XBase-0.161 I'd expect
the module to be called DBD::XBase.  Modules in the DBD::* namespace
are not usually called directly, rather they are used by DBI. 

> in my perl script, I encounter "Internal Server Error" when attempting
> to execute my script from my browser.  Any idea what is wrong?

Have a look at the error log or: 

use CGI::Carp 'fatalsToBrowser';

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 13 Oct 2000 18:25:30 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: regex challenge
Message-Id: <1eigjbu.cr8yi01dnlypgN%tony@svanstrom.com>

Andrew N. McGuire  <anmcguire@ce.mediaone.net> wrote:

> On Thu, 12 Oct 2000, Dave O'Brien quoth:
> 
> DO> Uri Guttman wrote:
> DO> > 
> DO> > >>>>> "G" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:
> 
> [ snip ]
> 
> DO> >   >> you snipped the important part and didn't read the subject.
> DO> >   >> typical lack of reading comprehension from moronzilla.
> DO> > 
> DO> >   >> Subject: regex challenge
> DO> > 
> DO> >   G> You are correct. I missed all this header information.
> DO> >   G> Thank you for posting this. I shall be more careful
> DO> >   G> about reading all header content. This is important.
> DO> > 
> DO> > just read the subject header. so how could you have claimed the above
> DO> > article and then apologize for the lack of header parsing skills?
> DO> > 
> DO> > oh, it is moronzilla! logic need not apply.
> 
> [ snip ]
> 
> DO> My god!  An apology from Godzilla!  You are the man Uri. (or woman)
> 
> She was being sarcastic, then again you probably are too, and I am just
> to stupid to realize it. :-)

This is c.l.p.misc, here no one is sarcastic.

(hehe)


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Fri, 13 Oct 2000 18:19:26 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Splitting a scalar in two arrays
Message-Id: <39e7522e.48f6$129@news.op.net>
Keywords: Kaplan, Sirius, agitate, invertible


In article <slrn8uer5b.uj.aym@aym4.domicile.fr>,
Andre Majorel <amajorel@teezer.fr> wrote:
>>        @items = split /(the_good_regexp)/, $raw;
>
>That sounds like an excellent idea but how do you get split() to
>return both the fields *and* the delimiters ? 

You put the split pattern into parentheses, as I showed in the example.

See the documentation for 'split' for full details.


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

Date: Fri, 13 Oct 2000 20:34:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Splitting a scalar in two arrays
Message-Id: <rqreusc9pjat27v7gft8hgfh7jeisdld6r@4ax.com>

Andre Majorel wrote:

>I would like to slurp the whole file into a scalar, extract the
>parts of it that match the above to an array and save the parts
>that don't to another array.

That sounds like a candidate for this idiom:

	push @{ /regex/ ? \@good : \@bad }, $_ foreach @all;

Or something like it.

>  zone "somedomain.com" in {
>  type master;
>  file "somefile";
>  };
>
>  zone "otherdomain.net" in {
>  type master;
>  file "otherfile";
>  };

The condition looks to me to be:

	/^zone .* in \{/ .. /\}/

which allows you to process the file line by line.

I tried this on your message, and it seems to be working:

 push @{ /^ *zone .* in \{/ .. /\}/ ? \@good : \@bad }, $_ while <DATA>;
 print "Good:\n@good\n\nBad:\n@bad\n";
__DATA__
I'm processing a named.conf file that contains various stuff
 ...
(entire original post)

-- 
	Bart.


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

Date: Fri, 13 Oct 2000 15:05:12 -0400
From: David J Kernen <reddjk@usa.net>
Subject: Re: UNIX/PERL question
Message-Id: <39E75CE8.3E3A5AC4@usa.net>

Clay Irving wrote:

> On Tue, 10 Oct 2000 17:45:18 GMT, christophe.conseil@equifax.com
> <christophe.conseil@equifax.com> wrote:
>
> >Just trying to understand the following:
> >I have a perl test program:
> >
> >first line: #!/usr/local/bin/perl -w
> >I made sure it is executable.
> >
> >Now when I type test file1>file2 no error but nothing is written
> >to file 2.
>
> Do you have anything past the first line of your program?
>
> --
> Clay Irving <clay@panix.com>
> Oh look, my brain just exploded! Cool idea, though.
> - Carl Rigney

Better yet, are you running your program? See if it behaves differently
when you say: ./test file1>file2

I don't know what Unix you're using or what shell, but I've used
different unixes with different shells and a lot of them have
/usr/bin/test (so if your own sudir is in your PATH it had better be
first) and some shells even have a built-in test command (so you'll need
a path regardless of where your subdir is in your PATH).

DjK



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

Date: Fri, 13 Oct 2000 21:28:04 GMT
From: tltt@my-deja.com
Subject: Re: UNIX/PERL question
Message-Id: <8s7uos$aut$1@nnrp1.deja.com>

[off-topic]
dperham@wgate.com wrote:
> there is also a UNIX command called 'test' (and many shells implement
it
> as an intrinsic function). it is this function that is getting called
> instead of your perl script because it is your PATH first or it is
> intrinsic in your shell.  try typing
>
>  ./test file1>file2
>
> by putting the explicit path, you avoid the ambiguity. otherwize you
can
> rename your perl script to 'ptest' or something like that.
>
> fyi, type
>
>    which test
>
> to find out which 'test' script you were truly executing
>

However "which" will not display shell builtins, so it is more accurate
to use "type" (in bash) or "whence -v" (in ksh). I'm afraid I can't help
if you are using another shell.

tltt


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 13 Oct 2000 20:10:41 +0200
From: =?iso-8859-1?Q?K=E5re_Olai_Lindbach?= <barbr-en@online.no>
Subject: Re: Win32-API.zip
Message-Id: <geIF5.5346$W31.81468@news1.online.no>


<martinsegersten@my-deja.com> skrev i melding
news:8s7485$j62$1@nnrp1.deja.com...
> Hi!
>
> I would like to get the  module "Win32-API.zip" to access general
> windows-api functions. I've tried to download it from the web-page :
>
> http://www.activestate.com/PPMPackages/zips/5xx-builds-only/
>
> but it fails... Could anyone please help me either by mail me the zip-
> file or explain what I can do.

You have ActiveState Perl.  And need something for your win32-machine?

Why don't you use PPM?

Build 5XX ???  This I haven't tried!
Then try:
DOS> ppm install --location=http://www.activestate.com/PPMPackages
/5.005   Win32-API
(*all on one line*)

All new downloads of Perl are version 5.6, build 61X.
Then use:
DOS> ppm install --location=http://www.activestate.com/PPMPackages
/5.6    Win32-API
(*all on one line*)


Hope this helps

Regards Kåre



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4611
**************************************


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