[21739] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3943 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 9 21:06:34 2002

Date: Wed, 9 Oct 2002 18:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 9 Oct 2002     Volume: 10 Number: 3943

Today's topics:
    Re: "my" a reserved word? <chuckmg@acm.org>
    Re: Accessing Oracle Database from Unix using Perl <pkent77tea@yahoo.com.tea>
    Re: An RE to encode XML entities <cpryce@pryce.nospam.net>
    Re: Anyone who uses Perl on VAX <pkent77tea@yahoo.com.tea>
    Re: cgi.pm code <joe+usenet@sunstarsys.com>
    Re: cgi.pm code <REMOVEsdnCAPS@comcast.net>
    Re: cgi.pm code (Jay Tilton)
    Re: Fast Stat <REMOVEsdnCAPS@comcast.net>
    Re: Fast Stat <pkent77tea@yahoo.com.tea>
    Re: GMT Windows vs Linux <ddunham@redwood.taos.com>
        Hello World doesn't work in 5.8?? (milkfilk)
    Re: How can I tell what version a module is? <dd@4pro.net>
    Re: How can I tell what version a module is? <pobugfix@peterlink.ru>
    Re: How can I tell what version a module is? <REMOVEsdnCAPS@comcast.net>
    Re: Multiple Pings/Second <troc@netrus.net>
    Re: newbie with datatype prob (safari)
        paragraph mode read a filehandle <sun_tong_001@yahoo.com>
    Re: Please help me with my Redirection script. (Jay Tilton)
        Re-entrant parser (AGoodGuyGoneBad)
    Re: Run perl script on web server from command line <junk.kingsley@sympatico.ca>
    Re: Run perl script on web server from command line (Tad McClellan)
    Re: Run perl script on web server from command line <wsegrave@mindspring.com>
        String manipulation help needed <nospamrbailey@gbronline.com>
    Re: String manipulation help needed (Tad McClellan)
        tied hash consumes all memory <stanton@lightlink.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 09 Oct 2002 23:07:24 GMT
From: Chuck Goldstein <chuckmg@acm.org>
Subject: Re: "my" a reserved word?
Message-Id: <3DA4B6AE.B7665A5C@acm.org>

John,

Many thanks.  Just the input I needed.  My basic problem was twofold:  1) an
outdated copy of Wall's Programming Perl and 2) didn't know how to access
the help docs in Win32.  Have already ordered Wall's 3rd Ed and, thanks to
you, am now up on the curve of accessing the documentation.

Regards,
Chuck

"John W. Krahn" wrote:

> Chuck Goldstein wrote:
> >
> > Used find2perl translator in version 5.6.1 (Win32) on a
> > simple 'find' for instructional purposes.   The resulting
> > Perl code included a subroutine doexec:
> > sub doexec {
> >     my $ok = shift;
> >     for my $word (@_)
> >         { $word =~ s#{}#$name#g }
> > ...
> >    return !$?;
> > }
> >
> > The 'my' looks like a similar construct from C++ but I can't
> > find any documentation on it.   Any help in pointing me in
> > the right direction wrt to documentation?  Am a newbie at
> > Perl and, apparaently,  haven't found my way to the right
> > docs.
>
> my() is listed in the perlfunc document that is installed with Perl.  To
> get help on Perl's builtin functions type this on the command line:
>
> perldoc -f my
>
> To list the complete perlfunc document:
>
> perldoc perlfunc
>
> For an intro and a list of the other documents:
>
> perldoc perl
>
> For information on how to use the perldoc program:
>
> perldoc perldoc
>
> John
> --
> use Perl;
> program
> fulfillment

--
Chuck

Charles M. Goldstein
10751 Durland Ave NE
Seattle, WA 98125
(206)362-2999




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

Date: Thu, 10 Oct 2002 00:14:44 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Accessing Oracle Database from Unix using Perl
Message-Id: <pkent77tea-C904AD.01144410102002@news-text.blueyonder.co.uk>

In article <Gu_o9.28551$PO2.489952@castor.casema.net>,
 "Shivakumar Gopalakrishnan" <shivag@wanadoo.nl> wrote:

> a small database in Access. I am trying to help them to migrate to Oracle
> under Linux(Which they are trying to get it for free). I would like to

AFAIK Oracle is free for personal and non-commercial use. The corollary 
is that Oracle is fscking expensive for commercial use :-) I think you 
should be OK but consult your friendly legal representative, or maybe 
Oracle themselves, to check.

> convert their interfaces to be html based using Perl (If it is not that
> complicated).

It's been done many times, so yes that's cool... but wait! You can do it 
other ways!
* I think Oracle can present an ODBC interface, which means you can have 
an oracle back end but you can use all the power of Access' GUI, forms, 
widgets, etc.
* SQL*Forms or Forms*Plus or whatever it's called is not limited to 
forms on dumb terminals! You can, so I learnt, use oracle forms to 
create a web interface to the database that is actually served up by 
oracle itself. No CGI required at all, no web server, no DBI. All done 
by oracle.

* Or yes run apache, perl, or mod_perl, and DBD::Oracle and fetch data 
from the database.

I've found this last approach completely fine for reading the data, but 
any kind of data entry stuff just screams for teh sophistication and 
integration that Forms or Access (the front end bit) can provide.

> It will be nice if someone points me to some examples which will help me in
> the process.

I think, although I can't check as my machine doesn't have the software, 
that DBI and DBD::Oracle have all the examples you need to get started. 
I think that's all I needed to start getting rows back.
Use a templating module to help out with presenting the results as HTML, 
and get simple command-line programs working first before writing a cgi 
version.
My first DBI program was something that basically did 'SELECT * FROM 
testtable' and variations of of fetchrow_arrayref(), fetchrow_hashref() 
etc and used Data::Dumper to print the result, but it proved everything 
worked without the complication of being a cgi.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Thu, 10 Oct 2002 00:04:18 GMT
From: cp <cpryce@pryce.nospam.net>
Subject: Re: An RE to encode XML entities
Message-Id: <091020021909323828%cpryce@pryce.nospam.net>

In article <Pine.LNX.4.40.0210092310240.5668-100000@lxplus076.cern.ch>,
Alan J. Flavell <flavell@mail.cern.ch> wrote:

> > A good case to keep in mind, thank you. My immediate problem was that one
> > editor turned in '"Final Plans & Specs" and another presented "Final P, S
> > &amp; E", having converted MS word to html before submitting. It is often
> > not consistent, but it will either be valid XHTL or plain ASCII with illegal
> > characters.
> 
> Then IMHO you'll probably want a preliminary sniff at each piece you
> got, and set a flag as to whether it's HTML-flavoured or
> plaintext-like, and let subsequent processing be dependent on that.

A good idea. I can, for instance, change the extension of the file, and
let my pre-processing script have a go, depending on the extension.
> 
> Btw, remember for proper results if you're getting those bogus
> &#number; references from MS where 'number' is in the range 128-159
> decimal, you'll need a lookup table of unicode values, since XML rules
> out 128-159 as illegal.  

Any idea where I can find a reference on those values?

Thanks for the advice

-- 
cp

remove 'nospam' to reply


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

Date: Thu, 10 Oct 2002 00:19:38 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <pkent77tea-58B773.01193910102002@news-text.blueyonder.co.uk>

In article <32b689fe.0210091048.250d0c2f@posting.google.com>,
 ph3arnot@hotmail.com (Ph3arnot) wrote:

> An interesting note, the version of perl that is running on our
> VAX/Alpha cluster DOESN'T have a "chomp" command.  I haven't even

Gah! OpenVMS and an ancient version (or bizarrely patched) of perl.

What happens if you run 'perl -v' and 'perl -V' or whatever the 
equivalent is under the DCL shell? You should get information about the 
build of perl.
Has your sysadmin installed several versions of perl, and you're 
accessing but one of them (apaprently perl 4 if its missing chomp()).

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: 09 Oct 2002 19:06:47 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: cgi.pm code
Message-Id: <m3lm57w6t4.fsf@mumonkan.sunstarsys.com>

Todd Anderson <todd@mrnoitall.com> writes:

> Dear sirs,
> Below is code that should replace /n with <BR>. It doesn't work.
> Any help is appreciated.
> Thanks in advance.

[...]

> foreach $thingy(@display_items){
> param('$thingy'  => ~ s/\n/<BR>/g);
> }
> 

What sort of warning messages do you get when perl compiles
this code?  Are those warnings relevant to the problem you're 
having?

-- 
Joe Schaefer        "The only thing that interferes with my learning is my
                                         education."
                                               --Albert Einstein


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

Date: Wed, 09 Oct 2002 19:21:05 CDT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: cgi.pm code
Message-Id: <Xns92A2CEE5D2FFFsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Todd Anderson <todd@mrnoitall.com> wrote in news:3DA48204.E24F2848
@mrnoitall.com:

> Dear sirs,
> Below is code that should replace /n with <BR>. It doesn't work.

I assume you mean \n.

"It doesn't work" isn't very helpful.  What are you expecting that isn't 
happening?

> Any help is appreciated.
> Thanks in advance.
> 
> @display_items  = (
> "realtorpage",
> "text",
> "picture1_caption",
> "picture2_caption",
> "picture3_caption",
> "picture4_caption"
> );

What /n (or \n)?

> foreach $thingy(@display_items){
> param('$thingy'  => ~ s/\n/<BR>/g);

What do you expect this syntax to do?

You have a variable enclosed in single quotes, so it won't interpolate.
You have the => operator, which makes param() have two arguments.
You use ~ all by itself, which makes it a binary NOT operator.
You have a s/// with no variable name specified, so it uses $_.

What your expression does is the following:
    It substitutes <BR> for newlines in $_.
    It performs a binary NOT on the count of those newline substitutions.
    It sets the CGI parameter named $thingy (the literal string 
'$thingy', not the parameter named by $thingy) to the result of that NOT.

Using my crystal ball to divine the question that you didn't ask, I am 
guessing that what you want to do is to fetch the values of several CGI 
input parameters (named in @display_items), and replace newlines with 
<BR> for each of those values.  (Hey, Miss Cleo's out of business now, 
maybe I've got a shot).

Something like this, maybe?

    foreach $var (@display_items) # Loop over all interesting variables
    {
        my $value = param($var);  # fetch the value
        $value =~ s/\n/<br>/g;    # use lowercase HTML tags, please!
        param($var, $value);      # set the value
    }

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPaTHv2PeouIeTNHoEQKOpwCcDppbBXe/7WHSklgEvxkQ7bmhjrAAoPdp
Y9xtDQkDdjQ1yKx7z18oW3DA
=AvZS
-----END PGP SIGNATURE-----


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

Date: Thu, 10 Oct 2002 00:47:29 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: cgi.pm code
Message-Id: <3da4bfeb.176270615@news.erols.com>

Todd Anderson <todd@mrnoitall.com> wrote:

| Below is code that should replace /n with <BR>.

"/n" ?  You mean "\n" .

Replace \n with <BR> in what string(s)?

| It doesn't work.

Accurately describing a problem is the first step to solving it.
"Doesn't work" is the vaguest description imaginable.

What should the program do that it does not?
What is the program doing that it shold not?

For example,

    I expect this code to replace "\n" with "<BR>" in the values of
    some chosen CGI parameters.  Instead, it leaves them untouched,
    and adds another parameter named "$thingy" whose value is always
    4294967295.

That's something to work with.

| foreach $thingy(@display_items){
| param('$thingy'  => ~ s/\n/<BR>/g);
| }

It's a jumble of mistakes.

1. Single quotes don't interpolate variables.  '$thingy' is a literal
string having nothing to do with the value in $thingy.
2.  ~ is the bitwise negation operator.  =~ is the one that binds a
string to a m// or s/// operator.
3.  There's no string to bind s/// to anyway.  It's working on $_ .

So, assuming $_ contains no "\n" characters, s/\n/<BR>/g returns a
value of 0,  ~ inverts it into 4294967295, and that value is assigned
to the parameter named "$thingy".

Instead of trying to do everything in one stroke, bust the task up
into a few discrete but digestible tasks.

    foreach my $thingy (@display_items) {
        my $value = param( $thingy ); # Get the parameter value
        $value =~ s/\n/<BR>/g;        # Alter it
        param( $thingy, $value );     # Put the altered value back
    }



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

Date: Wed, 09 Oct 2002 19:22:53 CDT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Fast Stat
Message-Id: <Xns92A2CF33F4DF9sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"George C. Demetros" <demetros@vnet.ibm.com> wrote in
news:3DA47D6D.22AA653D@vnet.ibm.com: 

> Hi.
> 
> I need to stat across the ocean and I was wondering of there was
> anything out there that would do a stat more efficiently than the
> built in perl function.  I am aware of using the underscore to speed
> things up, i.e.: 

I suspect that stat() isn't your problem.  What's the latency time for the 
connection?  Any time you have to look at a remote file, you're going to 
have to contend with that, no matter how you're doing the stat.

A stat should take milliseconds or less.  If you have latency problems, a 
faster stat won't help.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPaTILmPeouIeTNHoEQKQhACfaU2ZFTl6gD0lGqbG0fcKJjwvdaQAoJeS
UoKNM1SP8j33LQhYPbDBA/CI
=AwTa
-----END PGP SIGNATURE-----


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

Date: Thu, 10 Oct 2002 00:36:18 GMT
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Fast Stat
Message-Id: <pkent77tea-E01344.01361710102002@news-text.blueyonder.co.uk>

In article <3DA47D6D.22AA653D@vnet.ibm.com>,
 "George C. Demetros" <demetros@vnet.ibm.com> wrote:

> I need to stat across the ocean and I was wondering of there was anything out
> there that would do a stat more efficiently than the built in perl function.  
> I
> am aware of using the underscore to speed things up, i.e.:

I guess it depend whether you're statting the _same_ file >1 times, or 
whether you're statting e.g. lots of files 1 time each. The underscore 
filehandle is probably only going to be useful when statting a file many 
times.

stat() calls the operating system's stat(3) function or equivalents - 
it's just a wrapper around a system call TTBOMK.
stat() returns values so why not just go
my ($foo, $bar,....) = stat($foo);
or whatever and use the appropriate variables many times in the 
following bit of code?

You could try benchmarking (use Benchmark;) example code as you would be 
using it (e.g., statting 100 files in 10 directories, or statting 1 file 
25 times, or whatever) using the builtin stat and using the syscall 
interface, and also coding your own little XS module.

Also, profile the rest of your code to see if there are other, maybe 
better, places to optimize (if applicable). It could be that stat() is 
not a problem, or it could be that the stat() goes over NFS to a server 
in Wyoming, which is going to be slow in any case.

P

-- 
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply


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

Date: Wed, 09 Oct 2002 22:24:03 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: GMT Windows vs Linux
Message-Id: <702p9.2519$uL3.145525950@newssvr14.news.prodigy.com>

J. Dawson <nospam@fakedomain.com> wrote:
> Here is the input/output you mention.

> $ perl -le 'print scalar localtime'
> Wed Oct  9 15:06:30 2002
> $ date
> Wed Oct  9 15:06:48 CDT 2002
> $ perl -le 'print scalar gmtime'
> Wed Oct  9 20:07:22 2002
> $ date -u
> Wed Oct  9 20:07:32 UTC 2002
> $ echo $TZ
> $ perl -le 'print $ENV{TZ}'

I don't see the output for the last 2 lines, but everything else is
working okay, so I guess Linux just doesn't use the $TZ variable as the
container for the timezone setting.

I'm assuming that CDT is US Central Daylight Time.  If so then
everything looks correct to me.

Central is 6 hours behind UTC, or 5 hours behind when DST is in effect.
15 - 20 = -5.

London is likely also in BST (British Summer Time) at the moment, so
they are now one hour removed from UTC.  (so you're 6 hours behind
London, but not UTC).

> I am surprised that they are the same between perl output and the system
> output.  I will collect the code from my script and check it again and post
> it and any results I conclude.

What time do you expect UTC to be at 3pm CDT?

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: 9 Oct 2002 17:43:49 -0700
From: milkfilk@yahoo.com (milkfilk)
Subject: Hello World doesn't work in 5.8??
Message-Id: <90d82e70.0210091643.2ee7a5f3@posting.google.com>

Am I insane?

__________________________________________________
[milkfilk@computer scripts]$ perl -e 'print "hi";'
[milkfilk@computer scripts]$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Ok ... maybe my shell is screwy.


__________________________________________________
[milkfilk@computer scripts]$ cat HelloWorld.pl
#!/usr/bin/perl
print "Hello World!";

[milkfilk@computer scripts]$ perl -c HelloWorld.pl
HelloWorld.pl syntax OK
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Well of course the syntax is ok!

__________________________________________________
[milkfilk@computer scripts]$ perl -W HelloWorld.pl
[milkfilk@computer scripts]$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Perl is broke.  Unreal.  I'm not really looking for an answer, I'm
just posting this so that someone out there doesn't feel as confused
as I do right now.

RedHat 8.0, Perl, v5.8.0


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

Date: Wed, 9 Oct 2002 18:38:32 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: How can I tell what version a module is?
Message-Id: <ao2b63$isf2b$1@ID-159100.news.dfncis.de>

print IO::Socket::SSL::VERSION;

should works

--
-.. --- -- .. --.. .. ---
-.. . -- .. -.-. .... . .-.. .. ...


"user" <du_bing@hotmail.com> wrote in message
news:3DA4A7C6.9078B253@hotmail.com...
> Specifically, I need to know what IO::Socket::SSL version we have.
> Reading its manpage did not give me any clue.  It does not have a
> version method.
>
> Thanks for any hints,
>
> Bing
>




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

Date: Thu, 10 Oct 2002 02:12:58 +0400
From: "Andrew V. Tkachenko" <pobugfix@peterlink.ru>
Subject: Re: How can I tell what version a module is?
Message-Id: <ao29eh$msg$1@news.sovam.com>

user wrote:
> Specifically, I need to know what IO::Socket::SSL version we have.
> Reading its manpage did not give me any clue.  It does not have a
> version method.
> 
> Thanks for any hints,
> 
> Bing
> 

try to run it from command line:

perl -MIO::Socket::SSL -e 'print  $IO::Socket::SSL::VERSION'



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

Date: Wed, 09 Oct 2002 19:10:26 CDT
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How can I tell what version a module is?
Message-Id: <Xns92A2CD17CCBA3sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

user <du_bing@hotmail.com> wrote in news:3DA4A7C6.9078B253@hotmail.com:

> Specifically, I need to know what IO::Socket::SSL version we have.
> Reading its manpage did not give me any clue.  It does not have a
> version method.

Most modules have a $VERSION variable that tells you the version.

I always put a =head1 VERSION section in my documentation; I wish more 
people would do that.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPaTFQmPeouIeTNHoEQJpPQCg8pmDlhKIO+v0thdECmVu0Wvbv+IAnjLB
CGE9+JNJ+/pYKjcBRgK/G7Yy
=EaAX
-----END PGP SIGNATURE-----


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

Date: Wed, 09 Oct 2002 22:49:56 -0000
From: Rocco Caputo <troc@netrus.net>
Subject: Re: Multiple Pings/Second
Message-Id: <slrnaq9cke.8ma.troc@eyrie.homenet>

On Wed, 9 Oct 2002 11:50:00 -0500, Kevin Vaughn wrote:
> I'm writing a script with the intent of pinging up to 1500 hosts
> within a one minute time frame.  I have decided to take up this
> project using Perl, but I'm getting stuck.  I am somewhat of a
> newbie (been programming in Perl for a couple of months).

POE::Component::Client::Ping is a non-blocking ICMP pinger.  It takes
more work to get going than Net::Ping, but it has the benefit of
letting you run multiple pings in the same process.

See http://poe.perl.org/?POE_Cookbook/Pinging_Multiple_Hosts for a
very simple example of pinging several hosts at once from a single
process.  Be aware, though, that it pings its list of hosts all at
once, which won't work in your case.

> My problems started because I haven't found a Perl module or other
> application that will let me ping as fast as I need to.  The best
> application that I've found is called fping, which is a CLI pinger
> that can do multiple hosts at the same time.  Unfortunately, if a
> host is down, fping can take a while to return the results.  About
> the fastest I could ping 1500 hosts using fping is 10 minutes.

That may be your problem now, but once you begin pinging as fast as
you like, you may find that the problem turns into "I never receive
responses from hosts I know are alive".

The problem there is that ICMP isn't a reliable protocol.  1500 hosts
over 60 seconds is an average of 25 ICMP echo/reply pairs (50 packets)
per second.  Some packets are bound to get lost in the shuffle,
resulting in erratic host statuses.

You may be able to send far fewer than 1500 echo requests if your
operating system and routers allow you to ping subnet broadcast
addresses.  This practice has been abused in recent years, though.
Newer operating systems disable the feature by default, and
responsible router administrators don't allow such packets through
their gateways.

> So I started thinking - what if I could farm out a portions of the
> 1500 hosts, say in blocks of 50, to child processes and have those
> children do the pinging.  Then I would end up with 30 Perl processes
> that would each take around 15-20 seconds to execute.  I haven't
> dealt with processes yet.  Are there caveats to scripting this way?
> How many processes is too many?  Is there a way to launch the child
> processes and not have them return?

It's certainly doable.  Check your ps listing to see how much
memory/cpu each process takes, then multiply that by the number of
processes you want to manage.  Tune the numbers until they hit the
sweet spot between speed and resource consumption.

> I have to call fping using the "system" command.  AFAIK, the only
> way to capture the results of fping is to send the output to a file
> via ">>".  Is there a better way?  If not, what would be the best
> way to take groups of 50 from a hash or array and feed them to the
> child process?

system() won't work here.  You should look at IPC::Run or IPC::Open3
(possibly even just perldoc -f open) to spawn concurrent ping programs
and gather their output.

It's cheezy to redirect their output to a file, but again it's doable.
If you'd rather gather the information as the programs run, however,
take a look at open() or IPC::Run or IPC::Open2.  You'll also need to
look at IO::Select to watch all the processes at once.  I think
Benjamin Goldberg might have a ready example of how to do this.

> I know this is a bunch of questions.  I would appreciate your help
> in answering any of them.

Good luck!

-- Rocco Caputo / troc@pobox.com / poe.perl.org / poe.sf.net


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

Date: 9 Oct 2002 16:34:48 -0700
From: safa5952@mail.usyd.edu.au (safari)
Subject: Re: newbie with datatype prob
Message-Id: <1a518d50.0210091534.1286dafe@posting.google.com>

Thanks heaps to Tad, Jeff and Helgi. This group ain't half as scary as
I anticipated ;)

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnaq8e1t.2ee.tadmc@magna.augustmail.com>...
> safari <safa5952@mail.usyd.edu.au> wrote:

> > (line 17 is the if(($CustomerID>= 1000002)...
> 
> When perl says "uninitialized value", think "I used undef when
> I probably didn't mean to".
> 
> $CustomerID got a value of undef somehow or another.
> 

so can I just confirm that there's no problem for $CustomerID to
contain eight digits, starting with a zero, and be tested against
seven digit numbers. Perl's pretty smart, isn't it, in knowing they're
both normal integers (not octo)?

> 
> > line 201 is print SENDMAIL <<"EOF";)
> 
> Add "use strict;" for even more goodness.

will do. ta.

> 
> > $CustomerID = param('CustomerID');
> 
> Are you certain that you have a form parameter with that exact
> name, and that it was given a value?

yeah. There's some javascript on the form ensuring 8-digit CustomerID
is entered.

> 
> Did you type in (or redirect) a value for it when testing
> at the command line?

yep :( I've done what everyone's suggested but am still really unsure
what I'm doing wrong. I thought using >= might be messing things up
abit. Should it be ge instead, maybe?

thanks,
safari


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

Date: Thu, 10 Oct 2002 00:00:36 GMT
From: * Tong * <sun_tong_001@yahoo.com>
Subject: paragraph mode read a filehandle
Message-Id: <3DA4C324.19D99F79@yahoo.com>

Hi, 

How can I read texts from a filehandle in paragraph mode? 

I.e., why not the following code give me paragraph mode results? I still
get lots of empty lines.

	my $msgbodyfh = $nntp->bodyfh($first);

	# read in the body in paragraph mode
	local $/="";
	@newsarticle = ();
	while ($bodyline=<$msgbodyfh>) {
	    push(@newsarticle, $bodyline);
	}

Thanks. 

-- 
Tong (remove underscore(s) to reply)
  *niX Power Tools Project: http://xpt.sourceforge.net/
  - All free contribution & collection


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

Date: Wed, 09 Oct 2002 22:20:56 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Please help me with my Redirection script.
Message-Id: <3da44b12.146353386@news.erols.com>

On 9 Oct 2002 05:03:10 -0700, danielrc15@hotmail.com (drc15) wrote:

| I am using the following redirection script, (quite a popular one).

[snip]

| I am calling the script in the following way:
| 
| <a href="www.myurl.com/cgi-bin/redirect.pl?url=http://www.myurl2.com/b.asp?A=1234&I=1899">LINK</a>
| 
| I thought the '&' would get turned into '%26' on the url line, but it
| does not 

Why would that happen?  The href field is a literal string.

| but, if you do this manually the redirection works.

So do the escaping when the HTML is generated.



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

Date: 09 Oct 2002 22:42:56 GMT
From: agoodguygonebad@aol.com (AGoodGuyGoneBad)
Subject: Re-entrant parser
Message-Id: <20021009184256.25146.00008893@mb-fw.aol.com>

>From: "Domizio Demichelis"

>I have to parse and change a string containing simple start and end labels
>of the form {a} and {/a}.

snip

This should get you started.
$hits = 0;
$string='aaa {a} bbb {a} xxx {a} yyy {/a} xxx {/a} ccc {a} ddd {a} eee {/a}';
$_=$string;
 while($_ =~ m/{a}.*?{\/a}/ig) {
print "$&\n";
$hits++;
}
print "Hits are $hits\n";


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

Date: Wed, 9 Oct 2002 17:54:53 -0400
From: "Chuck" <junk.kingsley@sympatico.ca>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao28i7$ht$1@moonstone.imsb.nrc.ca>

Thanks for your suggestion but I will also need to automate it so a one-step
procedure is needed.  Could a perl script on the local computer be written
to execute the script on the remote web server?

Thanks


"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:ao23eq$vtv$1@nntp9.atl.mindspring.net...
> "Me" <ignore@nobody.com> wrote in message
> news:ao1sis$tfr$1@moonstone.imsb.nrc.ca...
> > I have a perl script on a web server which can of course be executed
from
> a
> > web browser.
> >
> > i.e. http://www.my.server/scripts/myperl.pl
> >
> > Is there any way I can execute this script from a Windows 2000 command
> line
> > instead of going through the browser ?
>
> Clarification:
>
> Your question is not really a perl programming question; so it is probably
> off-topic for this newsgroup.
>
> On re-reading your question, however, if I interpret your question
> literally, I see you may be trying to execute the script on the computer
> that is the host of the web server. Try the following:
>
> 1. Establish a telnet session on the computer that is hosting the web
> server.
>
> 2. Navigate to the directory where your scripts are stored.
>
> 3. Type "perl myperl.pl" at the command prompt of the telnet session.
>
> In my previous response, telnet is not required, as the contemplated
action
> applied to execution of the script on the client computer, which requires
> Perl to be installed on the client computer.
>
> Bill Segraves
>
>




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

Date: Wed, 9 Oct 2002 17:08:04 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Run perl script on web server from command line
Message-Id: <slrnaq9a64.3ki.tadmc@magna.augustmail.com>

Me <ignore@nobody.com> wrote:

> I know that I can execute a script that is
> running on the local computer (i.e. perl c:\myperl.pl).  


If you have telnet access to a remote computer's command line,
then you would start it similarly (perhaps adjusting for the OS).


> What I want to do
> is execute a script that is on a remote web server.  I would normally do it
> from the web browser but I want to be able to do it from a command line.


You want to write a Perl program that "looks like" a browser
when viewed by the web server?

There is only one answer to that, use the LWP module.

   http://search.cpan.org/author/GAAS/libwww-perl-5.65/lib/LWP.pm



[snip upside-down quoted text. Please do not do that.]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 9 Oct 2002 19:35:18 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao2i0k$4gs$1@slb7.atl.mindspring.net>

"Chuck" <junk.kingsley@sympatico.ca> wrote in message
news:ao28i7$ht$1@moonstone.imsb.nrc.ca...
> Thanks for your suggestion but I will also need to automate it so a
one-step
> procedure is needed.  Could a perl script on the local computer be written
> to execute the script on the remote web server?

NO, "perl" is the name of the executable program. I think you mean "Perl
script, in which case the answer is "Yes".

Please don't top post to this newsgroup.

Yes. Hint: Read the documentation for Net::Telnet and Net::SSH::Perl at
ActiveState.com. http://aspn.activestate.com/ASPN/Modules

BTW, you stated earlier (using another identity) that you already have
Activre State Perl. Didn't you check the docs to see if you could find the
answer to your questions? Also, you'd get higher quality answers if you'd
ask your _real_ question in your first post.

Given the zeal with which the regulars on this newsgroup expect you to read
and observe the posting guidelines, I'm surprised you haven't already found
the answer to your own question.

Bill Segraves




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

Date: Wed, 9 Oct 2002 18:45:13 -0500
From: "Rob" <nospamrbailey@gbronline.com>
Subject: String manipulation help needed
Message-Id: <v8SdnUb4G90QIjmgXTWcqw@News.GigaNews.Com>

I am working on a script that will encrypt a text file using one of a couple
of different methods for a homework assignment and I have hit a snag.  I
need a way to be able to manipulate the string on a binary level.

Consider the following:



$test_string = 'a rose by any other name would smell as sweet';

@A = unpack("B*", $test_string);



I was expecting $A[0] to contain the ASCII code for an a (in binary) and
$A[1] to contain the ASCII code for a space (in binary) etc.

However, I am actually getting a huge binary string in $A[0]

How can I spit this long binary string into 8 bit increments?

Or is there a way that I can unpack each character into a different element?
(at this point I think this would be the preferred method)

Any help will be greatly appreciated.

Thanks,
Rob




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

Date: Wed, 9 Oct 2002 19:26:13 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: String manipulation help needed
Message-Id: <slrnaq9i95.3sa.tadmc@magna.augustmail.com>

Rob <nospamrbailey@gbronline.com> wrote:

> Consider the following:
> 
> $test_string = 'a rose by any other name would smell as sweet';


> I was expecting $A[0] to contain the ASCII code for an a (in binary) and
> $A[1] to contain the ASCII code for a space (in binary) etc.


   my @A = map ord, split //, $test_string;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Wed, 09 Oct 2002 20:18:02 -0400
From: stanton <stanton@lightlink.com>
Subject: tied hash consumes all memory
Message-Id: <3DA4C73A.DA4429FC@lightlink.com>

I'm reading and parsing lines out of a file and populating
a tied hash with key/value pairs, some values are references
to anonymous arrays and anonymous hashes.

I'm processing millions of lines and eventually the
Perl program runs out of RAM and just hangs.  I'm running
Activestate Perl 5.6.1 build 633 on Win2k.

If I had had to guess, I would have thought a hash tied
to a disk file wouldn't consume all memory and then hang.

So what I did, to try to free up RAM was to untie the hash
before the program froze, figuring I could retie it or
just create another hash.

My question is, should the following free up any RAM?

thanks,
Stanton

--

use DB_File;

$dbh = tie(%db, 'DB_File', "mydb.db") or die "unable to tie mydb.db";
%db = ();

while ( processing millions of records ) { #fill in the hash

   # at some point 1.5GB of ram is exhausted, so
   $dbh->sync();
   untie %db;
   print "db is untied, hit <ENTER> to resume";
   # right here, 1.5GB of RAM is still taken; none has been freed

   $blah = <STDIN>;
}


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

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.  

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 3943
***************************************


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