[29952] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1195 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 14 18:09:41 2008

Date: Mon, 14 Jan 2008 15:09:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 14 Jan 2008     Volume: 11 Number: 1195

Today's topics:
    Re: Converting milliseconds to seconds <nospam-abuse@ilyaz.org>
    Re: Cpan problems <john@castleamber.com>
    Re: Cpan problems <brian.d.foy@gmail.com>
    Re: Cpan problems <jaford@watford53.freeserve.co.uk>
    Re: Cpan problems <john@castleamber.com>
        Referencing modules nested in a directory structure <davidsmith@hotmail.com>
    Re: USEFUL perl SCRIPT: NTP verifier <john@castleamber.com>
    Re: USEFUL perl SCRIPT: NTP verifier <ignoramus5390@NOSPAM.5390.invalid>
    Re: USEFUL perl SCRIPT: NTP verifier <john@castleamber.com>
    Re: USEFUL perl SCRIPT: NTP verifier <ignoramus5390@NOSPAM.5390.invalid>
    Re: USEFUL perl SCRIPT: NTP verifier <daneNO@MORE.mk.SPAMtelcordia.com>
    Re: USEFUL perl SCRIPT: NTP verifier <mgjv@tradingpost.com.au>
    Re: USEFUL perl SCRIPT: NTP verifier <bik.mido@tiscalinet.it>
    Re: Wait for background processes to complete xhoster@gmail.com
    Re: Wait for background processes to complete <ced@blv-sam-01.ca.boeing.com>
        Way to Parse HTML fields to Excel Spreadsheet <ghadley_00@yahoo.com>
    Re: Way to Parse HTML fields to Excel Spreadsheet <glex_no-spam@qwest-spam-no.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 14 Jan 2008 20:23:24 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Converting milliseconds to seconds
Message-Id: <fmggbs$v2c$1@agate.berkeley.edu>

[A complimentary Cc of this posting was NOT [per weedlist] sent to
Jürgen Exner 
<jurgenex@hotmail.com>], who wrote in article <jfsmo3l5ri6362h8l3eff45r1mukgji2sc@4ax.com>:
> It would never have occured to me that the term "to round" could be used to
> mean truncation of trailing digits without balancing. But according to
> friends and Wikipedia this is quite common.

There are 9 (vairably useful) semantics of finding an integer nearby:

  going in direction of -infty		(=down)
  going in direction of +infty		(=up)
  going in direction to 0
  going in direction away from 0;
  going to closest (if ambiguous, one of 4 variants listed above);
  going to closest (if ambiguous, to even).

It is very convenient to be able to use one verb to describe them all;
"to round" comes quite handy.

[(The last way is the IEEE way (used in any "serious context"),
"to-closest-or-away-from-0" is the "naive way" (one which they teach
in schools - and not used anywhere else).]

Hope this helps,
Ilya


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

Date: 14 Jan 2008 19:13:52 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Cpan problems
Message-Id: <Xns9A25869722047castleamber@130.133.1.4>

Jim Ford <jaford@watford53.freeserve.co.uk> wrote:

> I've used the cpan command line to install modules on several Linux 
> boxes in the past with no problems - cpan has installed 'out of the 
> box' with little or no configuration.
> 
> I've now set-up a Ubuntu 7.10 system (perl 5.8.8) and am having problems 
> with cpan (1.7602). Initially cpan was unable to connect with a site - 
> it just hung. After removing the local .cpan directory and re-installing 
> perl I can't even get that far - I'm now getting problems with 
> initialising cpan with 'o conf init'. This particular problem is that 
> when it gets to asking me to input a list of continents (with no options 
> displayed), it just loops stating that whatever I input is not a valid 
> option. The only way to break out of the loop is with a ^C.
> 
> I'd welcome any suggestions to enable me to get cpan up and running!

I am new to Ubuntu, but from what I understand you /must not/ use CPAN, 
but use the package manager (synaptic, apt-get) instead to get your 
modules.

-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


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

Date: Mon, 14 Jan 2008 15:02:22 -0600
From: brian d  foy <brian.d.foy@gmail.com>
To: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Re: Cpan problems
Message-Id: <140120081502224668%brian.d.foy@gmail.com>

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

In article <MPG.21f5bb4cc4cd7d64989690@news.cable.ntlworld.com>, Jim
Ford <jaford@watford53.freeserve.co.uk> wrote:

> I've used the cpan command line to install modules on several Linux 
> boxes in the past with no problems - cpan has installed 'out of the 
> box' with little or no configuration.
> 
> I've now set-up a Ubuntu 7.10 system (perl 5.8.8) and am having problems 
> with cpan (1.7602). Initially cpan was unable to connect with a site - 
> it just hung. After removing the local .cpan directory and re-installing 
> perl I can't even get that far - I'm now getting problems with 
> initialising cpan with 'o conf init'. 

Can you  a complete transcript of everything that you are doing and
that cpan(1) is outputing?

Do you get the same behaviour when you start CPAN.pm directly?

   $ perl -MCPAN -e shell

What's the output of `cpan -v`? I don't think I've ever released a
version 1.7602.

Thanks,


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

Date: Mon, 14 Jan 2008 21:09:09 GMT
From: Jim Ford <jaford@watford53.freeserve.co.uk>
Subject: Re: Cpan problems
Message-Id: <MPG.21f5c95c17a2c96f989691@news.cable.ntlworld.com>

In article <Xns9A25869722047castleamber@130.133.1.4>, 
john@castleamber.com says...
> Jim Ford <jaford@watford53.freeserve.co.uk> wrote:
> 
> > I've used the cpan command line to install modules on several Linux 
> > boxes in the past with no problems - cpan has installed 'out of the 
> > box' with little or no configuration.
> > 
> > I've now set-up a Ubuntu 7.10 system (perl 5.8.8) and am having problems 
> > with cpan (1.7602). Initially cpan was unable to connect with a site - 
> > it just hung. After removing the local .cpan directory and re-installing 
> > perl I can't even get that far - I'm now getting problems with 
> > initialising cpan with 'o conf init'. This particular problem is that 
> > when it gets to asking me to input a list of continents (with no options 
> > displayed), it just loops stating that whatever I input is not a valid 
> > option. The only way to break out of the loop is with a ^C.
> > 
> > I'd welcome any suggestions to enable me to get cpan up and running!
> 
> I am new to Ubuntu, but from what I understand you /must not/ use CPAN, 
> but use the package manager (synaptic, apt-get) instead to get your 
> modules.

Interesting - where did you see that? I'm not sure how apt-get would 
interogate the CPAN archives - doesn't it only deal with the Ubuntu 
repositories?

On my old Kubuntu installation (5.10) cpan worked fine.

I'm not sure I really like the 'oven-ready' Linux distros like Ubuntu. 
When everything works they're fine, but when something goes wrong they 
can be a pain. I might go back to Slackware if I get any more problems.

Jim Ford


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

Date: 14 Jan 2008 21:41:37 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Cpan problems
Message-Id: <Xns9A259FA4DBD64castleamber@130.133.1.4>

Jim Ford <jaford@watford53.freeserve.co.uk> wrote:

> In article <Xns9A25869722047castleamber@130.133.1.4>, 
> john@castleamber.com says...
>> Jim Ford <jaford@watford53.freeserve.co.uk> wrote:

[..]

>> I am new to Ubuntu, but from what I understand you /must not/ use
>> CPAN, but use the package manager (synaptic, apt-get) instead to get
>> your modules.
> 
> Interesting - where did you see that? I'm not sure how apt-get would 
> interogate the CPAN archives - doesn't it only deal with the Ubuntu 
> repositories?

It doesn't use CPAN, it requires that the module(s) you want are available 
as a package apt/synaptic can handle. (for Fedora there is software to 
make packages via CPAN)

Ubuntu installs some Perl modules via apt AFAIK. If you update those via 
CPAN, I can imagine stuff goes out of sync. And vice versa of course.

> On my old Kubuntu installation (5.10) cpan worked fine.

Until you accidentally update a module via CPAN, which is also managed via 
apt. At least that's my understanding of it all.

> I'm not sure I really like the 'oven-ready' Linux distros like Ubuntu.
> When everything works they're fine, but when something goes wrong they
> can be a pain.

In my experience that holds for any distro/OS.

(FWIW, I prefer the automatic update process of apt (et al) over manually   
       once in a while checking for updates, etc.)

-- 
John

http://johnbokma.com/


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

Date: Mon, 14 Jan 2008 16:24:17 -0500
From: David Smith <davidsmith@hotmail.com>
Subject: Referencing modules nested in a directory structure
Message-Id: <5v2280F1jq038U1@mid.individual.net>

	Pardon the rookie question, but I haven't been able to find an answer 
in either the Camel book or a web search.

	I'm coming to Perl from a Java background... where you import classes 
using a fully-qualified name, and then generally make use of it using 
the base class name:


import myapp.dataojects.User;
 ...
User myUser = new User();


	I've been emulating the same convention as far as organizing my Perl 
modules in a directory structure based on functionality.  However, I 
find that when using them I have to always use the fully-qualified name:


use MyApp::DataObjects::User;
 ...
my $myUser = MyApp::DataObjects::User->new();


	Is there any syntax by which I could access Perl objects by using the 
object name alone, rather than the fully-qualified name?  Such as this:


use MyApp::DataObjects::User;
 ...
my $myUser = User->new();


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

Date: 14 Jan 2008 19:12:31 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <Xns9A25865DA1836castleamber@130.133.1.4>

Toby A Inkster <usenet200712@tobyinkster.co.uk> wrote:

> Ignoramus5390 wrote:
> 
>> my @servers = @ARGV;
> 
> die "Usage: query-ntp [--detail] [--limit=N] host1 host2 [host3 ...]\n"
>      unless ($#servers > 1);


@servers > 2 or die "......";

(which I read as a precondition for the code that follows: there must be 
more than 2 servers, otherwise ... )


It's a bit unclear to me why at least 3 hosts must be given (contradicting 
the usage line):

items   scalar @servers >2   $#servers > 1
0           0            f       -1      f   
1           1            f        0      f  
2           2            f        1      f  
3           3            t        2      t



(additional note:

    there is no need for () after the unless (i.e. when used as a    
    statement modifier)
) 



-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


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

Date: Mon, 14 Jan 2008 13:26:37 -0600
From: Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <eYmdnUBvHrnwKhbanZ2dnUVZ_t7inZ2d@giganews.com>

On 2008-01-14, John Bokma <john@castleamber.com> wrote:
> Toby A Inkster <usenet200712@tobyinkster.co.uk> wrote:
>
>> Ignoramus5390 wrote:
>> 
>>> my @servers = @ARGV;
>> 
>> die "Usage: query-ntp [--detail] [--limit=N] host1 host2 [host3 ...]\n"
>>      unless ($#servers > 1);
>
>
> @servers > 2 or die "......";
>
> (which I read as a precondition for the code that follows: there must be 
> more than 2 servers, otherwise ... )
>

I am confused about all this. One server supplied on command line is
enough to do useful tests. Just one, not two or three.

ie 

query-ntp --limit 1 www.mydomain.com

would test that the clock of mydomain.com is in sync with localhost. 

or 

query-ntp pool.ntp.org

would compare localhost with atomic clock.

I do not see why there is a need for requiring the user to supply more
than one server. 

i

> It's a bit unclear to me why at least 3 hosts must be given (contradicting 
> the usage line):
>
> items   scalar @servers >2   $#servers > 1
> 0           0            f       -1      f   
> 1           1            f        0      f  
> 2           2            f        1      f  
> 3           3            t        2      t
>
>
>
> (additional note:
>
>     there is no need for () after the unless (i.e. when used as a    
>     statement modifier)
> ) 
>
>
>


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

Date: 14 Jan 2008 19:31:42 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <Xns9A25899E52118castleamber@130.133.1.4>

Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid> wrote:
 
> I am confused about all this. One server supplied on command line is
> enough to do useful tests. Just one, not two or three.

Me too, I would use something like:

@servers
    or die "usage: ... query-ntp [--detail] [--limit=N] host [host ... ]

moreover, if you're supporting --usage, you might want to put the message 
in a sub:


@servers or show_usage_and_die();

:

sub show_usage {

   die ....
}


-- 
John Bokma                                      http://johnbokma.com/


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

Date: Mon, 14 Jan 2008 13:41:25 -0600
From: Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <QPGdnaXr7bx4JxbanZ2dnUVZ_tSknZ2d@giganews.com>

On 2008-01-14, John Bokma <john@castleamber.com> wrote:
> Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid> wrote:
>  
>> I am confused about all this. One server supplied on command line is
>> enough to do useful tests. Just one, not two or three.
>
> Me too, I would use something like:
>
> @servers
>     or die "usage: ... query-ntp [--detail] [--limit=N] host [host ... ]
>
> moreover, if you're supporting --usage, you might want to put the message 
> in a sub:
>
>
> @servers or show_usage_and_die();
>
>:
>
> sub show_usage {
>
>    die ....
> }
>
>
here's my new version, incorporating usage. It will be my new pattern
to follow:
######################################################################
#!/usr/bin/perl

# See Also:
# http://www.webreference.com/programming/perl/ntp/
# http://www.webreference.com/programming/perl/ntp/2.html

#
# Copyright(C) Igor Chudov, 2008. 
# Released under GNU Public License version 3.
#

use strict;
use warnings;

use Data::Dumper;
use Getopt::Long;
use Net::NTP;
use Time::HiRes qw( time );

my $detail = undef;
my $limit = undef;
my $help = undef;

sub usage {
  my ($msg) = @_;
  print "ERROR: $msg\n\n";
  print STDERR "Usage: $0 [--detail] [--limit=N] host {host}\n";
  exit ($msg ? 1 : 0);
}

GetOptions( 
           "detail!" => \$detail,
           "limit=f" => \$limit,
           "help!"   => \$help,
          );

my @servers = @ARGV;

usage if $help;
usage "detail and limit are mutually exclusive" if $detail and $limit;
usage "You need to supply one or more servers" unless (@servers);

my $bad = undef;

foreach my $server (@servers) {
  my $t0 = time;
  my %h = get_ntp_response( $server );

  
  #Timestamp Name          ID   When Generated
  #------------------------------------------------------------
  #Originate Timestamp     T1   time request sent by client
  #Receive Timestamp       T2   time request received by server
  #Transmit Timestamp      T3   time reply sent by server
  #Destination Timestamp   T4   time reply received by client
  #
  #The roundtrip delay d and local clock offset t are defined as
  #
  #d = (T4 - T1) - (T2 - T3)    t = ((T2 - T1) + (T3 - T4)) / 2

  my $T1 = $t0;
  my $T2 = $h{'Receive Timestamp'};
  my $T3 = $h{'Transmit Timestamp'};

  my $T4 = time; # From Time::HiRes! Accurate to usec!

  my $roundtrip_delay = ($T4 - $T1) - ($T2 - $T3);
  my $local_clock_offset = (($T2 - $T1) + ($T3 - $T4)) / 2;
  my $duration = $T4-$t0;
  my $delta = $T2-$T1 - $duration/2;
  
  if( $limit ) {
    if( $delta > $limit || -$delta < -$limit) {
      print "Server $server OFF by $delta seconds!!!\n";
      $bad = 1;
    } else {
      print "Server $server OK, delta is $delta seconds!!!\n";
    }
    
  } else {
    if( $detail ) {
      print Dumper( \%h ) . "\nt0=$t0, T4=$T4\ndelay=$roundtrip_delay, offset=$local_clock_offset\nelapsed=$duration, delta=$delta\n\n";
    } else {
      #print "$server delay=$roundtrip_delay, offset=$local_clock_offset, delta=$delta, duration=$duration\n";
      print sprintf( "%-30s %.5f\n", $server, $local_clock_offset );
    }
  }
}

exit 1 if $bad;


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

Date: Mon, 14 Jan 2008 19:44:36 GMT
From: Dan Espen <daneNO@MORE.mk.SPAMtelcordia.com>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <ic63xwjiou.fsf@mk.telcordia.com>

Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid> writes:

> On 2008-01-14, Dan Espen <daneNO@MORE.mk.SPAMtelcordia.com> wrote:
>> Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid> writes:
>>
>>> Over the years, I have had many problems with NTPd stopping to work
>>> without any notice. That always upset me.
>>
>> Me too, but I took a different approach.
>> In root's crontab:
>>
>> 35      *       *       *       *       /root/scripts/ntp-check.sh
>>
>> Content of script:
>>
>> x=`/etc/rc.d/init.d/ntpd status`
>> case $x in
>>   *stopped*|*dead*)
>>              status=`/etc/rc.d/init.d/ntpd start 2>&1`
>>              printf "had to start ntpd on `uname -n`, state <$x>\
>> \nrestart got status\n $status" | mail -s cron root
>>              ;;
>> esac
>
> Yeah, and what happens when it is alive, but does not talk to any
> timeservers?

The only time I ever saw it exit,
it lost communications to the time server.
Reading the man page, I think that's what it is supposed to do.


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

Date: Tue, 15 Jan 2008 07:29:06 +1100
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <slrnfonhgi.bfp.mgjv@martien.heliotrope.home>

On 14 Jan 2008 18:10:25 GMT,
	John Bokma <john@castleamber.com> wrote:
> Ignoramus5390 <ignoramus5390@NOSPAM.5390.invalid> wrote:
>
>> On 2008-01-14, John Bokma <john@castleamber.com> wrote:

>>> If you need to explain what IDs mean it clearly shows that the names
>>> of your variables are not chosen well.
>> 
>> They come from NTP specification.
>
> OK, clear. That's something you've read to write this, but someone who 
> reads your program does not always have to be familiar with this 
> documentation, nor has to read it first IMO.
>
>     	my $roundtrip_delay = ($T4 - $T1) - ($T2 - $T3);
>
> v.s.
>
>     	my $roundtrip_delay = ( $destination_ts - $originate_ts )
>                            - ( $receive_ts     - $transmit_ts  );
>
> which is more readable?

To me the first one is more readable. While long variable names are good
in many ways, sometimes they hinder the easy parsing of expressions,
because too much wrap and distance gets in the way.

For me it's much easier to see what the expression does int he first
instance than in the second, even if the precise meaning of each
variable is not that clear.

Especially, also, given that these short variables are 'standard'
terminology, I see no problem with them.

Martien
-- 
                        | 
Martien Verbruggen      | I think there is a world market for maybe
                        | five computers. -- Thomas Watson, chairman of
                        | IBM, 1943


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

Date: Mon, 14 Jan 2008 23:57:49 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: USEFUL perl SCRIPT: NTP verifier
Message-Id: <n6qno3lart06dcgh5i84tht7t4udq6penn@4ax.com>

On 14 Jan 2008 18:10:25 GMT, John Bokma <john@castleamber.com> wrote:

>>> undef is the default value, I wouldn't assign it explicitly.
>> 
>> I like this style. Makes it very explicit. 
>
>IMO Perl programmers should know that the default is undef, and hence no 
>need to assign undef. To confuse matters a bit more (IMO), you set $bad 

FWIW, I wholeheartedly second that.
 

Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 14 Jan 2008 20:48:32 GMT
From: xhoster@gmail.com
Subject: Re: Wait for background processes to complete
Message-Id: <20080114154834.343$yd@newsreader.com>

pgodfrin <pgodfrin@gmail.com> wrote:
> On Jan 14, 11:11 am, xhos...@gmail.com wrote:
> >
> > The fork returns (to the parent) the pid of the process forked off.
> > (but you don't actually need to know the pid if you merely want to
> > wait, rather than waitpid.)  If that forked-off process then itself
> > starts the cp in the background, of course you are no better off.  But
> > if the forked-off process either becomes cp (using exec) or it starts
> > up cp in the foreground (using system without a "&"), then you now have
> > something to wait for.  In the first case, you wait for cp itself.  In
> > the second case, you wait for the forked-off perl process which is
> > itself waiting for the cp.
> >
> > $ perl -wle 'use strict; fork or exec "sleep " . $_*3 foreach 1..3 ; \
> >               my $x; do {$x=wait; print $x} until $x==-1'
> > 438
> > 439
> > 440
> > -1
> >
>
> Hi Xho,
> Well - your code and concepts work fine when you want to wait
> sequentially.

Is there an alternative to waiting sequentially?  Waiting sequentially
is what the shell does, too, behind the scenes.

> My goal here is to fire off x number of process and then
> wait for ALL of them to complete

That is what my code does.

> (this is basically rudimentary job
> control, trying to use the shell concepts and maximize parallelism).
> So, that requires the use of the & to send a process to the
> background.

No, that is not required.  Since Perl is not a shell, there really
isn't such a thing as the "background" in a Perl context.  However,
fork will launch another process which runs without blocking the original
process (well, at least not until the original process asks to be blocked)
or blocking sibling processes.  That is what you want, no?

> It looks like exec doesn't recognize the &, which leaves
> the system() command - which leaves us back at square one. The shell
> completes and the program has nothing to wait for.

Yes, so don't do that.  "&" basically means "Fork and then don't wait".
Since that isn't what you want to do, then don't do that.  Do your own
fork, and then do your own wait.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 14 Jan 2008 14:26:12 -0800 (PST)
From: "comp.llang.perl.moderated" <ced@blv-sam-01.ca.boeing.com>
Subject: Re: Wait for background processes to complete
Message-Id: <4000dd69-d76a-4dad-9b4f-c7ecd2d6df0c@j20g2000hsi.googlegroups.com>

On Jan 13, 7:08 pm, pgodfrin <pgodf...@gmail.com> wrote:
> Greetings,
> Well - I've spent a bunch of time trying to figure this out - to no
> avail.
>
> Here's what I want to do - run several commands in the background and
> have the perl program wait for the commands to complete. Fork doesn't
> do it, nor does wait nor waitpid.
>
> Any thoughts?
>
> Here's a sample program which starts the processes:
>
>    while (<*.txt>)
>    {
>         print "Copying  $_ \n";
>         system("cp $_ $_.old &") ;
>    }
>    print "End of excercise\n";
>    exit;
>
> I mean if this were a shell program - this would work:
>
>    for x in `ls *.txt`
>    do
>       print "Copying  $_ \n"
>       cp $_ $_.old &
>    done
>    wait
>

A 'quick 'n dirty' take :)

 while (<*.txt>) {
   ...
   system("cp $_ $_.old &") ;
 }
 my $jobs;
 do { sleep 1; $jobs =`ps |grep cp`; }
    while $jobs;


--
Charles DeRykus


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

Date: Mon, 14 Jan 2008 13:59:15 -0800 (PST)
From: "ghadley_00@yahoo.com" <ghadley_00@yahoo.com>
Subject: Way to Parse HTML fields to Excel Spreadsheet
Message-Id: <5c77a86c-6370-4796-bea6-514359f26c0a@m34g2000hsb.googlegroups.com>

Hi,

I've got a text file that contains the html of approximately 514 web
pages, concatenated into 1 file. Each html page has approximately the
same format, with data in tables. Can anyone recommend a way I can
parse the document to get the fields as variables and write them out
as an excel spreadsheet? [e.g. using win32 ole]

Thanks,

George

ghadley_00@yahoo.com


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

Date: Mon, 14 Jan 2008 16:17:24 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Way to Parse HTML fields to Excel Spreadsheet
Message-Id: <478bdf74$0$3578$815e3792@news.qwest.net>

ghadley_00@yahoo.com wrote:
> Hi,
> 
> I've got a text file that contains the html of approximately 514 web
> pages, concatenated into 1 file. Each html page has approximately the
> same format, with data in tables. Can anyone recommend a way I can
> parse the document to get the fields as variables and write them out
> as an excel spreadsheet? [e.g. using win32 ole]

Parse the HTML - There are many modules and possibly HTML::TableExtract 
might be useful, or possibly a regular expression might be enough.
Write out the data.

To really answer your question you should show us an example of the data 
(NOT the entire file), and what you've tried.  See the Posting Guidelines.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1195
***************************************


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