[13579] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 989 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 5 11:05:39 1999

Date: Tue, 5 Oct 1999 08:05:22 -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: <939135921-v9-i989@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 5 Oct 1999     Volume: 9 Number: 989

Today's topics:
    Re: acos function (M.J.T. Guy)
        altering contents of files <arogers@rational.com>
    Re: Counter <rhomberg@ife.ee.ethz.ch>
    Re: Counter <debot@xs4all.nl>
    Re: DBI/CGI Problem (cmd line works, but webserver fail (Scott McMahan)
    Re: eval Problem (Anno Siegel)
    Re: eval Problem <gernot@cat.at>
    Re: Executing passwd from perl to update passwd file? <namecity@my-deja.com>
        Filehandle with Perl / CGI <m.scheferhoff@gmx.de>
    Re: GDBM access behave differently  when called from CG <l.laperrousaz@net-clic.net>
        how to detect running process with perl? <xliu@cs.sunysb.edu>
        how to detect running process with perl? <xliu@cs.sunysb.edu>
        how to detect running process with perl? <xliu@cs.sunysb.edu>
        Interpret variable and its name? jboes@my-deja.com
    Re: libraries "die"ing (Benjamin Franz)
    Re: Need help with input verifier (Jana Cole or John Sayre)
    Re: Net::SMTP <nigh_postal@my-deja.com>
    Re: Net::SMTP <nigh_postal@my-deja.com>
    Re: New book: Automating Windows With Perl (Scott McMahan)
    Re: Newbie question ! (M.J.T. Guy)
    Re: odd or even numbers? <rhomberg@ife.ee.ethz.ch>
    Re: odd or even numbers? <rob@frii.com>
    Re: odd or even numbers? <Kien_Ha@Mitel.COM>
    Re: odd or even numbers? (H. Merijn Brand)
    Re: odd or even numbers? (Greg Bacon)
    Re: pattern match. & ? operator (M.J.T. Guy)
    Re: pattern matching question (M.J.T. Guy)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 5 Oct 1999 14:12:21 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: acos function
Message-Id: <7td105$1v1$1@pegasus.csx.cam.ac.uk>

In article <37f31959.0@etsv0008>,  <jmn.ac.delete@abanet.it> wrote:
>
>I read the docs. They say POSIX::acos. A discussion of why I don’t
> want to use the POSIX module will not be helpful.

That's not all they say  -  they also offer a formula, which will in
practice be more accurate (and probably faster) than Hastings' formula.

And the documentation doesn't mention it, but you can also use the
built-in module Math::Complex, which provides all the trig and
hyperbolic functions:

        use Math::Complex qw(acos);
        print acos(0.5);

And if you give it out-of-range arguments, it'll return the correct
complex result.


Mike Guy


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

Date: Tue, 05 Oct 1999 15:33:36 -0700
From: alan rogers <arogers@rational.com>
Subject: altering contents of files
Message-Id: <37FA7CC0.59372CF@rational.com>

Hi,

I wonder if anybody can help me with a problem I have.
I have created a series of files through a while statement which works
fine. What I want to do next is add to the contents the unix command "rm
-f" so it will look like rm -f <contents>
rm -f <contents>

etc

If anybody can point me in the right direction I would be most grateful.

Regards
Alan Rogers



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

Date: Tue, 05 Oct 1999 16:08:02 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Counter
Message-Id: <37FA0642.5FA6B2A0@ife.ee.ethz.ch>

Chris Loeser wrote:
> 
> Tach Post,
> 
> ich moechte ganz gerne einen Counter in einem HTML-Dokument haben.
> 
> 1.Server Side Includes ist bei dem HTTP-Server ausgeschaltet, daher :
> 
> 2. In einer vorhandenen Seite soll ein Perl-Script aufgerufen werden und
>    die Counterzahl soll in das Dokument eingebunden werden....
> 
> Hat jemand das schon mal gemacht ??

Du wirst es nicht glauben, aber es hat tatsaechlich schon mal jemand
einen Hitcounter implementiert.
Wie man das in die Seite einbindet ist eine reine HTML Frage.
Wie man den Counter macht steht im perlfaq5
perldoc -q locking

- Alex


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

Date: Tue, 05 Oct 1999 16:30:21 +0200
From: Frank de Bot <debot@xs4all.nl>
Subject: Re: Counter
Message-Id: <37FA0B7D.161CAE91@xs4all.nl>

Maybe if you write your messages in English we could all understand.

Chris Loeser wrote:

> Tach Post,
>
> ich moechte ganz gerne einen Counter in einem HTML-Dokument haben.
>
> 1.Server Side Includes ist bei dem HTTP-Server ausgeschaltet, daher :
>
> 2. In einer vorhandenen Seite soll ein Perl-Script aufgerufen werden und
>    die Counterzahl soll in das Dokument eingebunden werden....
>
> Hat jemand das schon mal gemacht ??
>
> cheers
>
> Chris
>
> mailto:loeser@upb.de

--
Penpal International
http://ppi.searchy.net
ppi@searchy.net or debot@xs4all.nl




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

Date: Tue, 05 Oct 1999 13:18:52 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: DBI/CGI Problem (cmd line works, but webserver fails to connect)
Message-Id: <0VmK3.1158$H32.69840@newshog.newsread.com>

David Salgado (david@connmed.co.nospam.uk) wrote:

> Concurrent access to the
> backend shouldn't cause any problems.

It shouldn't in a real database, but it probably will with
MS Access. Access is not a multiuser database like SQL
Server. Although Access has a few rudimentary multiuser
capabilities, it is nowhere near industrial strength
for web use.

Scott


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

Date: 5 Oct 1999 13:41:00 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: eval Problem
Message-Id: <7tcv5c$82o$1@lublin.zrz.tu-berlin.de>

Gernot Homma  <gernot@cat.at> wrote in comp.lang.perl.misc:
>This is a multi-part message in MIME format.
>--------------1E89547042C2A8F21A8BDD73
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>I have a problem with "eval" inside object-methods
>I have a method called method2
>
>sub method2 {
>   my $self = shift;
>   print $self . "\n";
>}
>
>and when I call method2 in two different ways I get different results
>from the print command.
>this code works fine:
>the print command in method2 prints out the correct reference to the
>object
>
>sub method1 {
>   my $self = shift;
>   $self->method2("atext");
>}
>
>
>but when i use
>
>sub method1 {
>   my $self = shift;
>   my $s = '$self->method2("atext")';
>   eval($s);
>}
>the code failes, the print command in method2 doesn't print out the
>correct reference

I don't see your problem.  Both print the same for me.  What is the
new() method to go with these?

Anno




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

Date: Tue, 05 Oct 1999 16:23:20 +0200
From: Gernot Homma <gernot@cat.at>
Subject: Re: eval Problem
Message-Id: <37FA09D8.B7E0BC3E@cat.at>

This is a multi-part message in MIME format.
--------------7D7D67A799D02549516A2E29
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

The problem is, that this code is part of a bigger project, and it's not
usefull to post the whole code.
The problem arises when I invoke method1 in the following context.
I have the following classes:
mysuperclass, class1 derived from mysuperclass, class2 derived from
mysuperclass;
method1 and method2 are methods of mysuperclass

now in a method of class1 (called methodcl1) i'm calling mehthod1 a
callstack looks like this
i1 = new class1; i2 = new class2;
i1 contains i2;

i1->methodcl1
   i1->method1
     i1->method2
   i2->method1    :: And now when method2 is called from instance i2 the
$self variable in method2 refers to instance i1

I hope this is now clearer
By the way:
Is there another way to call a method by a string

Many thanks
Gernot



Anno Siegel wrote:

> Gernot Homma  <gernot@cat.at> wrote in comp.lang.perl.misc:
> >This is a multi-part message in MIME format.
> >--------------1E89547042C2A8F21A8BDD73
> >Content-Type: text/plain; charset=us-ascii
> >Content-Transfer-Encoding: 7bit
> >
> >I have a problem with "eval" inside object-methods
> >I have a method called method2
> >
> >sub method2 {
> >   my $self = shift;
> >   print $self . "\n";
> >}
> >
> >and when I call method2 in two different ways I get different results
> >from the print command.
> >this code works fine:
> >the print command in method2 prints out the correct reference to the
> >object
> >
> >sub method1 {
> >   my $self = shift;
> >   $self->method2("atext");
> >}
> >
> >
> >but when i use
> >
> >sub method1 {
> >   my $self = shift;
> >   my $s = '$self->method2("atext")';
> >   eval($s);
> >}
> >the code failes, the print command in method2 doesn't print out the
> >correct reference
>
> I don't see your problem.  Both print the same for me.  What is the
> new() method to go with these?
>
> Anno

--------------7D7D67A799D02549516A2E29
Content-Type: text/x-vcard; charset=us-ascii;
 name="gernot.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Gernot Homma
Content-Disposition: attachment;
 filename="gernot.vcf"

begin:vcard 
n:Homma;Gernot
x-mozilla-html:FALSE
org:Cyber-Atelier
adr:;;;Vienna ;;1210;Austria
version:2.1
email;internet:gernot@cat.at
tel;fax:+43 1 272 92 51 9
tel;work:+43 1 272 92 51
x-mozilla-cpt:;0
fn:Homma, Gernot
end:vcard

--------------7D7D67A799D02549516A2E29--



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

Date: Tue, 05 Oct 1999 14:34:04 GMT
From: q2020262 <namecity@my-deja.com>
Subject: Re: Executing passwd from perl to update passwd file?
Message-Id: <7td28s$vtr$1@nnrp1.deja.com>

How are you creating the passwds?

SC



In article <37F2501B.7E0736AE@zipee.com>,
  Greg Crow <gcrow@zipee.com> wrote:
> Hi all,
>
> I've been working on a perl script that accesses a database and gets
> info
> to add newusers and the users password. All is working well, except
> if I try to login as one of the new users, I get denied. In my
syslogs,
> I get this when the password is beening create via passwd which is
> executed from within the perl script:
>
>        PAM_pwdb[6535]: password for ( user/0) changed by ((null)/0)
>
> The program is running as root so it should display this:
>
>         PAM_pwdb[6535]: password for (user/0) changed by (root/0)
>
> Does anyone know how I could get around this problem?
>
> Thanks,
>
> --
> Greg Crow                       Email: gcrow@zipee.com
> Zipee.com                       Voice: 360-748-4800 ext. 232
> Chief Technical Officer           Fax: 360-748-4600
>
>


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


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

Date: Tue, 05 Oct 1999 15:25:21 +0200
From: Michael Scheferhoff <m.scheferhoff@gmx.de>
Subject: Filehandle with Perl / CGI
Message-Id: <37F9FC41.FB98A37E@gmx.de>

Hello,

I programmed a newsclient with perl / CGI. With this client I'm able to
post messages to a newsserver on my local intranet. This client is also
able to add attachments to a posting. I encode these attachments MIME
Base 64, like email attachments. Now I would of course like to be able
to download postings including their attachments to my workstation. To
open the posting and decode the attachment is no problem. The "data" of
the file is in a scalar like "$decoded". My problem is:

How can I get the attachment? Do I have to use a filehandle? Is there
another possibility?

Thanks for your help,

Michael



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

Date: Tue, 5 Oct 1999 15:48:53 +0200
From: "Laurent.Laperrousaz" <l.laperrousaz@net-clic.net>
Subject: Re: GDBM access behave differently  when called from CGI
Message-Id: <7tcvtr$bu2$1@jaydee.iway.fr>


>When you're having trouble with a CGI program in Perl, you should first
>look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
>such problems. It's available on CPAN.
>
>   http://www.perl.com/CPAN/
>   http://www.cpan.org/
>   http://www.cpan.org/doc/FAQs/cgi/idiots-guide.html
>   http://www.cpan.org/doc/manual/html/pod/


I did of course before posting my  request
>
>
>Sounds as if you may have a different perl binary (or something) on the
>server as you do when you test your code on the command line. But maybe
>it's a permissions problem.


I'm testing on the same system

I also thought it was a permission problem, but I use the same user for
Apache and my standard test
 ...
I'm still wandering...

Thank you any way

Laurent
>




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

Date: Tue, 05 Oct 1999 10:25:18 -0400
From: Xiaoyan Liu <xliu@cs.sunysb.edu>
Subject: how to detect running process with perl?
Message-Id: <37FA0A4E.823D63CE@cs.sunysb.edu>

Hi,

In my CGI script, there is the need to detect whether a certain server
application
is running before sending the client request. If not,  it has to be
started once.

How to do this with Perl?

thank you in advance.


Liu



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

Date: Tue, 05 Oct 1999 10:25:47 -0400
From: Xiaoyan Liu <xliu@cs.sunysb.edu>
Subject: how to detect running process with perl?
Message-Id: <37FA0A6B.CD91B41A@cs.sunysb.edu>

Hi,

In my CGI script, there is the need to detect whether a certain server
application
is running before sending the client request. If not,  it has to be
started once.

How to do this with Perl?

thank you in advance.


Liu



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

Date: Tue, 05 Oct 1999 10:26:00 -0400
From: Xiaoyan Liu <xliu@cs.sunysb.edu>
Subject: how to detect running process with perl?
Message-Id: <37FA0A78.5DE9D0CD@cs.sunysb.edu>

Hi,

In my CGI script, there is the need to detect whether a certain server
application
is running before sending the client request. If not,  it has to be
started once.

How to do this with Perl?

thank you in advance.


Liu



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

Date: Tue, 05 Oct 1999 14:14:43 GMT
From: jboes@my-deja.com
Subject: Interpret variable and its name?
Message-Id: <7td144$uu9$1@nnrp1.deja.com>

Help me get through a mental block. Here's what I want:

sub logVar;

$a = 'foo';
logVar($a);
$a = 3;
logVar($a);
$a = \@b;
logVar($a);
logVar($b);

sub logVar {
 ???
}

would result in this output:

$a: 'foo'
$a: 3
$a: reference
$b: undef

That is, I want to be able to pass in a variable, or its name as in

logVar('a');

if I have to do it that way, and have a 'debugger' style output of the
variable name and contents.

(Yes, I know I can do this with something like

print '$a: ' . "'$a'";

but where's the challenge in that?)

The trick: this should work the same regardless of the local-ness or my-
ness of the variable.


--
Jeff Boes  jboes@qtm.net
http://www.qtm.net/~jboes/


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


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

Date: Tue, 05 Oct 1999 13:18:47 GMT
From: snowhare@long-lake.nihongo.org (Benjamin Franz)
Subject: Re: libraries "die"ing
Message-Id: <XUmK3.548$PG3.47770@typhoon01.swbell.net>

In article <OOD5N2inbanE5PHHhLWT3bJCOgf1@4ax.com>,
David Cantrell  <NukeEmUp@ThePentagon.com> wrote:
>On Mon, 27 Sep 1999 16:46:59 GMT, rdosser@my-deja.com said:
>
>>I find myself increasingly annoyed by library subroutines that 
>>take the liberty of "die"ing for me instead of setting an error 
>>code/message and returning undef.
>
>You're not the only one.
>
>I suspect that modules/libraries dieing is often because the authors
>are aware that programmers frequently don't bother checking return
>values. 

That's why I do it. There is almost never a good result from
ignoring a failure. By dieing or croaking, I usually ensure
that if it is ignored, it was on purpose. How many postings 
relating to 'tie' and 'open' FAQs would vanish from this group 
if they threw exceptions on failure rather than returning a false
value?

>My policy in modules I have written recently is to have them
>default to dieing when an error occurs, but if the programmer sets
>something like $MyModule::RETURN_ON_ERROR to a true value, they will
>return error codes instead.  In this way, programmers can make a
>'contract' with my module promising that they will be good little boys
>and girls and religiously check return values and handle them
>appropriately.

Interesting idea. I'll have to think about doing that.

-- 
Benjamin Franz


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

Date: Tue, 05 Oct 1999 13:05:51 GMT
From: quikscor@ix.netcom.com (Jana Cole or John Sayre)
Subject: Re: Need help with input verifier
Message-Id: <37f9f74c.4187507@nntp.ix.netcom.com>


I just saw a mistake in the code ("emt" should be "frm").
Here's the new version:

#!/usr/bin/perl
#script: lstreqtst.cgi
use CGI;
$q = new CGI;
print $q->header();
print "<HTML><HEAD><TITLE></TITLE>";
print <<Scripting;
<SCRIPT LANGUAGE="JavaScript">

# verifies input
function verinp(frm)
{
   var msg;
   var empty_fields = "";      
   
   if ((frm.restaurant_name == null) || (frm.restaurant_name == "") ||
isBlank(frm.restaurant_name))
   {
      empty_fields += "\n          " + "restaurant_name";
            
   }
         
   if (!empty_fields) return true;
   if (empty_fields)
   {
      msg += "You must fill in all required fields.\n\n"
      msg += "Fill in the following empty fields:"
         + empty_fields + "\n";
   }
   alert(msg);
   return false;
}

# tests for a field of whitespace
function isBlank(str)
{
   for (var i = 0; i < str.length; i++)
   {
      var chr = str.charAt(i);
      if ((chr != ' ') && (chr != '\n') && (chr != '\t')) return
false;
   } 
   return true;
} 
</SCRIPT>
Scripting
;
print "</HEAD><BODY>";

# if parameters, write them to file,
# if no parameters, display the form
if ($q->param())
{
   #write them to request file
   wrtreqfil();

   # thank for info
   print tnklstinf();
}
else
{
   # print the form
   prtlstinffrm();
}
print $q->end_html();

# write parameters to file
sub wrtreqfil
{
   $record_number = getrecnum();
   $month = (qw(1 2 3 4 5 6 7 8 9 10 11 12)) [(localtime)[4]];
   $day = (qw(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
22 23 24 25 26 27 28 29 30 31)) [(localtime)[3]];
   $year = (localtime)[5];
   if ($year > 99)
   {
      $year = year - 100;
   }
   $todays_date = "$month/$day/$year"; 
   open(REQFIL,">>lstreq.txt");
   print REQFIL "|$record_number|$todays_date|*";
   foreach $name ($q->param())
   {
      $value = $q->param($name);
      if ($value ne "Send")
      { 
      $value =~ s/^\s+//;
      $value =~ s/\s+$//;
      print REQFIL "|$value";
      }
   }
  print REQFIL "\n";
   close(REQFIL);
}

# thank user for info
sub tnklstinf
{
   print "Thank you for submitting your information";  
}

# display the form
sub prtlstinffrm
{
   print <<EndForm
    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 WIDTH="400"
BGCOLOR="#FFFFFF">
    <tr><td><VALIGN=TOP>
    
    <FORM  ACTION="lstreq.cgi" METHOD="post" onSubmit="return
verinp(this);">
    
    <INPUT type="text" name="restaurant_name" size="40"><p>
        
    <INPUT type="submit"  value="Send" name="submit">
    <INPUT type="reset" value="Reset" name="reset">

    </FORM>
    </td></tr>
    </TABLE>
   
EndForm
;
}

# get the record number to write to file
sub getrecnum
{
   open(RECNUMFIL,"recnum.txt");
   $currecnum = <RECNUMFIL>;
   $nxtrecnum = $currecnum + 1;
   open(RECNUMFIL,">recnum.txt");
   print RECNUMFIL $nxtrecnum;
   close(RECNUMFIL);
   chomp($currecnum);
   return $currecnum;
}




On Tue, 05 Oct 1999 12:49:36 GMT, quikscor@ix.netcom.com (Jana Cole or
John Sayre) wrote:

>#!/usr/bin/perl
>
>I copied this verification code from Flanagan's JavaScript book, but I
>can't get it to work for me.  Maybe the way I'm inbedding it in the
>Perl, I don't know.  Also, I'm not sure if this should be posted here
>or on a JavaScript newsgroup.
>
>I'm checking a text field for empty.  If it's empty, I'm supposed to
>get a dialog box saying please fill the field.  The empty field should
>not be submitted.  But it is.  If the field is filled or empty the CGI
>program runs, and the field is written to the data file.
>When the field is empty, the file record looks like this:
>record_number|todays_date|*|
>
>So, it seems that somehow the JavaScript is being ignored.
>Why, why, why......
>*************************************************************************************
>#script: lstreqtst.cgi
>use CGI;
>$q = new CGI;
>print $q->header();
>print "<HTML><HEAD><TITLE></TITLE>";
>print <<Scripting;
><SCRIPT LANGUAGE="JavaScript">
>
># verifies input
>function verinp(frm)
>{
>   var msg;
>   var empty_fields = "";      
>   
>   if ((emt.restaurant_name == null) || (emt.restaurant_name == "") ||
>isBlank(emt.restaurant_name))
>   {
>      empty_fields += "\n          " + emt.name;
>            
>   }
>         
>   if (!empty_fields) return true;
>   if (empty_fields)
>   {
>      msg += "You must fill in all required fields.\n\n"
>      msg += "Fill in the following empty fields:"
>         + empty_fileds + "\n";
>   }
>   alert(msg);
>   return false;
>}
>
># tests for a field of whitespace
>function isBlank(str)
>{
>   for (var i = 0; i < str.length; i++)
>   {
>      var chr = str.charAt(i);
>      if ((chr != ' ') && (chr != '\n') && (chr != '\t')) return
>false;
>   } 
>   return true;
>} 
></SCRIPT>
>Scripting
>;
>print "</HEAD><BODY>";
>
># if parameters, write them to file,
># if no parameters, display the form
>if ($q->param())
>{
>   #write them to request file
>   wrtreqfil();
>
>   # thank for info
>   print tnklstinf();
>}
>else
>{
>   # print the form
>   prtlstinffrm();
>}
>print $q->end_html();
>
># write parameters to file
>sub wrtreqfil
>{
>   $record_number = getrecnum();
>   $month = (qw(1 2 3 4 5 6 7 8 9 10 11 12)) [(localtime)[4]];
>   $day = (qw(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
>22 23 24 25 26 27 28 29 30 31)) [(localtime)[3]];
>   $year = (localtime)[5];
>   if ($year > 99)
>   {
>      $year = year - 100;
>   }
>   $todays_date = "$month/$day/$year"; 
>   open(REQFIL,">>lstreq.txt");
>   print REQFIL "|$record_number|$todays_date|*";
>   foreach $name ($q->param())
>   {
>      $value = $q->param($name);
>      if ($value ne "Send")
>      { 
>      $value =~ s/^\s+//;
>      $value =~ s/\s+$//;
>      print REQFIL "|$value";
>      }
>   }
>  print REQFIL "\n";
>   close(REQFIL);
>}
>
># thank user for info
>sub tnklstinf
>{
>   print "Thank you for submitting your information";  
>}
>
># display the form
>sub prtlstinffrm
>{
>   print <<EndForm
>    <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=10 WIDTH="400"
>BGCOLOR="#FFFFFF">
>    <tr><td><VALIGN=TOP>
>    
>    <FORM  ACTION="lstreq.cgi" METHOD="post" onSubmit="return
>verinp(this);">
>    
>    <INPUT type="text" name="restaurant_name" size="40"><p>
>        
>    <INPUT type="submit"  value="Send" name="submit">
>    <INPUT type="reset" value="Reset" name="reset">
>
>    </FORM>
>    </td></tr>
>    </TABLE>
>   
>EndForm
>;
>}
>
># get the record number to write to file
>sub getrecnum
>{
>   open(RECNUMFIL,"recnum.txt");
>   $currecnum = <RECNUMFIL>;
>   $nxtrecnum = $currecnum + 1;
>   open(RECNUMFIL,">recnum.txt");
>   print RECNUMFIL $nxtrecnum;
>   close(RECNUMFIL);
>   chomp($currecnum);
>   return $currecnum;
>}
>



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

Date: Tue, 05 Oct 1999 13:20:24 GMT
From: nigh_postal <nigh_postal@my-deja.com>
Subject: Re: Net::SMTP
Message-Id: <7tctuc$sgd$1@nnrp1.deja.com>

Nod.. like $smtp->verify(<Insert Address here>);  I had tried that as
well, but it didn't help.  I just forgot to put it back in.  I'll be
it's the relaying problem because I get the message every time.

I'll let you know if we're still having problems.

Thanks,
-Cody
>
> You should, of course, check the validity of the email list you are
> providing.
> If, for instance, one of your addresses is missing a qoute, like:
> "Big Bad Bubba <bubba@big.bad.com>,
> then it'll flub up a gabunch of other addresses.
> Also, if you are accessing a remote SMTP server that does not allow
> relaying from the server the script is running on, then only those
email
> addresses
> that are hosted on the SMTP server will be delivered.
>
> --homeless
> P.S. If you get desparate, let me know,  I do lots of low level pop3
and
> smtp stuff and would
> be happy to lend a hand.
>
>


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


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

Date: Tue, 05 Oct 1999 13:31:12 GMT
From: nigh_postal <nigh_postal@my-deja.com>
Subject: Re: Net::SMTP
Message-Id: <7tcuj0$sv1$1@nnrp1.deja.com>

Hrm... I tried sending it to a yahoo.com email address and it got there
fine.  For such a simple program, this has proved to be a major pain in
the neck.  *sigh* Back to the drawing board.

-Cody


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


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

Date: Tue, 05 Oct 1999 13:22:20 GMT
From: scott@aravis.softbase.com (Scott McMahan)
Subject: Re: New book: Automating Windows With Perl
Message-Id: <gYmK3.1159$H32.69840@newshog.newsread.com>

Kragen Sitaker (kragen@dnaco.net) wrote:

> >> - the publisher is "R&D Books", rdbooks.com, which appears to be a subsidiary
> >>   of Miller Freeman books.
> >
> >They publish the C/C++ User's Journal. I get that just to read Plauger's
> >column. In my other career as a book reviewer, I've seen several of
> >their books, and they have a high quality level overall. They're a
> >niche publisher, like O'Reilly used to be back in the pre-Internet days,
> >publishing the books that the big companies don't think are worth it.

> Thanks for the info!  I'll have to see if I can find other interesting
> books on their web pages.

They've got several gems among their books, including a C book on date and
time calculations that's really good. They're like O'Reilly was in '93,
a small collection of very focused books on subjects the big publishers
will not bother themselves with. There was a time when O'Reilly used to
publish books on obscure UNIX tools and it was hard to find
them on the shelves :)

Scott


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

Date: 5 Oct 1999 13:53:59 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Newbie question !
Message-Id: <7tcvtn$vv$1@pegasus.csx.cam.ac.uk>

In article <7tcbva$gi6$1@nnrp1.deja.com>, Wise Guy  <WiseGuy_73@go.com> wrote:
>I am pretty new to perl and would like some help. In Benchmark, what is
>the "iterations" ? From basic definition, I understand it is a loop.
>
>Why do I need iterations - can I not make do with only one iteration ?
>Or is it that the more the number of iterations, the more accurate is
>the result ?

Exactly.


Mike Guy


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

Date: Tue, 05 Oct 1999 15:11:29 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: odd or even numbers?
Message-Id: <37F9F901.3E0D2B4D@ife.ee.ethz.ch>

Abigail wrote:

> __ Does anybody know if there is an easy way to check whether a scalar value
> __ contains a odd or even integer?

> 
>     sub is_even {
>         my $number = abs shift;
>            $number ? is_odd -- $number : 1;
>     }
> 
>     sub is_odd {!is_even shift}
> 
> Or if you don't want to type that much:
> 
>     sub is_even {"${\5*$_[0]}" =~ /0$/}


but neither of those functions work!
The first gives a syntax error and if changed   {s/--
\$number/(--\$number)/}
- it doesn't terminate given fractional numbers
- returns true given text (which clearly aren't even integers)
The second always returned false in my tests.

The following two functions do what he asked:
check wether a scalar contains an odd or even integer (check if integer
&& odd)

sub is_even_int {
  eval "\$_[0] =~ /^-?\\d*[@{[join'',map {$_*2} (0..4)]}]\$/"?1:0;
}
sub is_odd_int {
  eval "\$_[0] =~ /^-?\\d*[@{[join'',map {$_*2+1} (0..4)]}]\$/"?1:0;
}

or the boring variant

sub is_even_int2 {
  int $_[0] eq $_[0] &&  ~$_[0]&1;
}
sub is_odd_int2 {
  int $_[0] eq $_[0] &&  $_[0]&1;
}


- Alex


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

Date: Tue, 05 Oct 1999 07:29:32 -0600
From: Rob Greenbank <rob@frii.com>
Subject: Re: odd or even numbers?
Message-Id: <6vz5NwLZ9Z9AH6HQMQMrG8ltuDop@4ax.com>

On 5 Oct 1999 11:27:55 +0100, Jonathan Stowe <gellyfish@gellyfish.com>
wrote:

>Well you could or you could do:
>
>  if ($value % 2)
>    {
>     #odd
>    }
>
>/J\

Or, ever so slightly faster is:
   if ($value & 1)
      {
         #odd
      }

Rob


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

Date: Tue, 05 Oct 1999 14:01:31 GMT
From: Kien Ha <Kien_Ha@Mitel.COM>
Subject: Re: odd or even numbers?
Message-Id: <37FA04A9.5307DD15@Mitel.COM>

Fokko Wesselius wrote:
> 
> Hello,
> 
> Does anybody know if there is an easy way to check whether a scalar value
> contains a odd or even integer?
> 
> Is there a perl function for this problem?
> 
> P.S. I'm using ActivePerl's win32 port of Perl.


How about checking the least significant bit like: 

print ( $number & 1 ? 'odd' : 'even', "\n");

-- 
Kien


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

Date: 5 Oct 1999 10:37:23 GMT
From: h.m.brand@hccnet.nl (H. Merijn Brand)
Subject: Re: odd or even numbers?
Message-Id: <8E568B036Merijn@192.0.1.19>

>Hello,
>
>Does anybody know if there is an easy way to check whether a scalar value
>contains a odd or even integer?

$num_type = $number % 2 ? "odd" : "even";

>Is there a perl function for this problem?

Yes, it's called %

>P.S. I'm using ActivePerl's win32 port of Perl.

So what ... (BTW Active Perl 520 has been released lataly)


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

Date: 5 Oct 1999 14:16:18 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: odd or even numbers?
Message-Id: <7td17i$fmk$3@info2.uah.edu>

In article <8E568B036Merijn@192.0.1.19>,
	h.m.brand@hccnet.nl (H. Merijn Brand) writes:

: >Is there a perl function for this problem?
: 
: Yes, it's called %

It's also called &. :-)

Greg
-- 
People are divided into two groups--the righteous and the unrighteous--and
the righteous do the dividing.
    -- Lord Cohen


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

Date: 5 Oct 1999 13:11:04 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: pattern match. & ? operator
Message-Id: <7tctd8$s0g$1@pegasus.csx.cam.ac.uk>

David Cassell  <cassell@mail.cor.epa.gov> wrote:
>
>if ( $string =~ /(\w+) (\(\w+\))?/ ) {
>    print "one: $1\n";
>    print "two: $2\n";
>}

That's not -w clean (but nor was the priginal attempt, of course).
So I'd suggest an extra set of perens:

 if ( $string =~ /(\w+) ((?:\(\w+\))?)/ ) {


Mike Guy


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

Date: 5 Oct 1999 13:37:13 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: pattern matching question
Message-Id: <7tcuu9$21$1@pegasus.csx.cam.ac.uk>

In article <Pine.LNX.4.10.9910041629250.19541-100000@ns0.jimsoffice.org>,
James Nessen  <nessenj@jimsoffice.org> wrote:
>
>        if ($in =~ /^P$u/){$userfound=0}

In addition to using \b as others have replied, also consider using \Q
if there is any possibility of unusual characters in $u:

         if ($in =~ /^P\Q$u\E\b/){$userfound=0}


Mike Guy


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

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


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