Re: regex help

2011-10-18 Thread John W. Krahn

Brian Fraser wrote:

On Tue, Oct 18, 2011 at 12:32 AM, Chris Stinemetz
chrisstinem...@gmail.comwrote:


/17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/



Spot the issue:
/
  17#Or
| 18#Or
| 19#Or
| 20#Or
| 21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH
/x

For anything but 21, the regex is only two numbers! You need to enclose the
alternatives in () or (?:), depending on whenever you want to capture them
or not.

That aside, please be very mindful that \d and . are both code smells. The
former will match much, much more than just [0-9] -- grab the unichars[0]
program from Unicode::Tussle[1] if you want to see for yourself. Either use
the /a switch (or the more localized form (?a:), bot available in newer
Perls), or [0-9], or \p{PosixDigit}, or (your favorite way here. TIMTOWTDI
applies).

The dot is also problematic. You aren't using the /s switch, so it actually
matches [^\n].


Correct.


Is that what you want? Are you certain that no one is going
to come and, after reading Perl Best Practices, will try to helpfully but
wrongly add the /smx flags and screw up your regex?


It doesn't really matter because the regular expression is matched 
against a line (via readline) and as such will only contain one 
newline and that newline will be at the end of the line so it will 
match the same with or without the /s option.


Also, as the regular expression does not contain either the ^ anchor or 
the $ anchor it will match the same with or without the /m option.




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex help

2011-10-18 Thread John W. Krahn

Chris Stinemetz wrote:

Hello,


Hello,


[*SNIP*]


#!/usr/bin/perl

use warnings;
use strict;
use POSIX;

# my $filepath =
sprintf(/omp/omp-data/logs/OMPROP1/%s.APX,strftime(%y%m%d%H,localtime));
my $filepath = (/tmp/110923.APX); # for testing

my $runTime = 
sprintf(/home/cstinemetz/programs/%s.txt,strftime(%Y-%m-%d-%H:%M,localtime));

my $fileDate = strftime(%y%m%d%H%,localtime);

open my $fh, '', $filepath or die ERROR opening $filepath: $!;
open my $out, '', $runTime or die ERROR opening $runTime: $!;

my %date;
my %cell;
my %heh_type_count;
while (my $line =$fh) {
   if ($line =~ 
/17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){


As you haven't changed the Input Record Separator the code my $line 
=$fh will read one line from the file and that line will have only 
one newline at the end of the line so /\n+\n+/ in the middle of your 
regular expression will never match.



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex help

2011-10-18 Thread Chris Stinemetz
On Mon, Oct 17, 2011 at 10:57 PM, Leo Susanto leosusa...@gmail.com wrote:
 From looking at the regex

  if ($line =~ 
 /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){

 against the data

 10/17/11 18:25:20 #578030

  25 REPT:CELL 221 CDM 2, CRC, HEH
     SUPPRESSED MSGS: 0
     ERROR TYPE: ONEBTS MODULAR CELL ERROR
     SET: MLG BANDWIDTH CHANGE
     MLG 1 BANDWIDTH = 1536

 I would assume $1 and $2 wouldn't match to anything plus $5 doesn't exist.

 Could you please let us know which part of the data you want to extract?

 Fill in the blanks
 $1=
 $2=
 $3=
 $4=
 $5=


Thanks everyone. I hope this clarifies what I am trying to match. For
example with this input:

10/17/11 18:25:20 #578030

  25 REPT:CELL 221 CDM 2, CRC, HEH
 SUPPRESSED MSGS: 0
 ERROR TYPE: ONEBTS MODULAR CELL ERROR
 SET: MLG BANDWIDTH CHANGE
 MLG 1 BANDWIDTH = 1536


$1= Match the time stamp Hour:Min:Sec only if the hour is = 17 and hour = 21
$2= capture CELL number
$3= capture the information after the CELL number (and before the first comma)

Thank you,

Chris

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Perl Fork and writing to stdout

2011-10-18 Thread sunckell
Hello Perl People

 I was wondering if someone could enlighten me on an observation I
have been seeing..

A little Background info:
 Where I work we have been seeing very slow ssh connections times
(it's not DNS.  Maybe NIS, NFS, but definitely not DNS).

  Anyways I wanted to write a script that would log the time it
takes to connect to a remote server via ssh and issue a command (uname
-n).  The tricky part was that I wanted the remote connections to kick
off every 60 secs.  (some ssh connections take a lot longer.  120+ in
some cases).  The log should enable me to pinpoint any time
correlation to the long ssh connect occurrences (every 5 minutes?  1/2
past every hour? etc).

 So here we are back to the script..  The script works as
expected, with one item of strangeness.  I was expecting the log
messages to be printed in the order they complete. For example, if the
connection attempt at 12:01 took 75 seconds to return, and the
connection attempt at 12:02 to 5 seconds to return, I would expect the
12:02 message to appear first then the 12:01, but it doesn't.  The
12:02 connection won't print until the 12:01 returns.

Here is my code:

use strict;
use Getopt::Std;
use Sys::Hostname;
use File::Basename;
use Net::SSH qw( sshopen2 );
use Time::HiRes qw( gettimeofday tv_interval );
$|++;

$SIG{CHLD} = 'IGNORE';

my %opts;
getopts('dr:', \%opts);

my $localhost = hostname();
my $r_host= $opts{'r'} ? $opts{'r'} : die need remote host -r
\n;
my $debug = $opts{'d'};
my $short_name = basename($0, .pl);

# --- set the counter to zero.  We'll print the counter to the log for
easier sorting
# --- of data where the ssh connections take longer than a minute to
return.
my $ct = 0;

while (1) {

my $pid = fork();

if ($pid) {
# parent
} elsif ($pid == 0) {
# child
my $p = _initialize($ct);
waitpid($p, 0);
exit 0;
} else {
die couldnt fork: $!\n;
}

$ct++;
sleep 60;
}

# ---
# --- sub: initialize
# --- descr:   for easier viewing of the code for the fork process.
# --- returns: nothing
# ---
sub _initialize{
my($count) = @_;

my $now= scalar localtime();

my $start   = [gettimeofday()];

my $ret = connect_to_remote_host($r_host);

my $elapsed = tv_interval( $start );

if ($count  10){
$count = 0$count;
}

if ($count  99){
$count = 0$count;
}

my $msg =  $count - [$now] $localhost to $r_host Elapsed time:
$elapsed ;
write_to_log($msg);

return;

}

# ---
# --- sub: connect_to_remote_host
# --- descr:   uses ssh to connect to a remote host via ssh keys only.
# --- returns: nothing.
# ---
sub connect_to_remote_host {
my($host) = @_;

my $user = 'root';
my $cmd  = uname -n;
my $out  = ;

sshopen2($user\@$host, *READER, *WRITER, $cmd) || die ssh:
$!;

while (READER) {
chomp();
#print $_\n;
$out = $_;
}

close(READER);
close(WRITER);

return $out;
}

# ---
# --- sub: write_to_log
# --- descr:   write messages to log file or print to stdout when in
debug
# --- returns: nothing
sub write_to_log{
my ($message) = @_;

my $log = /tmp/$short_name.log;

if ($debug){
print $message\n;
}

open L, $log or die Cannot open $log:$!\n;
print L $message\n;
close L;
}


Just wondering why the messages being printed to the console waits for
the previous pid (or pids) to complete before it's viewable.

FYI - I implemented the Counter thinking the messages weren't always
going to be in order and that I could always to a quick sort on the
counter to get the correct timeline.

Thanks,
Chad



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: regex help

2011-10-18 Thread Igor Dovgiy
Maybe this'll be helpful. )

my $time_rx = qr/(?timestamp
   (?hour \d{2} )
   (?: :\d{2} ){2}
 )
/x;

my $cell_record_rx = qr/CELL
  \s+
  (?cell_number \d+)
  \s+
  (?cell_info [^,]+)
 /x;

my $records_ref;
my $record_ts;
while () {
  if ($record_ts) {
# looking for record data of this particular timestamp
if (/$cell_record_rx/) {
  ++$records_ref-{$record_ts}{ $+{cell_number} }{ $+{cell_info} };
  undef $record_ts;
}
  }
  else {
#scanning for next valid record
if (/$time_rx/
 $+{hour} = 17  $+{hour} = 21) {
  $record_ts = $+{timestamp};
}
  }
}

-- iD

2011/10/18 Chris Stinemetz chrisstinem...@gmail.com

 On Mon, Oct 17, 2011 at 10:57 PM, Leo Susanto leosusa...@gmail.com
 wrote:
  From looking at the regex
 
   if ($line =~
 /17|18|19|20|21+:(\d+):(\d+)+\n+\n+CELL\s+(\d+)\s+(.+?),.+?HEH/){
 
  against the data
 
  10/17/11 18:25:20 #578030
 
   25 REPT:CELL 221 CDM 2, CRC, HEH
  SUPPRESSED MSGS: 0
  ERROR TYPE: ONEBTS MODULAR CELL ERROR
  SET: MLG BANDWIDTH CHANGE
  MLG 1 BANDWIDTH = 1536
 
  I would assume $1 and $2 wouldn't match to anything plus $5 doesn't
 exist.
 
  Could you please let us know which part of the data you want to extract?
 
  Fill in the blanks
  $1=
  $2=
  $3=
  $4=
  $5=
 

 Thanks everyone. I hope this clarifies what I am trying to match. For
 example with this input:

 10/17/11 18:25:20 #578030

  25 REPT:CELL 221 CDM 2, CRC, HEH
 SUPPRESSED MSGS: 0
 ERROR TYPE: ONEBTS MODULAR CELL ERROR
 SET: MLG BANDWIDTH CHANGE
 MLG 1 BANDWIDTH = 1536


 $1= Match the time stamp Hour:Min:Sec only if the hour is = 17 and hour =
 21
 $2= capture CELL number
 $3= capture the information after the CELL number (and before the first
 comma)

 Thank you,

 Chris

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Run perl scripts in Windows

2011-10-18 Thread Remy Guo
hi all,
I have a Perl script in Windows but my system administrator doesn't allow me
to install ActivePerl nor i guess anything that will change rigistry on the
machine.
is there any other way to run the script?

Thanks..

Remy


Re: Run perl scripts in Windows

2011-10-18 Thread Shlomi Fish
ׁHello Remy,

On Tue, 18 Oct 2011 09:05:41 -0400
Remy Guo rollingst...@gmail.com wrote:

 hi all,
 I have a Perl script in Windows but my system administrator doesn't allow me
 to install ActivePerl nor i guess anything that will change rigistry on the
 machine.
 is there any other way to run the script?
 

Yes, there are several ways:

1. One is to use the Portable version of Strawberry Perl:

http://strawberryperl.com/releases.html

2. The second one is to use PAR to pack the script into a self-contained
executable:

http://par.wikia.com/wiki/Main_Page



Maybe there are other ways that I cannot think of now.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Escape from GNU Autohell - http://www.shlomifish.org/open-source/anti/autohell/

Chuck Norris does not code; when he sits at a computer, it just does whatever
he wants. — Kattana on Freenode’s #perl6 .

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Run perl scripts in Windows

2011-10-18 Thread Igor Dovgiy
Hello Remy,

I guess you may either convert this script with something like perl2exe (or
similar solutions),
or use the portable version of Strawberry Perl -
http://strawberryperl.com/download/5.12.3.0/strawberry-perl-5.12.3.0-portable.zip
- to run it.

-- iD

2011/10/18 Remy Guo rollingst...@gmail.com

 hi all,
 I have a Perl script in Windows but my system administrator doesn't allow
 me
 to install ActivePerl nor i guess anything that will change rigistry on the
 machine.
 is there any other way to run the script?

 Thanks..

 Remy



Re: don't know where to start??? comparing files

2011-10-18 Thread Randal L. Schwartz
 Shawn == Shawn H Corey shawnhco...@gmail.com writes:

Shawn On 11-10-14 02:08 AM, Randal L. Schwartz wrote:
 Because this uses*my*  environment when I run*your*  Perl script.
 That's broken.

Shawn Then you should un-break your environment. I can help you if
Shawn you're using Linux. If you're using Windows, I'm sure there are
Shawn many on the list who can help.

My environment is not broken.  It's set the way I want to set it.

If your program requires a different environment, then it should set it
internally.  I should always be able to invoke /your/program/like/this
and just have it *work*.  If not, it's your problem, not mine.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: How to create randomly generated emails

2011-10-18 Thread Randal L. Schwartz
 Ryan == Ryan Munson ryan.barrac...@elboardo.com writes:

Ryan Are there any good articles out there or references to lookup on
Ryan how to create a simple script that could do the above? I am not
Ryan asking for someone to write this for me, but rather suggestions on
Ryan modules or resources that are good to read up on for automation.

One of my few CPAN contributions, Inline::Spew, might do the trick
nicely.

Came from the column at http://www.stonehenge.com/merlyn/LinuxMag/col04.html

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Madrigal, Juan A
Hi All!

I'm having serious problems trying to install DateTime-0.70 along with
pre-requisites Params-Validate-1.00
on Mac OS X 10.6.8 via CPAN.

I'm using the default install of Perl 5.10 (64bit). What jumps out to me
is this: Error: no compiler detected to compile 'lib/DateTime.c'.
Aborting

I have gcc 4.2 installed and I've even reinstalled Xcode 4.0.2 and no
luck. Here are the other errors:

Warning: Prerequisite 'Params::Validate = 0.76' for
'D/DR/DROLSKY/DateTime-0.70.tar.gz' failed when processing
'D/DR/DROLSKY/Params-Validate-1.00.tar.gz' with 'make = NO'. Continuing,
but chances to succeed are limited.
Building DateTime
Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting
  DROLSKY/DateTime-0.70.tar.gz
  ./Build -- NOT OK
Running Build test
  Can't test without successful make
Running Build install
  Make had returned bad status, install seems impossible
CPAN: Module::Build loaded ok (v0.38)
Failed during this command:
 DROLSKY/DateTime-Locale-0.45.tar.gz  : make_test FAILED but
failure ignored because 'force' in effect
 DROLSKY/DateTime-TimeZone-1.40.tar.gz: make_test FAILED but
failure ignored because 'force' in effect
 DROLSKY/Params-Validate-1.00.tar.gz  : make NO
 DROLSKY/DateTime-0.70.tar.gz : make NO

Any ideas?


What flags would I need to build and compile a separate install of perl
for Mac OS X 10.6.8 (64bit), say under /usr/local/bin/perl along with cpan?

Thanks,

Juan


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Rob Coops
On Tue, Oct 18, 2011 at 4:20 PM, Madrigal, Juan A j.madrig...@miami.eduwrote:

 Hi All!

 I'm having serious problems trying to install DateTime-0.70 along with
 pre-requisites Params-Validate-1.00
 on Mac OS X 10.6.8 via CPAN.

 I'm using the default install of Perl 5.10 (64bit). What jumps out to me
 is this: Error: no compiler detected to compile 'lib/DateTime.c'.
 Aborting

 I have gcc 4.2 installed and I've even reinstalled Xcode 4.0.2 and no
 luck. Here are the other errors:

 Warning: Prerequisite 'Params::Validate = 0.76' for
 'D/DR/DROLSKY/DateTime-0.70.tar.gz' failed when processing
 'D/DR/DROLSKY/Params-Validate-1.00.tar.gz' with 'make = NO'. Continuing,
 but chances to succeed are limited.
 Building DateTime
 Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting
  DROLSKY/DateTime-0.70.tar.gz
  ./Build -- NOT OK
 Running Build test
  Can't test without successful make
 Running Build install
  Make had returned bad status, install seems impossible
 CPAN: Module::Build loaded ok (v0.38)
 Failed during this command:
  DROLSKY/DateTime-Locale-0.45.tar.gz  : make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/DateTime-TimeZone-1.40.tar.gz: make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/Params-Validate-1.00.tar.gz  : make NO
  DROLSKY/DateTime-0.70.tar.gz : make NO

 Any ideas?


 What flags would I need to build and compile a separate install of perl
 for Mac OS X 10.6.8 (64bit), say under /usr/local/bin/perl along with cpan?

 Thanks,

 Juan


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



Hi Juan,

You might have GCC installed but do you have it configured?

Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting

Seems quite clear to me there is no C compiler found, you might want to have
a look at your CPAN settings and see if your compiler is set there. Normally
assuming you had the compiler installed before running CPAN setup it would
automatically detect the compiler. By the sound of it you might have
installed the compiler after running the CPAN setup in which case it will
simply have no compiler listed and will likely throw an error like this.

The other errors seems to stem from this problem so resolving that should
most likely fix the rest of the errors as well.

Regards,

Rob


Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Randal L. Schwartz
 Juan == Madrigal, Juan A j.madrig...@miami.edu writes:

[something unrelated to the parent of this message]

Please don't hijack a thread.  Don't start a new thread by replying to a
previous item and then just editing the subject line.  Your message has
*nothing* to do with my posting.

If you need help with your particular mail/news/thread reader, please
consult the appropriate documentation.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.posterous.com/ for Smalltalk discussion

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: don't know where to start??? comparing files

2011-10-18 Thread Zachary Zebrowski
Why don't we just agree to disagree and move on.  You both know you have a
valid point, and yet there is valid reasons on both sides for having it the
way it is, and why in particular environments it's valid to have it one way
or the other.

On Tue, Oct 18, 2011 at 10:13 AM, Randal L. Schwartz
mer...@stonehenge.comwrote:

  Shawn == Shawn H Corey shawnhco...@gmail.com writes:

 Shawn On 11-10-14 02:08 AM, Randal L. Schwartz wrote:
  Because this uses*my*  environment when I run*your*  Perl script.
  That's broken.

 Shawn Then you should un-break your environment. I can help you if
 Shawn you're using Linux. If you're using Windows, I'm sure there are
 Shawn many on the list who can help.

 My environment is not broken.  It's set the way I want to set it.

 If your program requires a different environment, then it should set it
 internally.  I should always be able to invoke /your/program/like/this
 and just have it *work*.  If not, it's your problem, not mine.

 --
 Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
 0095
 mer...@stonehenge.com URL:http://www.stonehenge.com/merlyn/
 Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
 See http://methodsandmessages.posterous.com/ for Smalltalk discussion

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Re: Perl Fork and writing to stdout

2011-10-18 Thread Brandon McCaig
On Mon, Oct 17, 2011 at 2:05 PM, sunckell sunck...@gmail.com wrote:
 So here we are back to the script.. The script works as
 expected, with one item of strangeness. I was expecting the
 log messages to be printed in the order they complete. For
 example, if the connection attempt at 12:01 took 75 seconds to
 return, and the connection attempt at 12:02 to 5 seconds to
 return, I would expect the 12:02 message to appear first then
 the 12:01, but it doesn't. The 12:02 connection won't print
 until the 12:01 returns.

 use strict;

You probably want the 'warnings' pragma too. :)

 $|++;

Well I'm out of ideas. :P

  if ($pid) {
# parent
  } elsif ($pid == 0) {
# child
my $p = _initialize($ct);
waitpid($p, 0);
exit 0;
  } else {
die couldnt fork: $!\n;
  }

nitpick:

I would much rather see that as something like this:

  die couldn't fork: $! unless defined $pid;

  if($pid == 0)
  {
  my $p = _initialize($ct);
  waitpid($p, 0);
  exit 0;
  }

Irrespective of what it's doing, it drives me nuts to see an
if...else ladder (or any control structure) with an empty block.
:P I have a colleague that does it and it drives me crazy.

It also makes sense to me that if you're going to die when
something fails that you probably want the die as close to the
thing failing as possible to make it clear.

/nitpick

  my $user = 'root';

That looks a bit dangerous to me, but I digress. :P If it were me
I'd probably prefer to use a non-root user for anything
involving an automated SSH session. I'll trust that you know what
you're doing then.

 sub write_to_log{
my ($message) = @_;

my $log = /tmp/$short_name.log;

if ($debug){
print $message\n;
}

open L, $log or die Cannot open $log:$!\n;
print L $message\n;
close L;
 }

Are you sure it's necessary to open and close the log file every
time you write to it? That doesn't look particular good to me.
Couldn't you just open it one time in the parent process? Perhaps
that accounts for the variance in write order.

/guess

 Just wondering why the messages being printed to the console
 waits for the previous pid (or pids) to complete before it's
 viewable.

I don't think you can rely on the order of things happening
though in different processes (or threads). So I don't know that
it's really anything to be concerned about. If anything, I would
design the output so that order didn't matter. As you said, you
can always sort the output later if it helps to interpret it. I'm
only assuming that I understand what's happening though. ^_^


-- 
Brandon McCaig bamcc...@gmail.com bamcc...@castopulence.org
Castopulence Software https://www.castopulence.org/
Blog http://www.bamccaig.com/
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Madrigal, Juan A
Hi Rob,

I checked my cpan configuration (MyConfig.pm) but nothing sticks out:

$CPAN::Config = {
  'applypatch' = q[],
  'auto_commit' = q[0],
  'build_cache' = q[100],
  'build_dir' = q[/Users/juan/.cpan/build],
  'build_dir_reuse' = q[1],
  'build_requires_install_policy' = q[ask/yes],
  'bzip2' = q[/usr/bin/bzip2],
  'cache_metadata' = q[1],
  'check_sigs' = q[0],
  'commandnumber_in_prompt' = q[1],
  'cpan_home' = q[/Users/juan/.cpan],
  'curl' = q[/usr/bin/curl],
  'ftp' = q[/usr/bin/ftp],
  'ftp_passive' = q[1],
  'ftp_proxy' = q[],
  'getcwd' = q[cwd],
  'gpg' = q[],
  'gzip' = q[/usr/bin/gzip],
  'histfile' = q[/Users/juan/.cpan/histfile],
  'histsize' = q[100],
  'http_proxy' = q[],
  'inactivity_timeout' = q[0],
  'index_expire' = q[1],
  'inhibit_startup_message' = q[0],
  'keep_source_where' = q[/Users/juan/.cpan/sources],
  'load_module_verbosity' = q[v],
  'lynx' = q[],
  'make' = q[/usr/bin/make],
  'make_arg' = q[],
  'make_install_arg' = q[UNINST=1],
  'make_install_make_command' = q[/usr/bin/make],
  'makepl_arg' = q[],
  'mbuild_arg' = q[],
  'mbuild_install_arg' = q[],
  'mbuild_install_build_command' = q[./Build],
  'mbuildpl_arg' = q[],
  'ncftp' = q[],
  'ncftpget' = q[],
  'no_proxy' = q[],
  'pager' = q[/usr/bin/less],
  'patch' = q[/usr/bin/patch],
  'prefer_installer' = q[MB],
  'prefs_dir' = q[/Users/juan/.cpan/prefs],
  'prerequisites_policy' = q[ask],
  'scan_cache' = q[atstart],
  'shell' = q[/bin/bash],
  'show_unparsable_versions' = q[0],
  'show_upload_date' = q[0],
  'show_zero_versions' = q[0],
  'tar' = q[/usr/bin/tar],
  'tar_verbosity' = q[v],
  'term_is_latin' = q[1],
  'term_ornaments' = q[1],
  'test_report' = q[0],
  'unzip' = q[/usr/bin/unzip],
  'urllist' = [],
  'use_sqlite' = q[0],
  'wget' = q[/usr/local/bin/wget],
  'yaml_load_code' = q[0],
  'yaml_module' = q[YAML],
};


-Juan

On 10/18/11 10:26 AM, Rob Coops rco...@gmail.com wrote:

On Tue, Oct 18, 2011 at 4:20 PM, Madrigal, Juan A
j.madrig...@miami.eduwrote:

 Hi All!

 I'm having serious problems trying to install DateTime-0.70 along with
 pre-requisites Params-Validate-1.00
 on Mac OS X 10.6.8 via CPAN.

 I'm using the default install of Perl 5.10 (64bit). What jumps out to me
 is this: Error: no compiler detected to compile 'lib/DateTime.c'.
 Aborting

 I have gcc 4.2 installed and I've even reinstalled Xcode 4.0.2 and no
 luck. Here are the other errors:

 Warning: Prerequisite 'Params::Validate = 0.76' for
 'D/DR/DROLSKY/DateTime-0.70.tar.gz' failed when processing
 'D/DR/DROLSKY/Params-Validate-1.00.tar.gz' with 'make = NO'.
Continuing,
 but chances to succeed are limited.
 Building DateTime
 Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting
  DROLSKY/DateTime-0.70.tar.gz
  ./Build -- NOT OK
 Running Build test
  Can't test without successful make
 Running Build install
  Make had returned bad status, install seems impossible
 CPAN: Module::Build loaded ok (v0.38)
 Failed during this command:
  DROLSKY/DateTime-Locale-0.45.tar.gz  : make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/DateTime-TimeZone-1.40.tar.gz: make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/Params-Validate-1.00.tar.gz  : make NO
  DROLSKY/DateTime-0.70.tar.gz : make NO

 Any ideas?


 What flags would I need to build and compile a separate install of perl
 for Mac OS X 10.6.8 (64bit), say under /usr/local/bin/perl along with
cpan?

 Thanks,

 Juan


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



Hi Juan,

You might have GCC installed but do you have it configured?

Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting

Seems quite clear to me there is no C compiler found, you might want to
have
a look at your CPAN settings and see if your compiler is set there.
Normally
assuming you had the compiler installed before running CPAN setup it would
automatically detect the compiler. By the sound of it you might have
installed the compiler after running the CPAN setup in which case it will
simply have no compiler listed and will likely throw an error like this.

The other errors seems to stem from this problem so resolving that should
most likely fix the rest of the errors as well.

Regards,

Rob


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Ryan Munson
Doubt this would be the problem but I had to run as sudo to install CPAN
modules recently??? Otherwise, I would get a permissions issue, but it
would say No such file or directory.

Ryan




On 10/18/11 11:05 AM, Madrigal, Juan A j.madrig...@miami.edu wrote:

Hi Rob,

I checked my cpan configuration (MyConfig.pm) but nothing sticks out:

$CPAN::Config = {
  'applypatch' = q[],
  'auto_commit' = q[0],
  'build_cache' = q[100],
  'build_dir' = q[/Users/juan/.cpan/build],
  'build_dir_reuse' = q[1],
  'build_requires_install_policy' = q[ask/yes],
  'bzip2' = q[/usr/bin/bzip2],
  'cache_metadata' = q[1],
  'check_sigs' = q[0],
  'commandnumber_in_prompt' = q[1],
  'cpan_home' = q[/Users/juan/.cpan],
  'curl' = q[/usr/bin/curl],
  'ftp' = q[/usr/bin/ftp],
  'ftp_passive' = q[1],
  'ftp_proxy' = q[],
  'getcwd' = q[cwd],
  'gpg' = q[],
  'gzip' = q[/usr/bin/gzip],
  'histfile' = q[/Users/juan/.cpan/histfile],
  'histsize' = q[100],
  'http_proxy' = q[],
  'inactivity_timeout' = q[0],
  'index_expire' = q[1],
  'inhibit_startup_message' = q[0],
  'keep_source_where' = q[/Users/juan/.cpan/sources],
  'load_module_verbosity' = q[v],
  'lynx' = q[],
  'make' = q[/usr/bin/make],
  'make_arg' = q[],
  'make_install_arg' = q[UNINST=1],
  'make_install_make_command' = q[/usr/bin/make],
  'makepl_arg' = q[],
  'mbuild_arg' = q[],
  'mbuild_install_arg' = q[],
  'mbuild_install_build_command' = q[./Build],
  'mbuildpl_arg' = q[],
  'ncftp' = q[],
  'ncftpget' = q[],
  'no_proxy' = q[],
  'pager' = q[/usr/bin/less],
  'patch' = q[/usr/bin/patch],
  'prefer_installer' = q[MB],
  'prefs_dir' = q[/Users/juan/.cpan/prefs],
  'prerequisites_policy' = q[ask],
  'scan_cache' = q[atstart],
  'shell' = q[/bin/bash],
  'show_unparsable_versions' = q[0],
  'show_upload_date' = q[0],
  'show_zero_versions' = q[0],
  'tar' = q[/usr/bin/tar],
  'tar_verbosity' = q[v],
  'term_is_latin' = q[1],
  'term_ornaments' = q[1],
  'test_report' = q[0],
  'unzip' = q[/usr/bin/unzip],
  'urllist' = [],
  'use_sqlite' = q[0],
  'wget' = q[/usr/local/bin/wget],
  'yaml_load_code' = q[0],
  'yaml_module' = q[YAML],
};


-Juan

On 10/18/11 10:26 AM, Rob Coops rco...@gmail.com wrote:

On Tue, Oct 18, 2011 at 4:20 PM, Madrigal, Juan A
j.madrig...@miami.eduwrote:

 Hi All!

 I'm having serious problems trying to install DateTime-0.70 along with
 pre-requisites Params-Validate-1.00
 on Mac OS X 10.6.8 via CPAN.

 I'm using the default install of Perl 5.10 (64bit). What jumps out to
me
 is this: Error: no compiler detected to compile 'lib/DateTime.c'.
 Aborting

 I have gcc 4.2 installed and I've even reinstalled Xcode 4.0.2 and no
 luck. Here are the other errors:

 Warning: Prerequisite 'Params::Validate = 0.76' for
 'D/DR/DROLSKY/DateTime-0.70.tar.gz' failed when processing
 'D/DR/DROLSKY/Params-Validate-1.00.tar.gz' with 'make = NO'.
Continuing,
 but chances to succeed are limited.
 Building DateTime
 Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting
  DROLSKY/DateTime-0.70.tar.gz
  ./Build -- NOT OK
 Running Build test
  Can't test without successful make
 Running Build install
  Make had returned bad status, install seems impossible
 CPAN: Module::Build loaded ok (v0.38)
 Failed during this command:
  DROLSKY/DateTime-Locale-0.45.tar.gz  : make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/DateTime-TimeZone-1.40.tar.gz: make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/Params-Validate-1.00.tar.gz  : make NO
  DROLSKY/DateTime-0.70.tar.gz : make NO

 Any ideas?


 What flags would I need to build and compile a separate install of perl
 for Mac OS X 10.6.8 (64bit), say under /usr/local/bin/perl along with
cpan?

 Thanks,

 Juan


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



Hi Juan,

You might have GCC installed but do you have it configured?

Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting

Seems quite clear to me there is no C compiler found, you might want to
have
a look at your CPAN settings and see if your compiler is set there.
Normally
assuming you had the compiler installed before running CPAN setup it
would
automatically detect the compiler. By the sound of it you might have
installed the compiler after running the CPAN setup in which case it will
simply have no compiler listed and will likely throw an error like this.

The other errors seems to stem from this problem so resolving that should
most likely fix the rest of the errors as well.

Regards,

Rob


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/





-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Madrigal, Juan A
Nope, I've been running cpan under sudo. I'm going to try installing cmake
with brew and pointing to that vs make.

Maybe it will help. I'll already reinstalled perl using pacifist and no
luck. I also tried installing the modules on a new clean install and
nothing. I'm thinking the module may be broken and need an update.

Any advice on installing a fresh install of perl and cpan in a different
directory?

Flags etc...?

Thanks,

Juan

On 10/18/11 11:17 AM, Ryan Munson ryan.barrac...@elboardo.com wrote:

Doubt this would be the problem but I had to run as sudo to install CPAN
modules recently??? Otherwise, I would get a permissions issue, but it
would say No such file or directory.

Ryan




On 10/18/11 11:05 AM, Madrigal, Juan A j.madrig...@miami.edu wrote:

Hi Rob,

I checked my cpan configuration (MyConfig.pm) but nothing sticks out:

$CPAN::Config = {
  'applypatch' = q[],
  'auto_commit' = q[0],
  'build_cache' = q[100],
  'build_dir' = q[/Users/juan/.cpan/build],
  'build_dir_reuse' = q[1],
  'build_requires_install_policy' = q[ask/yes],
  'bzip2' = q[/usr/bin/bzip2],
  'cache_metadata' = q[1],
  'check_sigs' = q[0],
  'commandnumber_in_prompt' = q[1],
  'cpan_home' = q[/Users/juan/.cpan],
  'curl' = q[/usr/bin/curl],
  'ftp' = q[/usr/bin/ftp],
  'ftp_passive' = q[1],
  'ftp_proxy' = q[],
  'getcwd' = q[cwd],
  'gpg' = q[],
  'gzip' = q[/usr/bin/gzip],
  'histfile' = q[/Users/juan/.cpan/histfile],
  'histsize' = q[100],
  'http_proxy' = q[],
  'inactivity_timeout' = q[0],
  'index_expire' = q[1],
  'inhibit_startup_message' = q[0],
  'keep_source_where' = q[/Users/juan/.cpan/sources],
  'load_module_verbosity' = q[v],
  'lynx' = q[],
  'make' = q[/usr/bin/make],
  'make_arg' = q[],
  'make_install_arg' = q[UNINST=1],
  'make_install_make_command' = q[/usr/bin/make],
  'makepl_arg' = q[],
  'mbuild_arg' = q[],
  'mbuild_install_arg' = q[],
  'mbuild_install_build_command' = q[./Build],
  'mbuildpl_arg' = q[],
  'ncftp' = q[],
  'ncftpget' = q[],
  'no_proxy' = q[],
  'pager' = q[/usr/bin/less],
  'patch' = q[/usr/bin/patch],
  'prefer_installer' = q[MB],
  'prefs_dir' = q[/Users/juan/.cpan/prefs],
  'prerequisites_policy' = q[ask],
  'scan_cache' = q[atstart],
  'shell' = q[/bin/bash],
  'show_unparsable_versions' = q[0],
  'show_upload_date' = q[0],
  'show_zero_versions' = q[0],
  'tar' = q[/usr/bin/tar],
  'tar_verbosity' = q[v],
  'term_is_latin' = q[1],
  'term_ornaments' = q[1],
  'test_report' = q[0],
  'unzip' = q[/usr/bin/unzip],
  'urllist' = [],
  'use_sqlite' = q[0],
  'wget' = q[/usr/local/bin/wget],
  'yaml_load_code' = q[0],
  'yaml_module' = q[YAML],
};


-Juan

On 10/18/11 10:26 AM, Rob Coops rco...@gmail.com wrote:

On Tue, Oct 18, 2011 at 4:20 PM, Madrigal, Juan A
j.madrig...@miami.eduwrote:

 Hi All!

 I'm having serious problems trying to install DateTime-0.70 along with
 pre-requisites Params-Validate-1.00
 on Mac OS X 10.6.8 via CPAN.

 I'm using the default install of Perl 5.10 (64bit). What jumps out to
me
 is this: Error: no compiler detected to compile 'lib/DateTime.c'.
 Aborting

 I have gcc 4.2 installed and I've even reinstalled Xcode 4.0.2 and no
 luck. Here are the other errors:

 Warning: Prerequisite 'Params::Validate = 0.76' for
 'D/DR/DROLSKY/DateTime-0.70.tar.gz' failed when processing
 'D/DR/DROLSKY/Params-Validate-1.00.tar.gz' with 'make = NO'.
Continuing,
 but chances to succeed are limited.
 Building DateTime
 Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting
  DROLSKY/DateTime-0.70.tar.gz
  ./Build -- NOT OK
 Running Build test
  Can't test without successful make
 Running Build install
  Make had returned bad status, install seems impossible
 CPAN: Module::Build loaded ok (v0.38)
 Failed during this command:
  DROLSKY/DateTime-Locale-0.45.tar.gz  : make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/DateTime-TimeZone-1.40.tar.gz: make_test FAILED but
 failure ignored because 'force' in effect
  DROLSKY/Params-Validate-1.00.tar.gz  : make NO
  DROLSKY/DateTime-0.70.tar.gz : make NO

 Any ideas?


 What flags would I need to build and compile a separate install of
perl
 for Mac OS X 10.6.8 (64bit), say under /usr/local/bin/perl along with
cpan?

 Thanks,

 Juan


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/



Hi Juan,

You might have GCC installed but do you have it configured?

Error: no compiler detected to compile 'lib/DateTime.c'.  Aborting

Seems quite clear to me there is no C compiler found, you might want to
have
a look at your CPAN settings and see if your compiler is set there.
Normally
assuming you had the compiler installed before running CPAN setup it
would
automatically detect the compiler. By the sound of it you might have
installed the compiler after running the CPAN setup in which case it
will
simply have no compiler listed and will likely throw an error like this.

The 

Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Phil Dobbin
On 18/10/11 at 16:22, j.madrig...@miami.edu (Madrigal, Juan A) wrote:

[...]

 Any advice on installing a fresh install of perl and cpan in a different
 directory?
 
 Flags etc...?

 
http://learnperl.scratchcomputing.com/tutorials/configuration/#installing_more_perls
 
 Cheers,

Phil.
--
Please consider the environment before reading this email...


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Installing CPAN Params::Validate and DateTime on Mac OS X 10.6.8

2011-10-18 Thread Madrigal, Juan A
Thanks Phil!

I installed Perl 5.14.2 and DateTime seems to have installed except that
DateTime.pm is missing.

When I point to the lib directory via the use command DateTime shows up in
my IDE (Komodo) but with an error message when I hover over use DateTime:

BEGIN failed --Compilation aborted.

I'm really starting to think that its a module issue.

-Juan

On 10/18/11 11:32 AM, Phil Dobbin phildob...@gmail.com wrote:

On 18/10/11 at 16:22, j.madrig...@miami.edu (Madrigal, Juan A) wrote:

[...]

 Any advice on installing a fresh install of perl and cpan in a different
 directory?
 
 Flags etc...?

 
http://learnperl.scratchcomputing.com/tutorials/configuration/#installing
_more_perls
 
 Cheers,

Phil.
--
Please consider the environment before reading this email...



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Run perl scripts in Windows

2011-10-18 Thread Natxo Asenjo
On Oct 18, 2011 3:07 PM, Remy Guo rollingst...@gmail.com wrote:

 hi all,
 I have a Perl script in Windows but my system administrator doesn't allow
me
 to install ActivePerl nor i guess anything that will change rigistry on
the
 machine.

You do not need to install anything on that host. You can install the msi in
another windows host and copy the c:\perl folder (if you choose to standard
location) to the host where you need to run the script.

After doing that, you can run your Perl scripts from a cmd prompt. Open
cmd.exe and in there type the path to perl.exe (if you have copied it to
c:\perl, it will be c:\perl\bin\perl.exe) and the path to your script.

So if you have your script in d:\scripts\test.pl, you type in cmd.exe:

c:\perl\bin\perl.exe d:\scripts\test.pl

If you want to associate the extension pl with perl.exe, then you need to
follow the instructions in here:

http://technet.microsoft.com/en-us/library/bb490912.aspx

When you install the active state msi, those things are automatically done
for you, that is the only difference.

-- 

natxo


Re: Run perl scripts in Windows

2011-10-18 Thread frank cui
i believe most group policy deployments doesn't allow personal created files
on root directory of system disk.

On Tue, Oct 18, 2011 at 5:16 PM, Natxo Asenjo natxo.ase...@gmail.comwrote:

 On Oct 18, 2011 3:07 PM, Remy Guo rollingst...@gmail.com wrote:
 
  hi all,
  I have a Perl script in Windows but my system administrator doesn't allow
 me
  to install ActivePerl nor i guess anything that will change rigistry on
 the
  machine.

 You do not need to install anything on that host. You can install the msi
 in
 another windows host and copy the c:\perl folder (if you choose to standard
 location) to the host where you need to run the script.

 After doing that, you can run your Perl scripts from a cmd prompt. Open
 cmd.exe and in there type the path to perl.exe (if you have copied it to
 c:\perl, it will be c:\perl\bin\perl.exe) and the path to your script.

 So if you have your script in d:\scripts\test.pl, you type in cmd.exe:

 c:\perl\bin\perl.exe d:\scripts\test.pl

 If you want to associate the extension pl with perl.exe, then you need to
 follow the instructions in here:

 http://technet.microsoft.com/en-us/library/bb490912.aspx

 When you install the active state msi, those things are automatically done
 for you, that is the only difference.

 --

 natxo



Re: Perl Fork and writing to stdout

2011-10-18 Thread John W. Krahn

sunckell wrote:

Hello Perl People

  I was wondering if someone could enlighten me on an observation I
have been seeing..

A little Background info:
  Where I work we have been seeing very slow ssh connections times
(it's not DNS.  Maybe NIS, NFS, but definitely not DNS).

   Anyways I wanted to write a script that would log the time it
takes to connect to a remote server via ssh and issue a command (uname
-n).  The tricky part was that I wanted the remote connections to kick
off every 60 secs.  (some ssh connections take a lot longer.  120+ in
some cases).  The log should enable me to pinpoint any time
correlation to the long ssh connect occurrences (every 5 minutes?  1/2
past every hour? etc).

  So here we are back to the script..  The script works as
expected, with one item of strangeness.  I was expecting the log
messages to be printed in the order they complete. For example, if the
connection attempt at 12:01 took 75 seconds to return, and the
connection attempt at 12:02 to 5 seconds to return, I would expect the
12:02 message to appear first then the 12:01, but it doesn't.  The
12:02 connection won't print until the 12:01 returns.

Here is my code:

use strict;
use Getopt::Std;
use Sys::Hostname;
use File::Basename;
use Net::SSH qw( sshopen2 );
use Time::HiRes qw( gettimeofday tv_interval );
$|++;

$SIG{CHLD} = 'IGNORE';

my %opts;
getopts('dr:', \%opts);

my $localhost = hostname();
my $r_host= $opts{'r'} ? $opts{'r'} : die need remote host-r
\n;


That is usually written as:

my $r_host= $opts{ r } or die need remote host-r\n;



my $debug = $opts{'d'};
my $short_name = basename($0, .pl);

# --- set the counter to zero.  We'll print the counter to the log for
easier sorting
# --- of data where the ssh connections take longer than a minute to
return.
my $ct = 0;

while (1) {

 my $pid = fork();

 if ($pid) {
 # parent
 } elsif ($pid == 0) {
 # child
 my $p = _initialize($ct);
 waitpid($p, 0);
 exit 0;
 } else {
 die couldnt fork: $!\n;
 }


That won't work correctly if fork returns undef and sets $! because 
undef in numerical context is the same as 0.


$ perl -le'print undef is , undef == 0 ?  : NOT , equal to 0'
undef is equal to 0

And without warnings enabled you won't catch this mistake.

See:

perldoc perlipc

For how to verify that fork() worked correctly.



 $ct++;
 sleep 60;
}

# ---
# --- sub: initialize
# --- descr:   for easier viewing of the code for the fork process.
# --- returns: nothing
# ---
sub _initialize{
 my($count) = @_;

 my $now= scalar localtime();


my $now =  forces scalar context on the right hand side of the 
assignment so the use of scalar is redundant.




 my $start   = [gettimeofday()];

 my $ret = connect_to_remote_host($r_host);

 my $elapsed = tv_interval( $start );

 if ($count  10){
 $count = 0$count;
 }

 if ($count  99){
 $count = 0$count;
 }


That is usually performed with sprintf:

$count = sprintf '%03d', $_[ 0 ];



 my $msg =  $count - [$now] $localhost to $r_host Elapsed time:
$elapsed ;
 write_to_log($msg);

 return;

}




John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/