[17109] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4521 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 4 18:05:43 2000

Date: Wed, 4 Oct 2000 15:05:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970697116-v9-i4521@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 4 Oct 2000     Volume: 9 Number: 4521

Today's topics:
        (Beginner) Perl split function... aplummer@my-deja.com
    Re: (Beginner) Perl split function... aramis1250@my-deja.com
    Re: (Beginner) Perl split function... <lr@hpl.hp.com>
    Re: (Beginner) Perl split function... aramis1250@my-deja.com
        [OT] Re: help: FORCE perl to evaluate arithmetic string <anmcguire@ce.mediaone.net>
        A little Cookie-Problem!! <Thomas@Trendsetter.de>
    Re: A matter of style (was Re: Search and Destroy) <nospam@david-steuber.com>
    Re: A matter of style (was Re: Search and Destroy) (Chris Fedde)
    Re: Blank line appending data to file (Brandon Metcalf)
        Code example in Cookbook aramis1250@my-deja.com
    Re: die() ignores tied STDERR? (Ilya Zakharevich)
        embedding in HTML <g99z44@yahoo.com>
    Re: embedding in HTML <yf32@cornell.edu>
        ExtUtils::MakeMaker and g+w install permissions (John J. Trammell)
    Re: force arithmetic interpretation (Andrew J. Perrin)
        Forking, Exiting, and Timing out within an Eval <already_seen@my-deja.com>
        help in finding info on perl hajir@my-deja.com
    Re: help in finding info on perl <jeff@vpservices.com>
    Re: Help with CGI stdenton@my-deja.com
    Re: help: FORCE perl to evaluate arithmetic string <lr@hpl.hp.com>
    Re: help: FORCE perl to evaluate arithmetic string <godzilla@stomp.stomp.tokyo>
        how do I set server socket timeouts with setsockopt? <kingsley@skymarket.get.co.rid..uk>
    Re: how do I set server socket timeouts with setsockopt <bart.lateur@skynet.be>
        How to find IP address by MAC address? <pangjo@hotmail.com>
        HTML Email <mailing@_sussex_-_internet.co._uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 04 Oct 2000 20:14:21 GMT
From: aplummer@my-deja.com
Subject: (Beginner) Perl split function...
Message-Id: <8rg32m$hod$1@nnrp1.deja.com>

I have a problem with an array split, as described below:

while (@PathOfFiles)
  {
     $filename = split( /\//);
     copy ($filename, "$New_Dir/$filename.bkp")
  }

Now, @PathOfFiles holds a large number of unix files, with
their paths...

@PathOfFiles = {
"/etc/passwd",
"/etc/dfs/dfstab",
"/etc/hosts",
 ...
}

I need to get rid of the path, keep the filename, and copy those
files to a certain directory, $New_Dir, with the new extension.
How would I do this?

I have been trying it with a split - to split up the array, and
get at the last entry - but as you can see, I'm having problems
getting it to work.

Thanks!


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


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

Date: Wed, 04 Oct 2000 20:34:47 GMT
From: aramis1250@my-deja.com
Subject: Re: (Beginner) Perl split function...
Message-Id: <8rg497$ipg$1@nnrp1.deja.com>

In article <8rg32m$hod$1@nnrp1.deja.com>,
  aplummer@my-deja.com wrote:
> I have a problem with an array split, as described below:
>
> while (@PathOfFiles)
>   {
>      $filename = split( /\//);
>      copy ($filename, "$New_Dir/$filename.bkp")
>   }
>
> Now, @PathOfFiles holds a large number of unix files, with
> their paths...
>
> @PathOfFiles = {
> "/etc/passwd",
> "/etc/dfs/dfstab",
> "/etc/hosts",
> ...
> }
>
> I need to get rid of the path, keep the filename, and copy those
> files to a certain directory, $New_Dir, with the new extension.
> How would I do this?

The split function will separate each part of the array on the
backslash character. You'll need variables to hold each part of the
split:

while (@PathOfFiles) {

  ($path1, $filename) = split(/\//);
  # Now, for a one-deep file/directory, say /etc/password
  # $path1 == etc and $filename == passwd

} #END while

I would probably do this:
foreach (@PathOfFiles) {

  $filename = (/\w+$);

} # end foreach

YMMV.


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


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

Date: Wed, 4 Oct 2000 14:09:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: (Beginner) Perl split function...
Message-Id: <MPG.14453c5e4e6c8aa198ae08@nntp.hpl.hp.com>

In article <8rg497$ipg$1@nnrp1.deja.com> on Wed, 04 Oct 2000 20:34:47 
GMT, aramis1250@my-deja.com <aramis1250@my-deja.com> says...
> In article <8rg32m$hod$1@nnrp1.deja.com>,
>   aplummer@my-deja.com wrote:
> > I have a problem with an array split, as described below:
> >
> > while (@PathOfFiles)
> >   {
> >      $filename = split( /\//);
> >      copy ($filename, "$New_Dir/$filename.bkp")
> >   }

 ...

> The split function will separate each part of the array on the
> backslash character. You'll need variables to hold each part of the
> split:

The split is on the *forward*slash character, also known simply as 
'slash'.

> while (@PathOfFiles) {
> 
>   ($path1, $filename) = split(/\//);
>   # Now, for a one-deep file/directory, say /etc/password
>   # $path1 == etc and $filename == passwd

Wrong.  $path1 would contain the null string "", and $filename eq 'etc'.

> } #END while
> 
> I would probably do this:
> foreach (@PathOfFiles) {
> 
>   $filename = (/\w+$);

If you did this, it wouldn't compile.

    $filename = /(\w+)$/;

But this is wrong anyway -- see below.

> } # end foreach
> 
> YMMV.

It certainly would vary, because filenames may contain characters other 
than word characters, such as '-' and '.' (and on Unix, anything except 
'/').

To extract the filename from a filepath in $_:

    my $filename = (split m!/!)[-1];

    my ($filename) = m!([^/]+)$!;

Or, for portability to other file-system naming conventions, use the 
File::Basename module.
    
-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 04 Oct 2000 21:19:02 GMT
From: aramis1250@my-deja.com
Subject: Re: (Beginner) Perl split function...
Message-Id: <8rg6rv$la0$1@nnrp1.deja.com>

[snip]
> foreach (@PathOfFiles) {
>
>   $filename = (/\w+$);
>
> } # end foreach
>

[/snip]

don't forget the trailing slash:

$filename = (/\w+$/);

<bonk self on head></bonk self on head>


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


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

Date: Wed, 4 Oct 2000 15:20:54 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: [OT] Re: help: FORCE perl to evaluate arithmetic string
Message-Id: <Pine.LNX.4.21.0010041503470.9288-100000@hawk.ce.mediaone.net>

On Wed, 4 Oct 2000, Godzilla! quoth:

G> Larry Rosler wrote:
G>  
G> > In article <39DA6C18.5154D3B1@stomp.stomp.tokyo>,
G> > godzilla@stomp.stomp.tokyo says...
G> > > ruzbehgonda@my-deja.com wrote:
G> 
G> > > > after building an arithmetic expression dynamically
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

G> > > > eg. $arith = ( (1 * 0) + 1) + 1
G> > > > i need perl to evaluate for the results...
G> > > > perl treats this as another string
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                    |||||||
         
G> > > > because of the operators and parenthesis and does
G> > > > not cast the string...
                      ^^^^^^

[ snip ]

See the underlined sections above.

G> No. You boys are blind and see a string. I see no string
G> but rather a standard mathematical expression which Perl
G> evaluates to two, numerical 2. Did you test his expression?
G> Tag a semicolon on the end of his line and run it. His is
G> a mathematical equation, not a string and, he clearly
G> states, with incorrect grammar, "arithmetic expression."

That is a troll, and a bad one, because  both "arithmetic"
and "arithmetical" can serve as an adjective.

G> There are no apostrophes around his 'string' nor are
G> there any quotes around his "string" and, his wording
G> indicates along with his example, both indicate a

[ snip ]

Again, see the underlined parts of the quote above.

G> > By the way, how did you get the following line of 
G> > code from your post to compile?
G>  
G> >     $string = 1 + 1 / 0 + 1 -1;
G> 
G> > Even without warnings and such, I get a fatal compilation error:
G>  
G> >     Illegal division by zero at ...
G> 
G> Easy. Look at this example,
G> 
G> 1 / 0 + 1 = infinity plus one.

Which infinity, positive or negative?  That equals undefined + 1, which
evaluates to undefined.

G> See my previous article for a print out on this
G> line in question. It's there, a clip from what
G> I see for a script crash. Actual message contains
G> more, but what I included says it all.

That is true, but waaaaayyy at the bottom.

G> I ran that line separate from the rest of my lines,
G> and made it appear, I didn't, just for fun. There
G> is a way to compile code and print, using a buffer
G> flush and indirect division by zero, but as soon
G> as this division is attempted, FUBAR. Easier to
G> have your code print division by zero as a string,
G> not a mathematical formula.

Again, we are all alot dumber now for having read that.
Are you trying to set some world record for trolling?

G> See what I mean Mr. Rosler. This example cited by
G> the originating author cannot be printed. It will
G> automatically evaluate, mathematically. You have
G> to 'make' it a string to print which is changing
G> his clearly stated parameters and, clear question,
G> 
G> "How to use parentheses for math?"

You need to reread the OP, this time read for comprehension.

anm
-- 
perl -wMstrict -e '
$a=[[qw[J u s t]],[qw[A n o t h e r]],[qw[P e r l]],[qw[H a c k e r]]];$.++
;$@=$#$a;$$=[reverse sort map$#$_=>@$a]->[$|];for$](--$...$$){for$}($|..$@)
{$$[$]][$}]=$a->[$}][$]]}}$,=$";$\=$/;print map defined()?$_:$,,@$_ for @$;
'



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

Date: Wed, 04 Oct 2000 22:31:27 +0200
From: Thomas <Thomas@Trendsetter.de>
Subject: A little Cookie-Problem!!
Message-Id: <39DB939F.852E2A2C@Trendsetter.de>

Hello,


a response-header shows up following lines after a HTTP-Request:

Set-Cookie: VisID=40198552; path=/;
Set-Cookie: Tango_UserReference=D48908A58044127239DB88AE; path=/

The next http-request so should have a header with 2 cookie-lines!

$cookie_jar->extract_cookies($res) does not work correctly in some cases
(i.e. http://www.egroups.com/message/libwww-perl/6228)
That is why I want to set the correct request-header with the 2 cookies
via $cookie_jar->set() in connection with
$cookie_jar->add_cookie_header($req).

$cookie_jar->set_cookie(undef,              # $version,
       $key,              # $key,
       $val,              # $val,
       '/',                # $path,
       $COOKIE_DOMAIN,    # $domain,
       undef,              # $port,
       0,                  # $path_spec
       0,                  # $secure
       undef,              # $maxage,
       0,                  # $discard,
       {},                # \%rest,
       );


All seems to work correctly because having a look at
$cookie_jar->as_string() shows following expected lines:

Set-Cookie3: VisID=40198552;
Set-Cookie3: Tango_UserReference=D48908A58044127239DB88AE

But - and that is the problem - the produced request- header
$req->as_string() makes clear that only 1 (!)  cookie is considered!!!
 ...
Cookie: Tango_UserReference=D48908A58044127239DB88AE
 ...

The line "Cookie: VisID=40198552" misses!

So the next request only would give 1 cookie back to the server!

Does anybody know why there is only 1 cookie-line in the produced
request-header instead of the expected 2 ???



Thanks a lot

Thomas



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

Date: Wed, 04 Oct 2000 20:48:22 GMT
From: David Steuber <nospam@david-steuber.com>
Subject: Re: A matter of style (was Re: Search and Destroy)
Message-Id: <m3em1wwcx7.fsf@solo.david-steuber.com>

Tom Briles <sariq@texas.net> writes:

' perldoc perlstyle

I hate to ask, but "Uncuddled elses?"

What does cuddling an else look like?

I've been doing this:

if ($foo) {
   ...
} elsif ($bar) {
   ...
} else {
   ...
}

Most everything else makes sense.  I generally indent only 3 though,
not 4.

-- 
David Steuber | Perl apprentice, Apache/mod_perl user,
NRA Member    | and general Internet web wannabe.
ICQ# 91465842
***         http://www.david-steuber.com/          ***


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

Date: Wed, 04 Oct 2000 20:54:26 GMT
From: cfedde@u.i.sl3d.com (Chris Fedde)
Subject: Re: A matter of style (was Re: Search and Destroy)
Message-Id: <6OMC5.125$D4.175586304@news.frii.net>

In article <m3em1wwcx7.fsf@solo.david-steuber.com>,
David Steuber  <nospam@david-steuber.com> wrote:
>
>I hate to ask, but "Uncuddled elses?"
>

Your example is cuddled braces. Uncuddled would replace that space
with a newline.

chris
-- 
    This space intentionally left blank


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

Date: 4 Oct 2000 18:30:41 GMT
From: bmetcalf@nortelnetworks.com (Brandon Metcalf)
Subject: Re: Blank line appending data to file
Message-Id: <8rft0h$fmh$1@bcrkh13.ca.nortel.com>

nige@npay.freeserve.co.uk writes:

 > Thanks Gwyn,
 > Apologies for the format - this should be better?

Except that you're posting jeopardy style.

Brandon


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

Date: Wed, 04 Oct 2000 20:20:07 GMT
From: aramis1250@my-deja.com
Subject: Code example in Cookbook
Message-Id: <8rg3de$i4c$1@nnrp1.deja.com>

I've been reading through the Perl Cookbook, and came across
the following snippit to extract information from apache common
logs:
# BEGIN code snippit
while <LOGFILE> {
 my ($client, $identuser, $authuser, $date, $time, $tz, $method,
$url, $protocol, $status, $bytes) = /^(\S+) (\S+) (\S+)
\[([^:]+):(\d+:\d+:\d) ([^\]]+) "(\S+) (.8?) (\S+)" (\S+) (\S+)$/
# my code here
} # END while logfile
# END code snippit

The problem that I run into is that .... none of the variables in the
first part ever get anything. What did I miss?


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


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

Date: 4 Oct 2000 19:37:41 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: die() ignores tied STDERR?
Message-Id: <8rg0u5$hi7$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Daniel Chetlin
<daniel@chetlin.com>],
who wrote in article <8rev1d02t0n@news2.newsguy.com>:
> >>   [~] $ perl -e'use overload q/""/,sub{"$_[0]"};$r=bless{};print$r'
> >>   Segmentation fault (core dumped)

> >Why so hairy?  This should be more or less equivalent to
> >
> >  perl -we 'sub a {my $x=shift; a($x)} a(1)'
> >
> >If it is not, something is buggy...

> Yes, it is now equivalent to your code. However, I might claim that it
> shouldn't be. I feel that this sort of magic (overloading, tieing, etc.)
> should be cognizant of itself and not allow that kind of recursion.

It *is* cognizant, *this* is why it allows the recursion.  That your
recursion never ends, is not the business of Perl.  (But of course,
you get a warning with -w.)

Ilya



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

Date: Wed, 4 Oct 2000 12:25:30 -0700
From: "N" <g99z44@yahoo.com>
Subject: embedding in HTML
Message-Id: <stn1dnbhms328b@corp.supernews.com>

Is there a way you embed perl script in the html files like PHP's <?php ....
> method besides using SSI's? If it is too complicated an answer I would be
happy with the name of this function (if exists) so I could look it up.

Thanks

N




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

Date: Wed, 04 Oct 2000 16:28:42 -0400
From: Young Chi-Yeung Fan <yf32@cornell.edu>
Subject: Re: embedding in HTML
Message-Id: <39DB92FA.E1B02954@cornell.edu>

ePerl : http://www.engelschall.com/sw/eperl/

N wrote:

> Is there a way you embed perl script in the html files like PHP's <?php ....
> > method besides using SSI's? If it is too complicated an answer I would be
> happy with the name of this function (if exists) so I could look it up.
>
> Thanks
>
> N



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

Date: 4 Oct 2000 21:42:16 GMT
From: trammell@nitz.hep.umn.edu (John J. Trammell)
Subject: ExtUtils::MakeMaker and g+w install permissions
Message-Id: <slrn8tmepk.pcv.trammell@nitz.hep.umn.edu>

Hello all:

I'd like to have Makefile.PL generate a Makefile that installs
files with group-rw permissions.

After reading the documentation, trying some options, cursing,
then looking at the code, I boiled it down to these lines in
ExtUtils::Install, routine pm_to_blib():

   foreach (keys %$fromto) {
      ...
      copy($_,$fromto->{$_});
      my($mode,$atime,$mtime) = (stat)[2,8,9];
      ...
      chmod(0444 | ( $mode & 0111 ? 0111 : 0 ),$fromto->{$_});
   }

Now that I've basked in the glow of Figuring It Out, the problem
remains: how to install these files with the right perms?  Any
ideas?

-- 
John J. Trammell
johntrammell@yahoo.com


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

Date: 04 Oct 2000 13:18:15 -0400
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: force arithmetic interpretation
Message-Id: <uvgv8zfs8.fsf@demog.berkeley.edu>

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

> TEST SCRIPT:
> ____________
> 
> 
> #!/usr/local/bin/perl
> 
> print "Content-Type: text/plain\n\n";
> 
> $string = 1 * 0 + 1 + 1;
> 
> print "String: $string\n";
> 
> $string = 1 / 1 + 0 + 1;
> 
> print "String: $string\n";
> 
> $string = 1 * 1 / 1 + 1;
> 
> print "String: $string\n";
> 
> $string = 1 + 2 / 1 - 1;
> 
> print "String: $string\n";
> 
> $string = (1 + 2) / 2 - 1 + 1.5;
> 
> print "String: $string\n";
> 
> $string = 1 + (6 / 2) - (.5 * 4);
> 
> print "String: $string\n";
> 
> $string = 1 + 1 / 0 + 1 -1;
> 
> print "String: $string\n";
> 
> exit;
> 
> 
> PRINTED RESULTS:
> ________________
> 
> String: 2
> String: 2
> String: 2
> String: 2
> String: 2
> String: 2
> 
> 
>              SCRIPT CRASH!
>          FUBAR! FUBAR! FUBAR! 
>  F[censored]D UP BEYOND ALL RECOGNITION!
>          FUBAR! FUBAR! FUBAR!

What a moron. The OP quite clearly wanted to be able to build a string
containing an expression, then evaluate that built expression - it's
quite obvious that if s/he had the expression literally beforehand
PurlMoron's^H^H^H^H^H^H^H^ MoronZilla's braindead suggestion would
work. 

The answer, of course, is eval(), which other posters have managed to
figure out quite nicely.

-- 
----------------------------------------------------------------------
Andrew Perrin - Solaris-Linux-NT-Samba-Perl-Access-Postgres Consulting
       aperrin@igc.apc.org - http://demog.berkeley.edu/~aperrin
----------------------------------------------------------------------


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

Date: Wed, 04 Oct 2000 18:09:55 GMT
From: post_to_group <already_seen@my-deja.com>
Subject: Forking, Exiting, and Timing out within an Eval
Message-Id: <8rfrpc$b15$1@nnrp1.deja.com>

Hello,

I have written a perl script that copies up a report script to a series
of hosts, runs the script, then copies it back.  Because there are about
40 hosts and the report takes 5 minutes per host, I fork the process.
What I don't include below is the "host_hash" which splits up the array
of hosts into sub-arrays (I am putting that in a separate post just to
see if my method is a good/efficient one but that part *is* working ok).
 With that code-bit I can get X number of sub-arrays into each fork.
However I am having several problems with the forking, both in
understanding how to get forking to work and how to exit properly.

One problem I am having is that the fork is just a section of the
script, neither the beginning nor the end and the stuff that comes
*after* the forked part is getting executed multiple times.   So I have
been placing exits at various key places in the fork trying to figure
out how/why each child also continues down with the rest of the script
and how to avoid that.  Any ideas why the children processes seem to
continue with the rest of the script outside the forked part?  What am I
doing wrong?  The script works pretty well going to each host once, but
then the final parts of the script, which need to be executed locally
like a normal non-forked perl script, get executed multiple times.

One other question/problem I am having is with where the exit's need to
go and what else is it that closes/stops each fork without impacting the
whole script (one exit below, if uncommented, just stops the whole fork,
another kills the whole script).

Additionally I am running either an scp or ssh command (I include only
the ssh command below as they are all very similar).  I am trying to
ensure that I am running the ssh command in the most efficient and
robust way possible.  Using some examples I have gathered I wrapped the
command in an eval.  The problem is that a time-out with one of the
hosts kills the entire fork.  I was trying to kill only the hung ssh/scp
process (e.g. the system is down or on a slow link).  I tried forking
each ssh or scp and then killing the timeout but again it kills the
entire "parent fork" so the subsequent hosts don't get run.  Any ideas
what I am doing wrong? Also is the way I setup the timeouts ok?  The
timeouts for the scp are 60seconds, while I give 3600 for the ssh as the
report takes that time to run.  Naturally any other suggestions or
comments on the stuff you see would be greatly appreciated.

And lastly, I was wondering if it is possible to use exec instead of
system?  I tried exec because there were some good examples using exec,
but then the alarm never happens.


# the "FORK: next" fork/code bit parts are copyright Daniel V. # Klein
1999 - gotten from his web cookbook class, adam

# save off the true standard out for reattaching at the end...
open SAVE_STDOUT, ">&STDOUT";

FORK: foreach $hosthash_counter (sort keys %host_hash)               {

# Parent forks and continues, child does the real work

next FORK if ($pid[$hosthash_counter] = fork);

# open a log file, one per fork
print STDOUT "Hosts to be processed for this child:
@{$host_hash{$hosthash_counter}} \n";

# only child should execute this:
 foreach $hostname (sort @{$host_hash{$hosthash_counter}}) {

@command_list =  qw(SCP-PUT SSH-RUN SCP-GET);
foreach $command_type (@command_list) {

# all steps for each of the 3 command_type's are the same except the
actual command itself, so for that use an if to match

if (!defined($ssh_run_pid{$hostname} = fork())) {
       # fork returned undef, so failed
       print STDOUT "$command_type cannot fork for $hostname: $!\n";
} elsif ( $ssh_run_pid{$hostname} == 0 ) {
       # fork returned 0 so this branch is the child
    $SIG{ALRM} = sub { warn "DAILY-REPORTS-WARNING: sig_alarm called
warn for a timeout of $hostname with message: $@" };
    $SIG{CHLD} = 'IGNORE';
       eval {

if ($command_type eq "SSH-RUN") {    # Posting note: for brevity, I
removed SCP-PUT & GET as they are pretty much the same
        alarm(3600);
        #  would like to get PID to match fork but exec'ing means the
alarm never happens - way around?
	print STDOUT "$command_type now processing $hostname in fork
$ssh_run_pid{$hostname} in fork $hosthash_counter \n";
#        system("/usr/local/bin/ssh $hostname ./$dailyreport ") && die
"$command_type for $hostname failed with exitstatus: $?";
                                   }
                                   }   #   close of eval braces

# end of if to determine command-type and thus execute correct command
in correct sequence
        exit 0;             # I found that an exit here is crucial as it
stops child from repeating over each host multiple times...
        alarm(0);
       };

       if ($@) {
           if ($@ =~ /timeout/) {   # timed out, do what you want here
           print STDOUT "$command_type operation for $hostname timed out
with error message:  $@ - now killing the proccess
$ssh_run_pid{$hostname}\n";
# this kills the entire fork so any remaining hosts of this particular
fork are skipped!
          system("kill $ssh_run_pid{$hostname}");
           next;
	   exit 0;             # NOT SURE if exit is needed or a good
idea here...
           } else {
           alarm(0);             # clear the still-pending alarm
#	   warn "DAILY-REPORTS-WARNING: operation for $hostname timed
out\n";
	   exit 0;             # NOT SURE if exit is crucial as it stops
child from repeating over each host multiple times...
           }
       }
exit 0;      # I THINK this closes this fork - not sure....
}
else {
# fork returned neither 0 nor undefined so this branch is the parent
      waitpid ( $ssh_run_pid{$hostname}, 0);
      print "I was the parent with ssh_run_pid of
$ssh_run_pid{$hostname} \n";
#      exit 0;    # not sure an exit here is a good thing or not... it
seems to kill the entire script
}

            }    # this closed the foreach $command_type loop


                                                        } # close
foreach $hostname ($sort... loop
	exit 0;                                           # exit is
crucial as it stops child from repeating over each host multiple
times...
                                                        } # close of the
FORK: foreach $hosthash_counter outer loop

# Housekeeping:  wait until children exit before going onto rest of
script:
until (($status = wait) == -1) {
      sleep 1;
      print "Child with PID $status is finished and exited\n";
#      exit 0;
}   # close of until


# once the forks are all done do the following

# fork should now be completely done


# COMMANDS FROM HERE DOWN GET EXECUTED MULTIPLE TIMES!  NOT SURE WHY IT
ISN'T ONLY THE PARENT EXECUTING THEM


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


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

Date: Wed, 04 Oct 2000 21:33:23 GMT
From: hajir@my-deja.com
Subject: help in finding info on perl
Message-Id: <8rg7n3$lv5$1@nnrp1.deja.com>

I need some help in finding some perl code.

I have basically creating a perl script that will open oracle
plus80.exe in DOS and run some queries, spooled to a file, for a weekly
date range - and then i need to pull the data out of the output text
file and put it into an excel sheet in specific cells.

Where can I find example on how to open MS Excel and put data out of a
text file into the excel sheet's cells?


thanks




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


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

Date: Wed, 04 Oct 2000 14:44:56 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: help in finding info on perl
Message-Id: <39DBA4D8.4A92B390@vpservices.com>

hajir@my-deja.com wrote:
> 
> I need some help in finding some perl code.
> 
> I have basically creating a perl script that will open oracle
> plus80.exe in DOS and run some queries, spooled to a file, for a weekly
> date range - and then i need to pull the data out of the output text
> file and put it into an excel sheet in specific cells.
> 
> Where can I find example on how to open MS Excel and put data out of a
> text file into the excel sheet's cells?

If you create the text file as a CSV (comma separated values) file, you
don't need to do anything extra, Excel will read the file and create a
spreadsheet from it.

If you are not already creating a CSV file and you are using DBI to
access Oracle anyway, you can use DBD::RAM to both pull the data out of
Oracle and create the CSV file.

Otherwise you could look into the Spreadsheet::WriteExcel module on
CPAN.

-- 
Jeff


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

Date: Wed, 04 Oct 2000 18:46:16 GMT
From: stdenton@my-deja.com
Subject: Re: Help with CGI
Message-Id: <8rfttl$d60$1@nnrp1.deja.com>

In article <39DB696C.3A1AED8D@pilot.msu.edu>,
  Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu> wrote:
> I have a cgi script written in perl used for a feedback form on a web
> page.  When you click on the submit button it sends an e-mail and then
> tries to print html back to the browser to display a "temporary" web
> page thanking the user, and then eventually I am going to add some
html
> to re-direct the web page back to the original. Anyways, the problem
is
> encountered when it tries to print the html back to the web browser,
it
> gets through the e-mail section, sends the e-mail but when it hits the
> first print statement for the html it asks to open the file or save it
> to disk (I'm using netscape on this one, it works in I.E, but the
users
> don't want to switch so I'm stuck making it work for netscape).  And
> when you choose Open it, it displays the html printed into my default
> text editor.  And only the html.  if you could take a look and see if
I
> am doing something wrong that would be much appreciated.  Oh, we are
> running perl 5.0 on an NT system.  Thanks

Well, for starters don't "do cgi-lib.pl", instead "use CGI;"

Next, you're asking a CGI question in a newsgroup devoted to the Perl
language.  Try posting somewhere that people will care.

Lastly, your code looks OK at first glance, but I'm not going to wade
through it.  Does it work if you don't send the e-mail?  Try to reduce
it down to a minimal subset of code that fails before asking again.


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


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

Date: Wed, 4 Oct 2000 12:42:42 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: help: FORCE perl to evaluate arithmetic string
Message-Id: <MPG.14452809988b803898ae05@nntp.hpl.hp.com>

In article <39DB592D.BD07306F@stomp.stomp.tokyo> on Wed, 04 Oct 2000 
09:22:05 -0700, Godzilla! <godzilla@stomp.stomp.tokyo> says...
> Larry Rosler wrote:
>  
> > In article <39DA6C18.5154D3B1@stomp.stomp.tokyo>,
> > godzilla@stomp.stomp.tokyo says...
> > > ruzbehgonda@my-deja.com wrote:
> 
> > > > after building an arithmetic expression dynamically
                                                ^^^^^^^^^^^
Interpretation:  At execution time, not at compile time.

> > > > eg. $arith = ( (1 * 0) + 1) + 1
> > > > i need perl to evaluate for the results...
> > > > perl treats this as another string
                                    ^^^^^^
> > > > because of the operators and parenthesis and does
> > > > not cast the string...
                     ^^^^^^
> > > > how can i do this?

See also the Subject: "help: FORCE perl to evaluate arithmetic string"

Beyond the slightest doubt, the poster omitted to include the string 
delimiters in his example.

> > > I have read some articles within this thread,
> > > with humored interest. I also posted a clear
> > > answer. Still, I am most curious. Why would
> > > you "force" perl core to evaluate a mathematical
> > > expression which is self-evaluating?

Because none of the rest of us choose to waste our time on compile-time 
constant expressions, which are trivial.

> > > "Arithmetical" expressions automatically evaluate.

And therefore are of little interest, and are not what the question 
related to.

> > As usual, you are dealing with a different problem from everyone else.
> > Your code shows constant arithmetic expressions, which are evaluated
> > when the program is compiled.  Everyone else is dealing with strings,
> > which must be evaluated at run time.
> 
> No. You boys are blind and see a string.

Because we know how to read and how to interpret what we read to be 
meaningful and useful, instead of trivial.

 ...

> By the way, how did you get the following line of 
> > code from your post to compile?
>  
> >     $string = 1 + 1 / 0 + 1 -1;

 ...

> I ran that line separate from the rest of my lines,
> and made it appear, I didn't, just for fun.

Is it 'fun' to post a complete program and its purported output, when 
the program doesn't compile?

 ...

> See what I mean Mr. Rosler. This example cited by
> the originating author cannot be printed. It will
> automatically evaluate, mathematically. You have
> to 'make' it a string to print which is changing
> his clearly stated parameters and, clear question,
> 
> "How to use parentheses for math?"

Nonsense.  His question was, in essence, why Perl can deal with the 
following statement 'correctly' (i.e., automatic conversion to number, 
in accordance with DWIM principles):

    $arith = '1';

But it cannot deal with this statement 'correctly':

    $arith = '(1)';

And what should be done about it?

So he learned the answer, which is 'eval', from the responses to the 
thread other then yours, which chose to deal with triviality.

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


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

Date: Wed, 04 Oct 2000 14:35:18 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: help: FORCE perl to evaluate arithmetic string
Message-Id: <39DBA296.75737914@stomp.stomp.tokyo>

Larry Rosler wrote:
 
> Godzilla! wrote:
> > Larry Rosler wrote:
> > > Godzilla! wrote:
> > > > ruzbehgonda wrote:

(snippage)

> Beyond the slightest doubt, the poster omitted to include
> the string delimiters in his example.

Possibly deliberately, Mr. Rosler?
A rhetorical question begging no
answer, of course.

=) <-- I am smiling at you sincerely. Don't wig on me.


Kira


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

Date: Wed, 4 Oct 2000 19:22:57 +0100
From: "Kingsley Tart" <kingsley@skymarket.get.co.rid..uk>
Subject: how do I set server socket timeouts with setsockopt?
Message-Id: <XAKC5.13259$L12.260296@news2-win.server.ntlworld.com>

I'm creating a server program in Perl and, as well as setting
the socket option below, I want to be able to have a read
timeout of 30 minutes. I can't find in any of my Perl books
how to do this. Any clues?

This is what I have at the moment:

setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l", 1))

Cheers,
KDT.




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

Date: Wed, 04 Oct 2000 19:16:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how do I set server socket timeouts with setsockopt?
Message-Id: <nc0ntsgv9oqk6k7gkkll20r6g623hom63c@4ax.com>

Kingsley Tart wrote:

>I'm creating a server program in Perl and, as well as setting
>the socket option below, I want to be able to have a read
>timeout of 30 minutes. I can't find in any of my Perl books
>how to do this. Any clues?

    $SIG{ALRM} = sub { die "alarm\n" };
    alarm(1800);

See the code in the perlfunc entry for alarm(), if you don't want the
script to die.

-- 
	Bart.


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

Date: Wed, 4 Oct 2000 16:22:31 -0400
From: "JP" <pangjo@hotmail.com>
Subject: How to find IP address by MAC address?
Message-Id: <vkMC5.45$l51.534@client>

I am writing a Perl script which will check device status using SNMP
functions.  Since the IP addresses of the devices are dynamic, I would like
to write the script based on the MAC or physical addresses.

Can anyone tell me how I can convert an MAC address to IP using Perl?

Thank you very much in advance.

Joe




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

Date: Wed, 4 Oct 2000 20:38:18 +0100
From: "Nick Mallinson" <mailing@_sussex_-_internet.co._uk>
Subject: HTML Email
Message-Id: <8rg0vp$jrc$1@news8.svr.pol.co.uk>

Hi Can anyone help, I have written a script to email the contents of a form,
(a V simple formmail.

I would like to be able to send the email in an HTML format. The email will
go to an Outlook express mail client.  I have tried, using the contents of
outlook's source code but it is just read as plain text and all you get is
the HTML source.

Does anyone know how to format this so my perl script can send a wizzy
email?

Many thanks

Nick




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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4521
**************************************


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