[12638] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 47 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 07:47:59 1999

Date: Wed, 7 Jul 1999 04:37:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 7 Jul 1999     Volume: 9 Number: 47

Today's topics:
    Re: Sending Emails but not using Sendmail etc etc <lgcl01@es.co.nz>
    Re: Sending Emails but not using Sendmail etc etc (I.J. Garlick)
    Re: Sending Emails but not using Sendmail etc etc time4tea@my-deja.com
    Re: Sending Emails but not using Sendmail etc etc (M.)
    Re: shortest self printing perl program quuxa@my-deja.com
        significant digits question!! <krutd@cadvision.com>
    Re: significant digits question!! <JFedor@datacom-css.com>
    Re: significant digits question!! <uri@sysarch.com>
    Re: significant digits question!! (Bob Trieger)
    Re: significant digits question!! (Abigail)
    Re: significant digits question!! (Tad McClellan)
    Re: significant digits question!! <palincss@his.com>
    Re: significant digits question!! (Abigail)
    Re: significant digits question!! <gellyfish@gellyfish.com>
    Re: significant digits question!! mchalyard@my-deja.com
    Re: significant digits question!! <kimball@stsci.edu>
    Re: simple math problem (Tad McClellan)
        Socket Programming <alex@exbook.com>
    Re: Socket Programming (Abigail)
    Re: Socket w/o Library <alex@exbook.com>
        something similar to 'creat' in C <engr@t1.ima.com>
    Re: something similar to 'creat' in C (Alan Curry)
    Re: something similar to 'creat' in C <Savage.Ron.RS@bhp.com.au>
    Re: something similar to 'creat' in C (Alan Curry)
    Re: something similar to 'creat' in C (Anno Siegel)
    Re: something similar to 'creat' in C <engr@t1.ima.com>
    Re: something similar to 'creat' in C <dms@rtp-bosch.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Sat, 3 Jul 1999 13:38:16 +1200
From: "Christopher Fairbairn" <lgcl01@es.co.nz>
Subject: Re: Sending Emails but not using Sendmail etc etc
Message-Id: <930965863.59654@inv.ihug.co.nz>

Hi,

Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
news:7lideu$1ac$1@gellyfish.btinternet.com...
> > I use smtp.es.co.nz to send emails using Outlook Express or Pine etc etc
is
> > there any way I can use this smtp server to send emails via PERL?
> >
>
> You can use the module Net::SMTP or one of the Mail::* modules to talk
> directly to this server - Of course you might not be able to use either
> of these solutions ...

I have tried using the Net::SMTP module but it is not on the server and I
don't know how to install it without having proper access to the server (ie
when my only access is via FTP).

However from some where on the net (it's been sitting on my harddrive for a
while) I have found a function which would send an email using sockets to
connect to an SMTP server or if you have sendmail send the email using
SENDMAIL. I'll list it below as I have found it usefull

$SMTP_SERVER = "smtp.es.co.nz";
# $SEND_MAIL="/usr/lib/sendmail -t";

###################################################################
#Sendmail.pm routine below by Milivoj Ivkovic
###################################################################
sub sendmail  {

# error codes below for those who bother to check result codes <gr>

# 1 success
# -1 $smtphost unknown
# -2 socket() failed
# -3 connect() failed
# -4 service not available
# -5 unspecified communication error
# -6 local user $to unknown on host $smtp
# -7 transmission of message failed
# -8 argument $to empty
#
#  Sample call:
#
# &sendmail($from, $reply, $to, $smtp, $subject, $message );
#
#  Note that there are several commands for cleaning up possible bad
inputs - if you
#  are hard coding things from a library file, so of those are unnecesssary
#

    my ($fromaddr, $replyaddr, $to, $smtp, $subject, $message) = @_;

    $to =~ s/[ \t]+/, /g; # pack spaces and add comma
    $fromaddr =~ s/.*<([^\s]*?)>/$1/; # get from email address
    $replyaddr =~ s/.*<([^\s]*?)>/$1/; # get reply email address
    $replyaddr =~ s/^([^\s]+).*/$1/; # use first address
    $message =~ s/^\./\.\./gm; # handle . as first character
    $message =~ s/\r\n/\n/g; # handle line ending
    $message =~ s/\n/\r\n/g;
    $smtp =~ s/^\s+//g; # remove spaces around $smtp
    $smtp =~ s/\s+$//g;

    if (!$to)
    {
 return(-8);
    }

 if ($SMTP_SERVER ne "")
  {
    my($proto) = (getprotobyname('tcp'))[2];
    my($port) = (getservbyname('smtp', 'tcp'))[2];

    my($smtpaddr) = ($smtp =~
       /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/)
 ? pack('C4',$1,$2,$3,$4)
     : (gethostbyname($smtp))[4];

    if (!defined($smtpaddr))
    {
 return(-1);
    }

    if (!socket(MAIL, AF_INET, SOCK_STREAM, $proto))
    {
 return(-2);
    }

    if (!connect(MAIL, pack('Sna4x8', AF_INET, $port, $smtpaddr)))
    {
 return(-3);
    }

    my($oldfh) = select(MAIL);
    $| = 1;
    select($oldfh);

    $_ = <MAIL>;
    if (/^[45]/)
    {
 close(MAIL);
 return(-4);
    }

    print MAIL "helo $SMTP_SERVER\r\n";
    $_ = <MAIL>;
    if (/^[45]/)
    {
 close(MAIL);
 return(-5);
    }

    print MAIL "mail from: <$fromaddr>\r\n";
    $_ = <MAIL>;
    if (/^[45]/)
    {
 close(MAIL);
 return(-5);
    }

    foreach (split(/, /, $to))
    {
 print MAIL "rcpt to: <$_>\r\n";
 $_ = <MAIL>;
 if (/^[45]/)
 {
     close(MAIL);
     return(-6);
 }
    }

    print MAIL "data\r\n";
    $_ = <MAIL>;
    if (/^[45]/)
    {
 close MAIL;
 return(-5);
    }

   }

  if ($SEND_MAIL ne "")
   {
     open (MAIL,"| $SEND_MAIL");
   }

    print MAIL "To: $to\n";
    print MAIL "From: $fromaddr\n";
    print MAIL "Reply-to: $replyaddr\n" if $replyaddr;
    print MAIL "X-Mailer: NPM Virtual Postcard System by Christopher
Fairbairn\n";
    print MAIL "Subject: $subject\n\n";
    print MAIL "$message";
    print MAIL "\n.\n";

 if ($SMTP_SERVER ne "")
  {
    $_ = <MAIL>;
    if (/^[45]/)
    {
 close(MAIL);
 return(-7);
    }

    print MAIL "quit\r\n";
    $_ = <MAIL>;
  }

    close(MAIL);
    return(1);
}


Just make sure that you only define one of the two variables: $SMTP_SERVER
or $SEND_MAIL and this function will go about sending an email using that
method. Aka connected via sockets to the SMTP server or using the SendMail
program.

Thanks,
Christopher Fairbairn.

PS: I hope Outlook Express won't garble the source too much.




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

Date: Mon, 5 Jul 1999 11:02:16 GMT
From: ijg@connect.org.uk (I.J. Garlick)
Subject: Re: Sending Emails but not using Sendmail etc etc
Message-Id: <FEE9Bs.93s@csc.liv.ac.uk>

In article <930965863.59654@inv.ihug.co.nz>,
"Christopher Fairbairn" <lgcl01@es.co.nz> writes:
> Hi,
> 
> Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
> news:7lideu$1ac$1@gellyfish.btinternet.com...
>> > I use smtp.es.co.nz to send emails using Outlook Express or Pine etc etc
> is
>> > there any way I can use this smtp server to send emails via PERL?
>> >
>>
>> You can use the module Net::SMTP or one of the Mail::* modules to talk
>> directly to this server - Of course you might not be able to use either
>> of these solutions ...
> 
> I have tried using the Net::SMTP module but it is not on the server and I
> don't know how to install it without having proper access to the server (ie
> when my only access is via FTP).
> 
> However from some where on the net (it's been sitting on my harddrive for a
> while) I have found a function which would send an email using sockets to
> connect to an SMTP server or if you have sendmail send the email using
> SENDMAIL. I'll list it below as I have found it usefull
> 

Christopher, Christopher, Christopher. Jonathan is one of the more
competant people around here. He really doesn't need informing of that
mis-named CPAN module.

What I suspect he was alluding too and what you missed was the fact that
any compotent sys-admin will have blocked the SMTP port if they don't want
you to do that. (At least tha sane ones who wish to keep their sanity do).

From what you initally describe as your problem it sounds like this has
indeed been done (I know, we have someone here bashing their head against
that particular brick wall :-) ). You are on a hiding to nothing, give up,
you wont get past anything a compotent root user doesn't want you too.

Sorry if this seems a bit strong but it's for your own good (person
mentioned above has been trying for 15 months now, despite being told not
to and given the correct email procedure, which they refuse to beleive).

-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

As long as the answer is right, who cares if the question is wrong?



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

Date: Mon, 05 Jul 1999 15:46:58 GMT
From: time4tea@my-deja.com
Subject: Re: Sending Emails but not using Sendmail etc etc
Message-Id: <7lqk1g$m9o$1@nnrp1.deja.com>

In article <FEE9Bs.93s@csc.liv.ac.uk>,
  ijg@connect.org.uk (I.J. Garlick) wrote:
> In article <930965863.59654@inv.ihug.co.nz>,
> "Christopher Fairbairn" <lgcl01@es.co.nz> writes:
> > Hi,
> >
> > Jonathan Stowe <gellyfish@gellyfish.com> wrote in message
> > news:7lideu$1ac$1@gellyfish.btinternet.com...
>
> Christopher, Christopher, Christopher. Jonathan is one of the more
> competant people around here. He really doesn't need informing of that
> mis-named CPAN module.
>
> What I suspect he was alluding too and what you missed was the fact
that
> any compotent sys-admin will have blocked the SMTP port if they don't
want
> you to do that. (At least tha sane ones who wish to keep their sanity
do).
>
> From what you initally describe as your problem it sounds like this
has
> indeed been done (I know, we have someone here bashing their head
against
> that particular brick wall :-) ). You are on a hiding to nothing, give
up,
> you wont get past anything a compotent root user doesn't want you too.
>
> Sorry if this seems a bit strong but it's for your own good (person
> mentioned above has been trying for 15 months now, despite being told
not
> to and given the correct email procedure, which they refuse to
beleive).
>

Well, the answer is simple (is not particularly a perlish problem)

1) Can you reach a mailer host (anywhere) from your computer?
2) If no - You are stuck
   If yes - Use Mail::Sendmail, and edit it so that the line
   'smtp' => [ 'the.mail.server' ]
  points to (any) mail server you can reach.


You can of course use
perl Makefile.PL LIB=~/lib
or something to install the library locally....

Cheers!

James


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 06 Jul 1999 13:40:58 GMT
From: mi @ linux . mediaprofil . ch (M.)
Subject: Re: Sending Emails but not using Sendmail etc etc
Message-Id: <37820448.16013989@news.urbanet.ch>

The "Sendmail.pm" that was posted in this thread was attributed to me,
but I don't recognize it as something I would have done. It may be a
rewrite of one of my first rewrites of a script I had found on the
net... :-)

Anyway:

1. Don't use that! Get Mail::Sendmail (also a single Sendmail.pm file
to install), or MIME::Lite and libnet, or Mail::Sender etc...

2. Please remove my name from that Sendmail.pm file if you don't
simply delete the file, which is what you should reallly do... :-)

Milivoj Ivkovic



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

Date: Mon, 05 Jul 1999 22:17:46 GMT
From: quuxa@my-deja.com
Subject: Re: shortest self printing perl program
Message-Id: <7lrau2$tda$1@nnrp1.deja.com>

In article <87iu8vd1no.fsf@gate7.olympiakos.com>,
  Kiriakos Georgiou <kgnews@olympiakos.com> wrote:
>
> OK, since I am in quiz mode today, can someone come up
> with a shorter program that prints itself without opening
> any files, spawning processes etc. than this one-liner:
>
> printf($x,39,$x='printf($x,39,$x=%c%s%c,39);',39);
>

The shortest strictly conforming SRP I have found is:

$_=q{$_=q{Q};s/Q/$_/;print};s/Q/$_/;print

by Brian Raiter.  For others of varying length & strictness, there is
a home page of them at http://www.nyx.net/~gthompso/quine.htm


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Fri, 02 Jul 1999 21:27:49 -0600
From: dann <krutd@cadvision.com>
Subject: significant digits question!!
Message-Id: <377D8335.FC61D5D8@cadvision.com>

I'm just learning perl and I'm wondering if there is any way to only
output 3 digits (for example) instead of the variable with the most
digits 

example ( oreilly pi example ) 2 * 3.141592 * 12.5 

the answer will be 78.539816...I would like 78.5

thanks

dann


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

Date: Sat, 3 Jul 1999 00:01:51 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: significant digits question!!
Message-Id: <7lk04e$e87$1@plonk.apk.net>

As in any other language, you might multiply by 10, take the whole number
and then move the decimal back 1, or multiply by 100 and move decimal back 2
etc.

Jody

dann wrote in message <377D8335.FC61D5D8@cadvision.com>...
>I'm just learning perl and I'm wondering if there is any way to only
>output 3 digits (for example) instead of the variable with the most
>digits
>
>example ( oreilly pi example ) 2 * 3.141592 * 12.5
>
>the answer will be 78.539816...I would like 78.5
>
>thanks
>
>dann




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

Date: 03 Jul 1999 00:07:37 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: significant digits question!!
Message-Id: <x7emiq1ily.fsf@home.sysarch.com>

>>>>> "JF" == Jody Fedor <JFedor@datacom-css.com> writes:

  JF> As in any other language, you might multiply by 10, take the whole
  JF> number and then move the decimal back 1, or multiply by 100 and
  JF> move decimal back 2

1. please quote properly by putting your reply AFTER the quoted text.

  JF> dann wrote in message <377D8335.FC61D5D8@cadvision.com>...
  >> I'm just learning perl and I'm wondering if there is any way to only
  >> output 3 digits (for example) instead of the variable with the most
  >> digits
  >> 
  >> example ( oreilly pi example ) 2 * 3.141592 * 12.5
  >> 
  >> the answer will be 78.539816...I would like 78.5

2. sprintf "%.1f", $pi
is the standard perl way to do it. remember, this is perl, not any other
language.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
  "F**king Windows 98", said the general in South Park before shooting Bill. 


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

Date: Sat, 03 Jul 1999 04:27:56 GMT
From: sowmaster@juicepigs.com (Bob Trieger)
Subject: Re: significant digits question!!
Message-Id: <7lk3h4$1up$1@oak.prod.itd.earthlink.net>

[ courtesy cc sent by mail if address not munged ]
     
dann <krutd@cadvision.com> wrote:
>I'm just learning perl and I'm wondering if there is any way to only
>output 3 digits (for example) instead of the variable with the most
>digits 
>
>example ( oreilly pi example ) 2 * 3.141592 * 12.5 
>
>the answer will be 78.539816...I would like 78.5


Being new is no excuse for not reading the FAQs

From perlfaq4:
Does perl have a round function? What about ceil() and
floor()? Trig functions? 

For rounding to a certain number of digits, sprintf() or printf() is 
usually the easiest route. 

The POSIX module (part of the standard perl distribution) implements 
ceil(), floor(), and a number of other mathematical and trigonometric 
functions. 

In 5.000 to 5.003 Perls, trigonometry was done in the Math::Complex 
module. With 5.004, the Math::Trig module (part of the standard perl 
distribution) implements the trigonometric functions. Internally it uses 
the Math::Complex module and some functions can break out from the real 
axis into the complex plane, for example the inverse sine of 2. 

Rounding in financial applications can have serious implications, and 
the rounding method used should be specified precisely. In these cases, 
it probably pays not to trust whichever system rounding is being used by 
Perl, but to instead implement the rounding function you need yourself. 



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

Date: 3 Jul 1999 04:53:50 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: significant digits question!!
Message-Id: <slrn7nrnct.31h.abigail@alexandra.delanet.com>

dann (krutd@cadvision.com) wrote on MMCXXXII September MCMXCIII in
<URL:news:377D8335.FC61D5D8@cadvision.com>:
&& I'm just learning perl and I'm wondering if there is any way to only
&& output 3 digits (for example) instead of the variable with the most
&& digits 
&& 
&& example ( oreilly pi example ) 2 * 3.141592 * 12.5 
&& 
&& the answer will be 78.539816...I would like 78.5


print 78.5;


HTH. HAND.



Abigail
-- 
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} #  Yet Another silly JAPH by Abigail
sub A::FETCH     {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Sat, 3 Jul 1999 06:26:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: significant digits question!!
Message-Id: <igokl7.1a4.ln@magna.metronet.com>

dann (krutd@cadvision.com) wrote:

: the answer will be 78.539816...I would like 78.5


   perldoc -f sprintf


   $_ = 2 * 3.141592 * 12.5;
   my $oneplace = sprintf '%.1f', $_;
   print "$oneplace\n";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 03 Jul 1999 17:19:45 -0400
From: Steve Palincsar <palincss@his.com>
Subject: Re: significant digits question!!
Message-Id: <377E7E71.261F9CFD@his.com>

Abigail wrote:
> 
> dann (krutd@cadvision.com) wrote on MMCXXXII September MCMXCIII in
> <URL:news:377D8335.FC61D5D8@cadvision.com>:
> && I'm just learning perl and I'm wondering if there is any way to only
> && output 3 digits (for example) instead of the variable with the most
> && digits
> &&
> && example ( oreilly pi example ) 2 * 3.141592 * 12.5
> &&
> && the answer will be 78.539816...I would like 78.5
> 
> print 78.5;
> 
> HTH. HAND.
> 
> Abigail

Yeah, right.  Very helpful.  The thought never
occurred that 'dann' might not have heard of printf?


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

Date: 3 Jul 1999 18:23:39 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: significant digits question!!
Message-Id: <slrn7nt6r8.31h.abigail@alexandra.delanet.com>

Steve Palincsar (palincss@his.com) wrote on MMCXXXII September MCMXCIII
in <URL:news:377E7E71.261F9CFD@his.com>:
## Abigail wrote:
## > 
## > dann (krutd@cadvision.com) wrote on MMCXXXII September MCMXCIII in
## > <URL:news:377D8335.FC61D5D8@cadvision.com>:
## > && I'm just learning perl and I'm wondering if there is any way to only
## > && output 3 digits (for example) instead of the variable with the most
## > && digits
## > &&
## > && example ( oreilly pi example ) 2 * 3.141592 * 12.5
## > &&
## > && the answer will be 78.539816...I would like 78.5
## > 
## > print 78.5;
## > 
## > HTH. HAND.
## > 
## > Abigail
## 
## Yeah, right.  Very helpful.  The thought never
## occurred that 'dann' might not have heard of printf?


Oh yes. But that's why there's a faq, right?



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 4 Jul 1999 15:08:12 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: significant digits question!!
Message-Id: <7lntcs$404$1@gellyfish.btinternet.com>

On Sat, 3 Jul 1999 03:12:55 -0400 Jody Fedor wrote:
> 
> Uri Guttman wrote in message ...
>>>>>>> "JF" == Jody Fedor <JFedor@datacom-css.com> writes:
>>  >> I'm just learning perl and I'm wondering if there is any way to only
>>  >> output 3 digits (for example) instead of the variable with the most
>>  >> digits
>>  >>
>>  >> example ( oreilly pi example ) 2 * 3.141592 * 12.5
>>  >>
>>  >> the answer will be 78.539816...I would like 78.5
>>
>>2. sprintf "%.1f", $pi
>>is the standard perl way to do it. remember, this is perl, not any other
>>language.
>>
> 
> Are you assuming he only wants to display an answer significant to the first
> decimal?
> He might be using the answer to continue on to calculate something else and
> his variable
> would still be left with the long insignificant decimals.
> 

I think you misread Uri's post - sprintf doesnt *display* anything.

Of course the most succinct answer would be to refer the poster to
perlfaq4:


=head2 Does perl have a round function?  What about ceil() and floor()?  
       Trig functions?

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Mon, 05 Jul 1999 18:15:06 GMT
From: mchalyard@my-deja.com
Subject: Re: significant digits question!!
Message-Id: <7lqsn4$p0i$1@nnrp1.deja.com>

To round-off to 1 decimal place for printing use
   printf ("%3.1f",$var);
You'll still get more than 3 chars total if var is >= 100.0.
To round off into a new variable use
   $new = sprintf ("%3.1f",$old);

-  Dennis McNulty

In article <7lntcs$404$1@gellyfish.btinternet.com>,
  Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On Sat, 3 Jul 1999 03:12:55 -0400 Jody Fedor wrote:
> >
> > Uri Guttman wrote in message ...
> >>>>>>> "JF" == Jody Fedor <JFedor@datacom-css.com> writes:
> >>  >> I'm just learning perl and I'm wondering if there is any way
to only
> >>  >> output 3 digits (for example) instead of the variable with the
most
> >>  >> digits
> >>  >>
> >>  >> example ( oreilly pi example ) 2 * 3.141592 * 12.5
> >>  >>
> >>  >> the answer will be 78.539816...I would like 78.5
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Tue, 06 Jul 1999 15:41:35 -0400
From: Tim Kimball <kimball@stsci.edu>
To: dann <krutd@cadvision.com>
Subject: Re: significant digits question!!
Message-Id: <37825BEF.B6470A5E@stsci.edu>

dann wrote:
> 
> I'm just learning perl and I'm wondering if there is any way to only
> output 3 digits (for example) instead of the variable with the most
> digits
> 
> example ( oreilly pi example ) 2 * 3.141592 * 12.5
> 
> the answer will be 78.539816...I would like 78.5

Dann,

Take a look at the Math::SigFigs module on CPAN (in
modules/by-modules/Math/); it may be of some use.

As for the rest of you: Dann was not asking how to round off to one
decimal place. He was asking how to round off to three significant
figures. If you don't know the difference between those two statements,
then get yourself a freshman science textbook and find out (or read the
Math::SIGFIGS documentation).

-- tdk


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

Date: Sat, 3 Jul 1999 06:13:26 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: simple math problem
Message-Id: <6onkl7.m84.ln@magna.metronet.com>

Jeremiah and Veronica Adams (adams1015@worldnet.att.net) wrote:

: Can you tell me WHY this dosen't work?


   Yes, because it does not compile.

   Compilation is essential to "working"...


: $total=$in{'textfield2'}*$in{'textfield3};
                               ^         ^^
                               ^         ^^

: $adjective2=$in{'textfield'};
: $adjective3=$in{'textfield2'};
[snip]
: $total=$adjective2*$adjective3;
: print &PrintHeader;


   # see what values you are multiplying
   print "the product of '$adjective2' and '$adjective3' is '$total'\n";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 5 Jul 1999 19:20:13 GMT
From: "Alex" <alex@exbook.com>
Subject: Socket Programming
Message-Id: <01bec71b$67f338b0$258eb987@il0015jtampc>

Hi Everyone,

I have a program that running well in UNIX, I use 
the socket in my program, now, I want to port it to my
Windows NT IIS website (A virtual hosting website.),
The website only privide the perl compiler, but without 
the perl library. So which library file I need to place in
my cgi-bin directory in order to make the socket function
working OK?

What module do I need to include in the cgi-bin directory?

How to use the 'push' and 'use' command in this case?

I appreciate your help!

Thank you,
Alex



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

Date: 5 Jul 1999 18:29:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Socket Programming
Message-Id: <slrn7o2fta.h6v.abigail@alexandra.delanet.com>

Alex (alex@exbook.com) wrote on MMCXXXIV September MCMXCIII in
<URL:news:01bec71b$67f338b0$258eb987@il0015jtampc>:
@@ Hi Everyone,
@@ 
@@ I have a program that running well in UNIX, I use 
@@ the socket in my program, now, I want to port it to my
@@ Windows NT IIS website (A virtual hosting website.),
@@ The website only privide the perl compiler, but without 
@@ the perl library.

Without the "perl library", Perl doesn't run. Fix your installation
of Perl.

@@                   So which library file I need to place in
@@ my cgi-bin directory in order to make the socket function
@@ working OK?

None. Library files do not belong in the cgi-bin directory.

@@ What module do I need to include in the cgi-bin directory?

None. Modules do not belong in the cgi-bin directory.

@@ How to use the 'push' and 'use' command in this case?

In the same way as usual.


Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 3 Jul 1999 22:34:07 GMT
From: "Alex" <alex@exbook.com>
Subject: Re: Socket w/o Library
Message-Id: <01bec5a4$252df5b0$258eb987@il0015jtampc>


What module do I need to include in the cgi-bin directory?

-Alex

Free Textbook Idea : http://www.exbook.com

Alastair <alastair@calliope.demon.co.uk> wrote in article
<slrn7nqpfc.c5.alastair@calliope.demon.co.uk>...
> Alex <alex@exbook.com> wrote:
> >How to use the 'push' and 'use' command in this case?
> 
> Isn't that a frequently asked question?
> 
> perlfaq8 : How do I keep my own module/library directory?
> 
> 
> -- 
> 
> Alastair
> work  : alastair@psoft.co.uk
> home  : alastair@calliope.demon.co.uk
> 


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

Date: Tue, 6 Jul 1999 12:18:34 +0800
From: "Engr" <engr@t1.ima.com>
Subject: something similar to 'creat' in C
Message-Id: <7ls0f0$6vs$1@m5.att.net.hk>

Hi, I am new to Perl. I would like to know how can I creat a file in Perl so
that it fails if that file already exist in the system. This is something
like creat(..O_EXCL) in C.

Thanks in advance.




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

Date: Tue, 06 Jul 1999 04:37:33 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: something similar to 'creat' in C
Message-Id: <hKfg3.147$cO4.7124@news12.ispnews.com>

In article <7ls0f0$6vs$1@m5.att.net.hk>, Engr <engr@t1.ima.com> wrote:
>Hi, I am new to Perl. I would like to know how can I creat a file in Perl so
>that it fails if that file already exist in the system. This is something
>like creat(..O_EXCL) in C.

The perl sysopen() function takes flags like the POSIX C open() function. Use
the Fcntl module (or POSIX module) to import the values of the O_* constants.
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: Tue, 6 Jul 1999 14:38:51 +1000
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: something similar to 'creat' in C
Message-Id: <7ls160$3ia1@atbhp.corpmel.bhp.com.au>

See below

--
Ron Savage
Office (preferred): Savage.Ron.RS@bhp.com.au
Home: rpsavage@ozemail.com.au
http://www.ozemail.com.au/~rpsavage
Engr wrote in message <7ls0f0$6vs$1@m5.att.net.hk>...
>Hi, I am new to Perl. I would like to know how can I creat a file in Perl
so
>that it fails if that file already exist in the system. This is something
>like creat(..O_EXCL) in C.


Do you mean something like:

    my($fileName) = 'file.txt';
    if (-e $fileName)
    {
        print STDERR "$fileName exists\n";
        exit(1);
    }
    else
    {
        open(OUT, "> $fileName") || die("Can't open(> $fileName): $!");
        print OUT "Line 1\n";
        close(OUT);
    }


>
>Thanks in advance.
>
>




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

Date: Tue, 06 Jul 1999 04:51:45 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: something similar to 'creat' in C
Message-Id: <BXfg3.151$cO4.7336@news12.ispnews.com>

In article <7ls160$3ia1@atbhp.corpmel.bhp.com.au>,
Ron Savage <Savage.Ron.RS@bhp.com.au> wrote:
>See below

Aww, how cute, a guidepost warning us that this post is actually written in a
sensible order.

>Engr wrote in message <7ls0f0$6vs$1@m5.att.net.hk>...
>>Hi, I am new to Perl. I would like to know how can I creat a file in Perl
>so
>>that it fails if that file already exist in the system. This is something
>>like creat(..O_EXCL) in C.
>
>
>Do you mean something like:

[race condition snipped]

No. If you test for existence of a file and then create it, there is a small
period of time in between those two actions, during which the file might be
created by some other process. You would then clobber that new file. O_EXCL
is an atomic operation. Either the file will be created or the open will
fail. The operating system will not allow any clobbering to take place.
-- 
Alan Curry    |Declaration of   | _../\. ./\.._     ____.    ____.
pacman@cqc.com|bigotries (should| [    | |    ]    /    _>  /    _>
--------------+save some time): |  \__/   \__/     \___:    \___:
 Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman


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

Date: 6 Jul 1999 05:09:55 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: something similar to 'creat' in C
Message-Id: <7ls333$28f$1@lublin.zrz.tu-berlin.de>

Engr <engr@t1.ima.com> wrote in comp.lang.perl.misc:
>Hi, I am new to Perl. I would like to know how can I creat a file in Perl so
>that it fails if that file already exist in the system. This is something
>like creat(..O_EXCL) in C.

Yes.  Run the following twice to see the difference:

use FileHandle;

$fh = new FileHandle '/tmp/x', O_CREAT|O_EXCL;

if ( $fh ) {
  print "New file\n";
} else {
  print "File existed\n"
}

Anno


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

Date: Tue, 6 Jul 1999 15:40:21 +0800
From: "Engr" <engr@t1.ima.com>
Subject: Re: something similar to 'creat' in C
Message-Id: <7lsc9m$558$1@m5.att.net.hk>

sysopen works for me! Thanks for all your help.


Alan Curry <pacman@defiant.cqc.com> wrote in message
news:BXfg3.151$cO4.7336@news12.ispnews.com...
> In article <7ls160$3ia1@atbhp.corpmel.bhp.com.au>,
> Ron Savage <Savage.Ron.RS@bhp.com.au> wrote:
> >See below





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

Date: Tue, 06 Jul 1999 14:52:56 -0400
From: Doug Seay <dms@rtp-bosch.com>
Subject: Re: something similar to 'creat' in C
Message-Id: <37825088.37650D4@rtp-bosch.com>

Alan Curry wrote:
>
> No. If you test for existence of a file and then create it, there is a small
> period of time in between those two actions, during which the file might be
> created by some other process. You would then clobber that new file. O_EXCL
> is an atomic operation. Either the file will be created or the open will
> fail. The operating system will not allow any clobbering to take place.

I may be forgetting stuff in my old age, but isn't that atomic only if
the filesystem is local?  Doesn't O_EXCL have potential problems across
NFS?

- doug


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


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