[18737] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 905 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 15 14:06:29 2001

Date: Tue, 15 May 2001 11:05:21 -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: <989949920-v10-i905@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 15 May 2001     Volume: 10 Number: 905

Today's topics:
        Addition <Tim.Lauterborn@gmx.de>
    Re: Addition <a.v.a@home.nl>
    Re: Addition <a.v.a@home.nl>
    Re: AND-connected search nobull@mail.com
        ANNOUNCE: Data::Denter 0.13 <ingy@ActiveState.com>
        assigning a subroutine to a variable <ayeretsk@arm.com>
    Re: assigning a subroutine to a variable (Anno Siegel)
    Re: assigning a subroutine to a variable <ayeretsk@arm.com>
    Re: assigning a subroutine to a variable <a.v.a@home.nl>
    Re: assigning a subroutine to a variable (Anno Siegel)
    Re: Benefits of "strict" and "-w"? <feldspar@ix.netcom.com>
    Re: Cannot install perl-5.6.1: problem in "make test" (Georg Wittig)
        EmbPerl Problem <djm@spamfree.mcoe.k12.ca.us>
    Re: Emptying all variables in script <somewhere@in.paradise.net>
    Re: garbage collection in perl (Anno Siegel)
    Re: garbage collection in perl (M.J.T. Guy)
    Re: garbage collection in perl <feldspar@ix.netcom.com>
    Re: garbage collection in perl (Anno Siegel)
        Help with Ping Script <mlaw@talk21.comNOSPAM>
    Re: Help with Ping Script <a.v.a@home.nl>
    Re: Help with Ping Script <brian@stevens.com>
    Re: Help with Ping Script <mlaw@talk21.comNOSPAM>
    Re: How to call a 3rd-party DLL from perl script? <hillr@ugs.com>
    Re: How to call a 3rd-party DLL from perl script? <Jenda@Krynicky.cz>
        How to check validity of a credit card? (Lars)
    Re: How to check validity of a credit card? <hartleh1@westat.com>
    Re: How to check validity of a credit card? (Anno Siegel)
    Re: How to check validity of a credit card? <a.v.a@home.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 15 May 2001 18:33:17 +0200
From: "Tim Lauterborn" <Tim.Lauterborn@gmx.de>
Subject: Addition
Message-Id: <9drloi$b4l$1@nets3.rz.RWTH-Aachen.DE>

Hi,

in addition to the text above this is the program I used:

  binmode(STDOUT);
  print "Content-type: audio/wav\n\n";
  open(FILE, "../templates/test.wav");
  binmode(FILE);
  while ($temporary = <FILE>) {
    $output_line .= $temporary;
  }
  close(FILE);
  print $output_line;

Greetings,
Tim




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

Date: Tue, 15 May 2001 17:19:20 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: Addition
Message-Id: <3B013D2A.17770BEB@home.nl>

Tim Lauterborn wrote:

> Hi,
>
> in addition to the text above this is the program I used:
>
>   binmode(STDOUT);
>   print "Content-type: audio/wav\n\n";
>   open(FILE, "../templates/test.wav");
>   binmode(FILE);
>   while ($temporary = <FILE>) {
>     $output_line .= $temporary;
>   }
>   close(FILE);
>   print $output_line;
>
> Greetings,
> Tim

im not sure what it is you are trying to do, but if you are trying to
play a wav file in a webpage then u should use <embed> (for NS) and
<src> (for IE).



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

Date: Tue, 15 May 2001 17:31:02 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: Addition
Message-Id: <3B013FE8.8A1AF257@home.nl>

AvA wrote:

> Tim Lauterborn wrote:
>
> > Hi,
> >
> > in addition to the text above this is the program I used:
> >
> >   binmode(STDOUT);
> >   print "Content-type: audio/wav\n\n";
> >   open(FILE, "../templates/test.wav");
> >   binmode(FILE);
> >   while ($temporary = <FILE>) {
> >     $output_line .= $temporary;
> >   }
> >   close(FILE);
> >   print $output_line;
> >
> > Greetings,
> > Tim
>
> im not sure what it is you are trying to do, but if you are trying to
> play a wav file in a webpage then u should use <embed> (for NS) and
> <src> (for IE).

make the last one for IE <bgsound>



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

Date: 15 May 2001 18:09:09 +0100
From: nobull@mail.com
Subject: Re: AND-connected search
Message-Id: <u9eltq5ykq.fsf@wcl-l.bham.ac.uk>

Bart Lateur <bart.lateur@skynet.be> writes:

> I gather that you want tocreate such a search on the fly, from user
> data. eval to the rescue!
> 
> 	$searchsub = eval 'sub { ' .
> 	    join('  && ', map "/$_/", @searchterm) .
> 	    '};';

This is exceptionlly dangerous code.

> You'll have to take care of properly handling special characters in the
> searchterms.

That is an understatement.

> For example, for literal searches, you can use "/\Q$_/" for
> the map expression.

You mean "/\Q$_\E/".

If you want to allow @searchterm to be a list of user supplied regular
expressions then extreem caution is required to 

A good start would be to use qr// to canonicalise the pattern (avoid
any embebed Perl code (assuming you have taint checking on)) and use
"m'$_'" rather than "m/$_/" to avoid variable interpolation in the
eval.  Obviously you'll also need to escape any single quotes in the
patterb to avoid premature terminataion of the pattern.

for (@searchterm) { $_=qr/$_/; s!'!\\'!g; $_="m'$_'"; }
$searchsub = eval 'sub{' . join('&&',@searchterm) . '}';

AFAIK the above is secure, but to be doubly secure I'd also use Safe
module so that the user supplied code that somehow does get past the
above is evaluated in it's own private sandbox and prohibited from
performing any filesystem actions.

use Safe;
my $safe = Safe->new;
for (@searchterm) { $_=qr/$_/; s!'!\\'!g; $_="m'$_'"; }
$searchsub = $safe->reval('sub{' . join('&&',@searchterm) . '}');


-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 15 May 2001 10:07:37 GMT
From: Brian Ingerson <ingy@ActiveState.com>
Subject: ANNOUNCE: Data::Denter 0.13
Message-Id: <tg2c8cps457d56@corp.supernews.com>

Data::Denter - An alternative to Data::Dumper and Storable.

INTRODUCTION:

Data::Denter is yet another Perl data serializer/deserializer. It
formats nested data structures in an indented fashion. It is optimized
for human readability/editability, safe deserialization, and
(eventually) speed.

NOTE: It may be optimized for Python programmers too, but please don't
hold that against me ;)

It exports 2 functions: Indent() and Undent() for serialization and
deserialization respectively. It handles all of the commonly
serializable Perl data types, including: scalars, hash refs, array
refs, scalar refs, ref refs, undef, and blessed references. It can
even properly handle circular and duplicate references.

SAMPLE:

     use Data::Denter;
     print Indent bless {foo => 42,
                         bar => [ 'happy', undef, [], 'sad' ],
                         baz => "Bozo the Clown",
                        }, "Small::Example";

yields:

     %Small::Example
         bar => @
             happy
             ?
             @
             sad
         baz => Bozo the Clown
         foo => 42

CHANGES:

(Version 0.13)
- Fixed scalar context bug in Undent.

(Version 0.12)
- URI style escaping for binary data.
- Hash keys are sorted by default for the Indent()
function. Controlled by the "Sort" option.
- Added "HashMode" option for creating quick and easy config files.
- Added "MaxLines" option for limiting the output of very long string
values.
- Fixed bug. Now works with 5.7.0+.

INFORMATION:

For more information on Data::Denter, see 'perldoc Data::Denter'.

Please send questions and comments to "Brian Ingerson" <INGY@cpan.org>

Copyright (c) 2001, Brian Ingerson. All Rights Reserved.




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

Date: Tue, 15 May 2001 11:28:51 -0500
From: Andrew Yeretsky <ayeretsk@arm.com>
Subject: assigning a subroutine to a variable
Message-Id: <3B015943.4E1695F6@arm.com>

I have a subroutine that generates a random number.  I assigned the
subroutine to a variable, however, everytime I use the variable it
generates a new random number.  How do I keep the variable as the first
random number throughout the program.



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

Date: 15 May 2001 16:37:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: assigning a subroutine to a variable
Message-Id: <9drlvm$ceu$5@mamenchi.zrz.TU-Berlin.DE>

According to Andrew Yeretsky  <ayeretsk@arm.com>:
> I have a subroutine that generates a random number.  I assigned the
> subroutine to a variable, however, everytime I use the variable it
> generates a new random number.  How do I keep the variable as the first
> random number throughout the program.

You are obviously doing something unusual (if not cruel), when you
"assign(ed) the subroutine to a variable".  Please show what you are
doing there, and also how you use the variable later.

Anno


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

Date: Tue, 15 May 2001 11:47:14 -0500
From: Andrew Yeretsky <ayeretsk@arm.com>
Subject: Re: assigning a subroutine to a variable
Message-Id: <3B015D92.9C528D1B@arm.com>

Anno Siegel wrote:

> According to Andrew Yeretsky  <ayeretsk@arm.com>:
> > I have a subroutine that generates a random number.  I assigned the
> > subroutine to a variable, however, everytime I use the variable it
> > generates a new random number.  How do I keep the variable as the first
> > random number throughout the program.
>
> You are obviously doing something unusual (if not cruel), when you
> "assign(ed) the subroutine to a variable".  Please show what you are
> doing there, and also how you use the variable later.
>
> Anno

I guess I didn't phrase that very well.  I am calling the subroutine and
assigning its return value to a variable. Is there a way to keep $firstcard
constant throughout the program?:


my $firstcard = &GetCard();

sub GetCard {
  %dist = &weight_to_dist(%weights);
  $card = &weighted_rand(%dist);
  return $card;
}





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

Date: Tue, 15 May 2001 16:59:49 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: assigning a subroutine to a variable
Message-Id: <3B013896.492A9A13@home.nl>

Andrew Yeretsky wrote:

> Anno Siegel wrote:
>
> > According to Andrew Yeretsky  <ayeretsk@arm.com>:
> > > I have a subroutine that generates a random number.  I assigned the
> > > subroutine to a variable, however, everytime I use the variable it
> > > generates a new random number.  How do I keep the variable as the first
> > > random number throughout the program.
> >
> > You are obviously doing something unusual (if not cruel), when you
> > "assign(ed) the subroutine to a variable".  Please show what you are
> > doing there, and also how you use the variable later.
> >
> > Anno
>
> I guess I didn't phrase that very well.  I am calling the subroutine and
> assigning its return value to a variable. Is there a way to keep $firstcard
> constant throughout the program?:
>
> my $firstcard = &GetCard();
>
> sub GetCard {
>   %dist = &weight_to_dist(%weights);
>   $card = &weighted_rand(%dist);
>   return $card;
> }

unless $firstcard {
my $firstcard = &GetCard();
}



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

Date: 15 May 2001 17:31:39 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: assigning a subroutine to a variable
Message-Id: <9drp5r$i65$4@mamenchi.zrz.TU-Berlin.DE>

According to Andrew Yeretsky  <ayeretsk@arm.com>:
> Anno Siegel wrote:
> 
> > According to Andrew Yeretsky  <ayeretsk@arm.com>:
> > > I have a subroutine that generates a random number.  I assigned the
> > > subroutine to a variable, however, everytime I use the variable it
> > > generates a new random number.  How do I keep the variable as the first
> > > random number throughout the program.
> >
> > You are obviously doing something unusual (if not cruel), when you
> > "assign(ed) the subroutine to a variable".  Please show what you are
> > doing there, and also how you use the variable later.
> >
> > Anno
> 
> I guess I didn't phrase that very well.  I am calling the subroutine and
> assigning its return value to a variable. Is there a way to keep $firstcard
> constant throughout the program?:
> 
> 
> my $firstcard = &GetCard();
> 
> sub GetCard {
>   %dist = &weight_to_dist(%weights);
>   $card = &weighted_rand(%dist);
>   return $card;
> }

Why yes.  Don't assign to it again.  If "my $firstcard = &GetCard();"
happens in a loop, put it before the loop.  Whenever you use $firstcard
later in the program, as in 'print "$firstcard\n"', it will have the
same value[1].

Anno

[1] Well, $firstcard could be tied, but somehow I doubt that's the
    problem.


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

Date: Tue, 15 May 2001 12:32:58 -0300
From: Antaeus Feldspar <feldspar@ix.netcom.com>
Subject: Re: Benefits of "strict" and "-w"?
Message-Id: <3B014C2A.3DA24964@ix.netcom.com>

xris wrote:
> 
> I know this is probably in the faq somewhere, but I don't know where to
> start looking, so I'm asking here (my teachers always told me to ask
> questions, no matter how stupid they sounded).
> 
> I've been messing with perl for years, but as I've had no formal
> training, and Larry Wall's perl book doesn't stress either of these
> options (let alone give me enough info to even know what they REALLY
> do), I never bothered using them.  Since I've decided that my coding
> abilities have finally matured enough that I really should start using
> these, I'm wondering what the advantages are.  Is compilation/execution
> faster?  More reliable?
> 
> Thanks,
> 
> Chris

By default, Perl will let you get away with a lot of things that
seriously indicate that you may not know what you're doing or that
you're being sloppy.

"use strict" and "-w" will complain about these practices.

It may sound paradoxical, that so many people swear by something that
actually cuts down on Perl's famed flexibility -- but as anyone who's
ever tried pushing a rope understands, flexibility is often the last
thing you want.*

"use strict" and "-w" are good for everyone to use because anyone can
mistype a variable name -- and having Perl point out in two seconds that
this "$playerrs" variable is not the same as the "$players" variable
that you actually declared and initialized earlier, rather than spending
a half-hour debugging to spot that mistype, is a Good Thing.

It's particularly good for those still learning, because people often
learn by doing.  Let people get away with doing it wrong -- and they
learn to do it wrong. **

	-jc

* This principle also applies on wedding nights.

** Everyone's got a horror story about this.  My favorite comes from a
friend, whose boss had "rm -rf" set to a macro on his keyboard, because
that was the command he'd been shown for clearing out his old e-mail. 
And he wondered why my friend didn't want to give him the root password
to the entire company's networks...


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

Date: 15 May 2001 13:45:05 GMT
From: Georg.Wittig@gmd.de (Georg Wittig)
Subject: Re: Cannot install perl-5.6.1: problem in "make test"
Message-Id: <9drbt1$kaq$1@hop.gmd.de>

mjtg@cus.cam.ac.uk (M.J.T. Guy) writes:

>a)   Before each experiment, did you do "make distclean"?
>     Or alternatively start with a new source tree?
>     You can get all sorts of wierd effects from the remains of
>     previous failed builds.
>
>b)   Does a vanilla config work?    I.e.
>
>	make distclean
>	./Configure -des
>	make test
>	[ Dont do "make install here ! ]


Thanks for your hints. "make distclean" was one of the few things I
didn't think of. Interestingly, your advice b) works pretty well. But
as soon as I insert a "cp ../5.6.0/Policy.sh ." before the ./Configure
line, "make test" will blow up. Hmm...

So I ended up in "make distclean; ./Configure" and answered all those
questions by hand. Afterwards, "make" and "make test" were happy. :-)


-- 
	Georg Wittig, GMD			Georg.Wittig@gmd.de
Urteile über niemanden, bevor du nicht mindestens 3 Meilen in seinen
Schuhen gelaufen bist: 1. bist du dann 3 Meilen weg und 2. hast du
seine Schuhe.


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

Date: Tue, 15 May 2001 16:13:27 GMT
From: "Dave" <djm@spamfree.mcoe.k12.ca.us>
Subject: EmbPerl Problem
Message-Id: <HAcM6.144$Jk3.7113@typhoon.sonic.net>

I went to the homesite of EmbPerl http://perl.apache.org/embperl/
Trying to discover how I can put perl code into my HTML documents.

After clicking on the link to "full documentation", the runtime modes MAKE
NO MENTION OF HOW
to run perl in HTML DOCUMENTS.  (an html document is filename.html or
filename.shtml)

The listed "runtime" modes include the mod_perl mode, which gives an example
of how to run
a given document as a CGI script..  WIth its own custom directory. Far be it
from me to be critical, but this is nothing more then a far fetched and
alternative CGI method!

You can put PHP in standard documents, you dont "run" these docuemnts,
mod_php just reads each
document and runs the php code it finds. This is what I want for Perl,
except either the documentation of EmbPerl doesnt make this clear, or it
just simply is impossible to do right now with EmbPerl.

Is there anyone out there in the world who is already doing what I'm trying
to do with Perl?  Are you able to have your .html files processed without
renaming them to .epl and tossing them into their own custom directory?

-Dave





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

Date: Tue, 15 May 2001 23:07:51 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Emptying all variables in script
Message-Id: <yS9M6.70$Pa4.788509@news.interact.net.au>


"News" <neo@accesscable.net> wrote in message
news:Xn0M6.238165$Z2.2589256@nnrp1.uunet.ca...
> I need to know if there is a way to empty all your variables in a perl
> script at once instead of:
>
> $variable1 = "";
> $variable2 = "";
> $variable3 = "";
>
> This is because I require another script later in the program except the
> script that I require conflicts with some of the variables.  Instead of
> emptying them one by one as above I'd like to clear all variables in my
> script at once if that is possible.

You're asking the wrong question to the problem.  It's a case of "how do I
prevent variable name conflicts".

You need to read up on variable scoping and packages.  Also, I have a
suspicion that you are not making use of arrays or hashes (just using my
ESP::PSI module).




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

Date: 15 May 2001 14:05:12 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: garbage collection in perl
Message-Id: <9drd2o$9ds$1@mamenchi.zrz.TU-Berlin.DE>

According to Ilya Zakharevich  <ilya@math.ohio-state.edu>:
> [A complimentary Cc of this posting was sent to
> Anno Siegel
> <anno4000@lublin.zrz.tu-berlin.de>], who wrote in article
> <9dpi4p$fu4$4@mamenchi.zrz.TU-Berlin.DE>:
> > > The value of that variable *will* persist until the next access (most
> > > often by my(), which undef()s the previous value) unless this value is
> > > an object reference.
> > 
> > I'm not sure I understand.  In which way is an object reference treated
> > differently from other scalars?  Is it not reset by my()?  Or is it not
> > retained until the next access?  I can't seem to find a code example
> > that supports either reading.
> 
> This is a correct search result.  I write it differently below.
> 
>   a1) *Nothing* is done to a lexical variable "when it goes from scope".
>       (HEURISTIC: Going out from scope is a "time-related issue").  
> 
>   a2) Exception: if the variable contains an object reference, the
>       variable is undef()ed on exit.
> 
>   b)  Runtime-effect of my() is the same as of undef().

Ah, I get it.  So the undef()ing (a2) happens immediately before
a variable enters the limbo of un-collected memory, where it is
outside the reach of a mortal programmer.  Presumably this is done
to trigger a possible DESTROY method in an orderly fashion.

Anno


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

Date: 15 May 2001 15:25:49 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: garbage collection in perl
Message-Id: <9drhpt$a26$1@pegasus.csx.cam.ac.uk>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>
>Ah, I get it.  So the undef()ing (a2) happens immediately before
>a variable enters the limbo of un-collected memory, where it is
>outside the reach of a mortal programmer.  Presumably this is done
>to trigger a possible DESTROY method in an orderly fashion.

Yes  -  that's exactly right.    The default behaviour is to leave
a lexical unchanged  -  the assumption is that similar memory will be
needed for it next time round, so a deallocate and allocate can be
saved in the ordinary case.    But of course, an object must be freed
to get DESTROY called in a timely manner.


Mike Guy


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

Date: Tue, 15 May 2001 12:38:25 -0300
From: Antaeus Feldspar <feldspar@ix.netcom.com>
Subject: Re: garbage collection in perl
Message-Id: <3B014D71.EEE3F199@ix.netcom.com>

Anno Siegel wrote:
> 
> According to carlos <carlos@plant.student.utwente.nl>:
> 
> > is a 'my' variable automagically undeffed when it falls out of scope?
> 
> What happens with a variable after is goes out of scope[1] is rather
> a metaphysical question for a programmer.  All we need to know is that
> its contents can be garbage-collected, as the documentation says.
> 
> Anno
> 
> [1] ...meaning, the refcount goes to zero

Not at all.  Some of us would like to use Perl for applications that
operate on large amounts of data.  Only knowing that a variable is
"metaphysically" gone, NOT knowing whether it is still holding on to
memory, is of practical and not just philosophical concern.

	-jc


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

Date: 15 May 2001 17:09:10 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: garbage collection in perl
Message-Id: <9drnrm$i65$2@mamenchi.zrz.TU-Berlin.DE>

According to Antaeus Feldspar  <feldspar@cryogen.com>:
> Anno Siegel wrote:
> > 
> > According to carlos <carlos@plant.student.utwente.nl>:
> > 
> > > is a 'my' variable automagically undeffed when it falls out of scope?
> > 
> > What happens with a variable after is goes out of scope[1] is rather
> > a metaphysical question for a programmer.  All we need to know is that
> > its contents can be garbage-collected, as the documentation says.
> > 
> > Anno
> > 
> > [1] ...meaning, the refcount goes to zero
> 
> Not at all.  Some of us would like to use Perl for applications that
> operate on large amounts of data.  Only knowing that a variable is
> "metaphysically" gone, NOT knowing whether it is still holding on to
> memory, is of practical and not just philosophical concern.

This concern is take care of by the fact that it is collectible.  Its
space will be used when memory is needed.

Another question is whether freed memory can be used by other processes.
In that case it may make sense to explicitly undef large variables,
but most Unixes don't do that.  In any case, that's not under Perl's
control.

Anno


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

Date: Tue, 15 May 2001 16:13:32 +0100
From: "Matt L." <mlaw@talk21.comNOSPAM>
Subject: Help with Ping Script
Message-Id: <wCbM6.3152$Yh2.69758@NewsReader>

Hi!

I have an interesting problem that might be a good project for a perl
script.  When I connect to my ISP (which I pay a monthly subscription to) I
am automatically disconnected after 5mins of inactivity.  This is just a
little too short and is causing me to constantly redial when I am reading
long pages or tutorials.
What I would like to do is run a perl script when I first connect that pings
an external IP (or goes through a list of IP addresses) every 3 minutes.  I
don't know how to do timed events in perl or how to ping from a script (I'm
a newbie).  If anyone could share these two scraps of information with me I
would be most grateful.  I'm working on a Linux kernel 2.4 distro.

Many thanks,

Matt.






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

Date: Tue, 15 May 2001 15:11:32 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: Help with Ping Script
Message-Id: <3B011F36.99D8E05E@home.nl>

"Matt L." wrote:

> Hi!
>
> I have an interesting problem that might be a good project for a perl
> script.  When I connect to my ISP (which I pay a monthly subscription to) I
> am automatically disconnected after 5mins of inactivity.  This is just a
> little too short and is causing me to constantly redial when I am reading
> long pages or tutorials.
> What I would like to do is run a perl script when I first connect that pings
> an external IP (or goes through a list of IP addresses) every 3 minutes.  I
> don't know how to do timed events in perl or how to ping from a script (I'm
> a newbie).  If anyone could share these two scraps of information with me I
> would be most grateful.  I'm working on a Linux kernel 2.4 distro.
>
> Many thanks,
>
> Matt.

why not use cron?
assuming u have unix/linux.



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

Date: Tue, 15 May 2001 09:18:19 -0600
From: Brian Stevens <brian@stevens.com>
Subject: Re: Help with Ping Script
Message-Id: <3B0148BB.AE5E7E2A@stevens.com>

Don't get me wrong - I love Perl, but it's way overkill here.
Since you're running linux, from the command line somewhere,
just do "ping -i 60 {IP}"  That'll ping every 60 seconds...

Brian

"Matt L." wrote:
> 
> Hi!
> 
> I have an interesting problem that might be a good project for a perl
> script.  When I connect to my ISP (which I pay a monthly subscription to) I
> am automatically disconnected after 5mins of inactivity.  This is just a
> little too short and is causing me to constantly redial when I am reading
> long pages or tutorials.
> What I would like to do is run a perl script when I first connect that pings
> an external IP (or goes through a list of IP addresses) every 3 minutes.  I
> don't know how to do timed events in perl or how to ping from a script (I'm
> a newbie).  If anyone could share these two scraps of information with me I
> would be most grateful.  I'm working on a Linux kernel 2.4 distro.
> 
> Many thanks,
> 
> Matt.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Brian Stevens                 STEVENS.COM, Inc.
  brian@stevens.com                 (303)638-1366
        Systems Administration Consultant
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: Tue, 15 May 2001 16:38:32 +0100
From: "Matt L." <mlaw@talk21.comNOSPAM>
Subject: Re: Help with Ping Script
Message-Id: <YZbM6.3158$Yh2.70370@NewsReader>

Thanks!

I didn't know it was that easy!

Matt.




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

Date: Tue, 15 May 2001 06:20:50 -0700
From: Ron Hill <hillr@ugs.com>
Subject: Re: How to call a 3rd-party DLL from perl script?
Message-Id: <3B012D32.26CBD24A@ugs.com>

Christopher Mooney wrote:
> The obvious disadvantage to this is that I must start a background
> instance of Excel, thus degrading system performance and requiring
> Excel be installed on the machine. I have been coding production Perl
> scripts at work for a while now, and would love to replace this Excel
> call with one from a Perl script (if it's doable of course).
> 
> Anyone else had luck with this kind of problem?
> 
you might want to look at Win32::API

With this module you can import and call arbitrary functions from
Win32's Dynamic Link Libraries (DLL)

Ron


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

Date: Tue, 15 May 2001 16:02:10 GMT
From: Jenda Krynicky <Jenda@Krynicky.cz>
Subject: Re: How to call a 3rd-party DLL from perl script?
Message-Id: <1104_989942530@JENDA>

On Tue, 15 May 2001 03:24:57 GMT, cjmoone@yahoo.com (Christopher Mooney) wrote:
> I am currently toward the end of the first phase of a project I am
> coding in VB6 with an Access Database and using a background Excel
> instance to fill a spreadsheet record with 100+ inputs, which then
> makes a call to a third-party DLL designed to be called from Excel. I
> then sniff out the output and store it in the database along with
> other values.  I have tried several unsucessful options to call this
> DLL from VB, but to no avail (including suggestions from other native
> USENET VB programmers). ARGGGGGHHH!
> 
> The obvious disadvantage to this is that I must start a background
> instance of Excel, thus degrading system performance and requiring
> Excel be installed on the machine. I have been coding production Perl
> scripts at work for a while now, and would love to replace this Excel
> call with one from a Perl script (if it's doable of course). 
> 
> Anyone else had luck with this kind of problem?
> 
> Thanks in advance :)

And how do you call the DLL from Excel? Could you show us a snipet of code?

Jenda




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

Date: Tue, 15 May 2001 14:20:42 GMT
From: Lars.Plessmann@gmx.de (Lars)
Subject: How to check validity of a credit card?
Message-Id: <3b013aca.4247483@news.btx.dtag.de>

can anybody tell me how to check a creditcards validity?
please do not refer to any module. maybe there is another possibility
to include some code to my cgi script directly.

thx in advance,
Lars


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

Date: Tue, 15 May 2001 10:33:20 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: How to check validity of a credit card?
Message-Id: <3B013E30.713FD876@westat.com>

Lars wrote:
> 
> can anybody tell me how to check a creditcards validity?

This is a non-Perl question so I'm going to give you a non-Perl answer.  
See: <http://www.beachnet.com/~hstiles/cardtype.html>

If you have trouble implementing this formula in Perl, then that would 
be a Perl question.

> please do not refer to any module. maybe there is another possibility
> to include some code to my cgi script directly.

Why no modules?  That's the Perl way to include some code in your script
directly.
See: <http://search.cpan.org/search?dist=Business-CreditCard>

-- 
Henry Hartley


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

Date: 15 May 2001 14:49:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to check validity of a credit card?
Message-Id: <9drflu$ceu$1@mamenchi.zrz.TU-Berlin.DE>

According to Lars <Lars.Plessmann@gmx.de>:
> can anybody tell me how to check a creditcards validity?
> please do not refer to any module. maybe there is another possibility
> to include some code to my cgi script directly.

Sure.

    sub valid_number {
        my $card_number = shift;
        return crypt( $card_number, 'as') eq 'asxMyJW9ok9EA';
    }

Seriously, why don't you want to use a module?  There is one for
exactly this purpose, and a search for "credit" on

http://theoryx5.uwinnipeg.ca/CPAN/cpan-search.html

will find it.

Anno


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

Date: Tue, 15 May 2001 15:17:29 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: How to check validity of a credit card?
Message-Id: <3B01209B.F25AE0DB@home.nl>

Lars wrote:

> can anybody tell me how to check a creditcards validity?
> please do not refer to any module. maybe there is another possibility
> to include some code to my cgi script directly.
>
> thx in advance,
> Lars

the module Business::CreditCard is easy and simple in its use so use
that,
or look at its code if u think you can do better.
Oh and if so, post it please.



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 905
**************************************


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