[21740] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3944 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 10 03:05:42 2002

Date: Thu, 10 Oct 2002 00:05:08 -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           Thu, 10 Oct 2002     Volume: 10 Number: 3944

Today's topics:
    Re: Flag processing <bongie@gmx.net>
    Re: Flag processing <goldbb2@earthlink.net>
    Re: Hello World doesn't work in 5.8?? <ak@freeshell.org.REMOVE>
    Re: Hello World doesn't work in 5.8?? <goldbb2@earthlink.net>
    Re: Multiple Pings/Second <goldbb2@earthlink.net>
    Re: paragraph mode read a filehandle <jkeen@concentric.net>
    Re: paragraph mode read a filehandle <s_grazzini@hotmail.com>
    Re: paragraph mode read a filehandle <skuo@mtwhitney.nsc.com>
    Re: paragraph mode read a filehandle <krahnj@acm.org>
    Re: paragraph mode read a filehandle <goldbb2@earthlink.net>
        Perl script to access devices on COM1. COM2 or USB ? <nosuchperson@nothere.net>
        Re-entrant parser (AGoodGuyGoneBad)
    Re: Re-entrant parser <dd@4pro.net>
    Re: Run perl script on web server from command line <junk.kingsley@sympatico.ca>
    Re: Run perl script on web server from command line <junk.kingsley@sympatico.ca>
    Re: Run perl script on web server from command line <wsegrave@mindspring.com>
    Re: Run perl script on web server from command line (Si Ballenger)
    Re: String manipulation help needed (Jay Tilton)
    Re: tied hash consumes all memory <goldbb2@earthlink.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 10 Oct 2002 04:47:08 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Flag processing
Message-Id: <2285498.nGngpB8hU3@nyoga.dubu.de>

Teh (tî'pô) wrote:
> John W. Krahn bravely attempted to attach 35 electrodes of knowledge
> to the nipples of comp.lang.perl.misc by saying:
>>the /o modifier isn't
>>going to help as there are no variables in the regular expression.  Of
>>course, it depends on how the data is stored.  :-)
> 
> Oops looks like I should re-read the documentation, I thought a
> regular expression was compiled even when it doesn't contain a
> variable.

Regexps are compiled at compile-time if they don't contain variables.  
If they do, Perl compiles them every time they are used, *unless* you 
tell Perl with the /o modifier that you're absolutely sure that the 
variable's value won't change over run-time, so Perl can treat the 
regex like a constant one.  So the /o modifier won't do anything useful 
with regexps that don't contain variables. (It won't do harm either, 
but it's irritating.)

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Real Programmers don't write in PL/I.  PL/I is for programmers who
can't decide whether to write in COBOL or FORTRAN.


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

Date: Wed, 09 Oct 2002 23:20:14 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Flag processing
Message-Id: <3DA4F1EE.C2EE85CF@earthlink.net>

Harald H.-J. Bongartz wrote:
[snip]
> Regexps are compiled at compile-time if they don't contain variables.
> If they do, Perl compiles them every time they are used, *unless* you
> tell Perl with the /o modifier that you're absolutely sure that the
> variable's value won't change over run-time, so Perl can treat the
> regex like a constant one.  So the /o modifier won't do anything
> useful with regexps that don't contain variables. (It won't do harm
> either, but it's irritating.)

Actually, on modern perls, perl will cache the compiled regex, and the
next time the regex is run, it checks if the interpolated string has
changed, and if not, uses the cached version.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 10 Oct 2002 01:15:58 -0000
From: Andreas =?iso-8859-1?Q?K=E4h=E4ri?= <ak@freeshell.org.REMOVE>
Subject: Re: Hello World doesn't work in 5.8??
Message-Id: <slrnaq9l5t.kp2.ak@otaku.freeshell.org>

Submitted by "milkfilk" to comp.lang.perl.misc:
> Am I insane?
> 
> __________________________________________________
> [milkfilk@computer scripts]$ perl -e 'print "hi";'
> [milkfilk@computer scripts]$
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Try 

    perl -e 'print "hi\n";'

Maybe it's not flushing it's buffers on exit?

-- 
Andreas Kähäri @ New Zealand +------ Have a Unix: netbsd.org
-----------------------------+------ This post ends with :wq


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

Date: Thu, 10 Oct 2002 02:38:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Hello World doesn't work in 5.8??
Message-Id: <3DA52061.67A68F33@earthlink.net>

Andreas Kähäri wrote:
> 
> Submitted by "milkfilk" to comp.lang.perl.misc:
> > Am I insane?
> >
> > __________________________________________________
> > [milkfilk@computer scripts]$ perl -e 'print "hi";'
> > [milkfilk@computer scripts]$
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Try
> 
>     perl -e 'print "hi\n";'
> 
> Maybe it's not flushing it's buffers on exit?

Unlikely -- a more probable reason is that the prompt contains "\r" as
the first character, causing it to overwrite the "hi".

Either way, though, adding a newline should fix the problem.

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 10 Oct 2002 02:05:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multiple Pings/Second
Message-Id: <3DA518A0.D34BE59C@earthlink.net>

Rocco Caputo wrote:
> 
> 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.

If you're willing to look into the guts of Net::Ping, and learn how ICMP
pings are constructed, you could write your own program to send multiple
pings at once.

> 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.

First -- why do you say that pinging the whole list at once won't work?

Second -- who says you *have* to feed it the whole list at once?  You
could feed it some reasonable sized block, wait for them to respond or
time out, and then send more.

> > 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.

The obvious thing to do is send your pings as fast as you can, read as
many responses as you can within a timeout, and then resend to those who
didn't respond.

Something like:

   my $socket = ...;
   my @hosts = ...; # 4 byte ip addresses.

   my %hosts = map {; pack_sockaddr_in(0, $_) => $_ } @hosts;
   my $seq = 0;

   my @checksums;

   my $gotone = 1;
   while( %hosts and $seq++ < 30 ) {

      # code, subcode, checksum, pid, seq, [data ommited]
      my $msg = pack("C2S3", 8, 0, 0, $$ & 0xFFFF, $seq);
      my $chk = unpack("%32S*", $msg);
      # $chk += ord(substr( $msg, -1 )) if length($msg) % 2;
      $chk = ($chk & 0xFFFF) + ($chk >> 16) for 1..2;
      $chk = $checksums[$seq] = 0xFFFF & ~$chk;
      $msg = pack("C2S3", 8, 0, $chk, $$ & 0xFFFF, $seq);

      send( $s, $msg, 0, $_ ) for keys %hosts;

      --$gotone;

      vec( my $rvec = "", fileno($socket), 1 ) = 1;
      my $t = 1;
      while( $t ) {
         (my ($n), $t) = select($rvec, '', '', $t);
         die "select failed: $!" if !defined($n) or $n < 0;
         last if $n == 0; # timeout.

         my $responder = recv( $s, my ($resp), length($msg), 0 )
            or die "Error in recv: $!"; # shouldn't happen.

         my ($port, $ip) = unpack_sockaddr_in($responder);
         die "Expected port to be zero" if $port;
         my ($rtype, undef, $rchk, $rpid, $rseq) =
            unpack("C2S3", $resp);
         # make sure this is a valid packet:
         $rtype == 0 and $rseq > 0 and $rseq <= $seq
            and $rpid == ($$ & 0xFFFF) and
            and $rchk == $checksums[$rseq] or next;

         # remove this host from the %hosts hash, and
         # if wasn't previously there, ignore the packet.
         delete $hosts{$responder} or next;

         $gotone = 1;

         # print out the fact that we've discovered
         # that the host is alive.
         print inet_ntoa($ip) . " is alive\n";

      } # end while($t)

      print "[" . scalar(keys %hosts) . " hosts timed out]\n"
         if $gotone == 0;

   } # end while(%hosts and $seq++ < 30)

   print inet_ntoa($_)." is down\n" for values %hosts;

[untested]

> 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.

Since he hasn't said that he's pinging broadcast addresses, I would
*assume* that he's pinging actual hosts.  Thus, this shouldn't be
relevant (I think).

> 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.

Using IPC::Run or IPC::Open2 are overkill, unless you need to both send
to the stdin and read from the stdout of a process.  (And you certainly
wouldn't use IPC::Open3, unless you needed to capture the stderr of the
process).

A simple open will do:
   my $pid = open( FPING, "-|", "fping", @args_to_fping )
      or die horribly;

> 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 *could*, but it's much more fun to write an example for dealing with
many pings, than many processes :)

I've done stuff for processes before, but I don't recall having done
pings before.

If you *really* want to use many instances of fping, post a message to
the newsgroup telling what kind of arguments it takes, and what kind of
output it producess.  *But*, before you do that, look through the
archives on groups.google.com, looking at the prior examples of code
I've written for dealing with multiple input streams with IO::Select.

(Other people's code for that may also be good inspiration, but I'm
better able to explain code that I'm familar with)

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: 10 Oct 2002 01:27:05 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: paragraph mode read a filehandle
Message-Id: <ao2l19$6bl@dispatch.concentric.net>


"* Tong *" <sun_tong_001@yahoo.com> wrote in message
news:3DA4C324.19D99F79@yahoo.com...
> I.e., why not the following code give me paragraph mode results? I still
> get lots of empty lines.
>
> # read in the body in paragraph mode
> local $/="";

Because that's not paragraph mode.  You've locally defined $/ as an empty
string.  You probably want this, instead:

    local $/ = "\n\n";




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

Date: Thu, 10 Oct 2002 01:33:02 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: paragraph mode read a filehandle
Message-Id: <iN4p9.4234$BV1.332598@twister.nyc.rr.com>

James E Keenan <jkeen@concentric.net> wrote:
> 
> "* Tong *" <sun_tong_001@yahoo.com> wrote in message
> news:3DA4C324.19D99F79@yahoo.com...
>> I.e., why not the following code give me paragraph mode results? I still
>> get lots of empty lines.
>>
>> # read in the body in paragraph mode
>> local $/="";
> 
> Because that's not paragraph mode.  You've locally defined $/ 
> as an empty string.  You probably want this, instead:
> 
>     local $/ = "\n\n";

  $ perldoc perlvar
  ...

  $INPUT_RECORD_SEPARATOR
  $RS
  $/      The input record separator, newline by default.
          ...
          Setting it to "\n\n" means something slightly
          different than setting to "", if the file contains
          consecutive empty lines.  Setting to "" will treat
          two or more consecutive empty lines as a single
          empty line.  Setting to "\n\n" will blindly assume
          that the next input character belongs to the next
          paragraph, even if it's a newline. 

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: Wed, 9 Oct 2002 19:11:35 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: paragraph mode read a filehandle
Message-Id: <Pine.GSO.4.21.0210091904460.22712-100000@mtwhitney.nsc.com>

On 10 Oct 2002, James E Keenan wrote:

> 
> "* Tong *" <sun_tong_001@yahoo.com> wrote in message
> news:3DA4C324.19D99F79@yahoo.com...
> > I.e., why not the following code give me paragraph mode results? I still
> > get lots of empty lines.
> >
> > # read in the body in paragraph mode
> > local $/="";
> 
> Because that's not paragraph mode.  You've locally defined $/ as an empty
> string.  You probably want this, instead:
> 
>     local $/ = "\n\n";
 



I doubt that the OP wants to do this if he is trying to eliminate
empty lines while reading.  The difference between $/="" and $/="\n\n"
is described in perlvar and can be seen by running this example:


#! /usr/local/bin/perl
use strict;
use warnings;

my $counter;
my $pos = tell DATA;
for my $separator ('', "\n\n") {
    local $/= $separator;
    ++$counter;
    seek DATA, $pos, 0;
    my @array = <DATA>;
    print "Loop: $counter\n";
    print "Found empty line\n" if grep { $_ =~ /^\n+/ } @array;
    print join '*', map {tr/\n//d; $_} @array;
    print "\n";
}


__DATA__
1
2


3
4




5
-- 
Regards,
Steven



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

Date: Thu, 10 Oct 2002 04:37:42 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: paragraph mode read a filehandle
Message-Id: <3DA503FB.7D146D86@acm.org>

* Tong * wrote:
> 
> 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);
                          ^^^^^
Are you using Net::NNTP to read usenet articles?  If so then Net::NNTP
does not define a bodyfh() method.  Try adding this line:

die "\$nntp->bodyfh did not return a file handle\n"
    unless ref($msgbodyfh) eq 'GLOB';


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



John
-- 
use Perl;
program
fulfillment


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

Date: Thu, 10 Oct 2002 02:43:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: paragraph mode read a filehandle
Message-Id: <3DA5218D.C2D8D676@earthlink.net>

John W. Krahn wrote:
> 
> * Tong * wrote:
> >
> > 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);
>                           ^^^^^
> Are you using Net::NNTP to read usenet articles?  If so then Net::NNTP
> does not define a bodyfh() method.

The version of Net::NNTP which comes with 5.8.0 has such a method.

   http://www.perldoc.com/perl5.8.0/lib/Net/NNTP.html

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

Date: Thu, 10 Oct 2002 00:17:50 -0400
From: "Pero" <nosuchperson@nothere.net>
Subject: Perl script to access devices on COM1. COM2 or USB ?
Message-Id: <3da4ff6d_4@nopics.sjc>

I would like to write a Perl script to access a device on COM1, COM2 or USB.
Such as a PDA device.
I would like to read from and write to this device.
Is this possible?  Any HOWTO appreciated.
What documentation do you recommend to guide me?
Thanks
Rick




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

Date: 10 Oct 2002 05:39:37 GMT
From: agoodguygonebad@aol.com (AGoodGuyGoneBad)
Subject: Re-entrant parser
Message-Id: <20021010013937.23990.00000713@mb-ms.aol.com>

>> This should get you started.
>
>not really. Thank you, but I don't need just a RE like m/{a}.*?{\/a}/ig to
>process one block at a time, because this RE fails with nested blocks, and
>fails with singleton tokens ({a} without {/a}). Besides the number is not
>just a counter of the hits, but a way to show in the example the sequence of
>the hits
>

It was just an example of how to start.
You said "since the syntax is very simple, I would like to avoid the use of a
parser module."
I agree, but you have to start some where...
I don't think you'll be able to do things in the order you want to in your
pseudo code.

I would count the number of blocks, then check each block and see if it is
undef. (Maybe even keep track of each blocks length, and starting postion. )
Then once you have that data, start sending the return contents, and build the
replacement string.

Try these, and see what the results are.
m/}.*?{\/a}/ig)
m/}.*?{\//ig)
m/..}.*?{./ig)
m/}.*?{/ig)
m/.*?{./ig)

Steve

>> $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 21:11:23 -0400
From: "Domizio Demichelis" <dd@4pro.net>
Subject: Re: Re-entrant parser
Message-Id: <ao2k4m$iau6o$1@ID-159100.news.dfncis.de>

> This should get you started.

not really. Thank you, but I don't need just a RE like m/{a}.*?{\/a}/ig to
process one block at a time, because this RE fails with nested blocks, and
fails with singleton tokens ({a} without {/a}). Besides the number is not
just a counter of the hits, but a way to show in the example the sequence of
the hits


> $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 21:35:23 -0400
From: "Chuck" <junk.kingsley@sympatico.ca>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao2lfm$6em$1@moonstone.imsb.nrc.ca>

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

Isn't that what I said!

> 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.

Next time I'll make sure to be more thorough when posting a question.  I'll
also make sure that the identities are the same.  I posted from two
different computers and my news reader was obviously configured differently.
In any case thanks for your input.

Chuck




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

Date: Wed, 9 Oct 2002 21:27:00 -0400
From: "Chuck" <junk.kingsley@sympatico.ca>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao2kvv$4vm$1@moonstone.imsb.nrc.ca>

Thanks.  The sample Perl script on that page did the trick.

Chuck

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news: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 22:13:48 -0500
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Run perl script on web server from command line
Message-Id: <ao2rhh$6tm$1@slb5.atl.mindspring.net>

"Chuck" <junk.kingsley@sympatico.ca> wrote in message
news:ao2lfm$6em$1@moonstone.imsb.nrc.ca...
<snip>
>
> Next time I'll make sure to be more thorough when posting a question.
<snip>

That would be helpful, especially to you.. You received several different
answers to your questions because you were not precise about the type of
transaction you wished to perform with the remote computer you described as
your web server, e.g.,

1. Tad McClellan pointed you towards the LWP module, which is the correct
response if you wish to perform "HTTP-style communication" from the command
line of your (client) computer. In this case, your script interacts with the
web _server_ running on the remote computer.

2. I directed you to Net::Telnet (or Net::SSH::Perl), which might be
appropriate if you wish to perform "Telnet-style (secure) communication"
from the command line of your (client) computer.

3. There are other alternatives to 1 and 2 above, e.g., VNC.

Whether you choose HTTP-type or Telnet-type transactions depends upon
factors you have not stated in your previous posts.

> In any case thanks for your input.

You're very welcome!

Bill Segraves






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

Date: Thu, 10 Oct 2002 03:43:10 GMT
From: shb*NO*SPAM*@comporium.net (Si Ballenger)
Subject: Re: Run perl script on web server from command line
Message-Id: <3da4f4b9.179641520@news.comporium.net>

On Wed, 9 Oct 2002 14:29:48 -0400, "Me" <ignore@nobody.com>
wrote:

>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 ?
>
>Thanks

I've used a little work around to do something similar using the
IE brouser to do the work. I reduce the brouser until it is as
small as possible (you can get it really small and drag it off
your visible screen if desired), then use the command line in a
batch file like below. When the batch file is run, the brouser
does it's thing pretty much out of site. The batch file can be
executed via scheduler, events and such when the computer is
unattended.

@echo off
start http://www.my.server/scripts/myperl.pl


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

Date: Thu, 10 Oct 2002 01:19:25 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: String manipulation help needed
Message-Id: <3da4d13b.180703675@news.erols.com>

"Rob" <nospamrbailey@gbronline.com> wrote:

| $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?

  my @A = unpack("B*", $test_string) =~ /[01]{8}/g;

| Or is there a way that I can unpack each character into a different element?

Make a pack template that matches the length of the string,

  my @A = unpack 'B8' x length($test_string), $test_string;

or bust up the string into characters and unpack each individually,

  my @A = map unpack('B8',$_), $test_string =~ /./g;

or, if you feel like being weird,

  my@A=split$",sprintf'%*v08b',$",$test_string;



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

Date: Thu, 10 Oct 2002 02:36:58 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: tied hash consumes all memory
Message-Id: <3DA5200A.3A3607D8@earthlink.net>

stanton wrote:
[snip]
> $dbh = tie(%db, 'DB_File', "mydb.db") or die "unable to tie mydb.db";
> %db = ();
[snip]
>    untie %db;
>    print "db is untied, hit <ENTER> to resume";
>    # right here, 1.5GB of RAM is still taken; none has been freed

The data gets freed when the object that %db was tied to gets DESTROYed.

Since you still have a reference to that object in $dbh, it can't get
destroyed.  Add a line, 'undef $dbh;' after you 'untie %db;', and all
should be well.

>    $blah = <STDIN>;
> }

-- 
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
 ."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]


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

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


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