[6920] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 545 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 30 18:07:51 1997

Date: Fri, 30 May 97 15:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 30 May 1997     Volume: 8 Number: 545

Today's topics:
     Re: any editor for perl?--any editor written in Perl? (Charles F. Randall)
     Re: any editor for perl?--any editor written in Perl? <merlyn@stonehenge.com>
     decimal to binary converter (Mike East)
     Re: Desparately Seeking Assistance - Numbers Calculatio (Shawn Halpenny)
     Re: get the users login name (Abigail)
     GET THIS WHILE U CAN! 39e19fty@fia.net
     Re: getting started... (M Kent Dawson)
     Re: Good Perl Tutorial with exercises ?? (Nathan V. Patwardhan)
     Help: Accessing Package from variable (Eric Brown)
     Looking for a Perl Programmer (N1Graphics)
     Re: OS/2 : Backticks causing runtime crash (Ilya Zakharevich)
     Re: OS/2 : Backticks causing runtime crash (Ilya Zakharevich)
     Re: Perl 5.002 socket call on DEC OSF/1   -    HELP (M Kent Dawson)
     Perl poems? (Budi Rahardjo)
     perldb on WIndows NT (Yuri Shtil)
     Please help with IPC problem (Thomas Rock)
     Problem compiling Perl5.003 under SCO5 (Poul Kornmod)
     Processing many form fields gpylant@cc.memphis.edu
     Re: Read a file to $wholefile (Honza Pazdziora)
     Re: Read a file to $wholefile (Paul D. Smith)
     Re: reading hashes from a file (Bruce Schiller)
     Re: Standalone web database for Perl? (Bruce Schiller)
     this example won't work..why not? (Patrick O'Leary)
     Re: this example won't work..why not? (Nathan V. Patwardhan)
     Why 10000 + 0.63 = 10000.6299999...? <tian@esd.sgi.com>
     Re: Why 10000 + 0.63 = 10000.6299999...? (Craig Berry)
     Re: Why is ("a" == 0) true? (Abigail)
     WinNT Build 306: %var = {}; fails (Charles Henkel)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 30 May 1997 13:57:05 -0600
From: crandall@free.click-n-call.com (Charles F. Randall)
Subject: Re: any editor for perl?--any editor written in Perl?
Message-Id: <5mnbeh$8em$1@free.click-n-call.com>

[Note: CC of this article mailed to poster, and crossposted to comp.editors]

O'Shaughnessy Evans <shaug@callamer.com> wrote:
>> I haven't seen it, but I hear that there's a version of vi which uses
>> embedded Perl, so you can use Perl code to edit your files. I've gotta try
>> that. :-)
>
>Wow, that's a teaser!  Sooo, has anybody else heard of this -- if so,
>howzabout a URL?

I think that he's referring to nvi. There's a link at "The Perl Oasis"
that refers to it,

	http://www.oasis.leo.org/perl/misc/00-index.html

The nvi home appears to be at,

	http://mongoose.bostic.com/vi/


-Randy
-- 
Charles F. Randall             With Click-n-Call, you can put a button
crandall@click-n-call.com      on a Web page that can initiate an H.323 
http://www.click-n-call.com/   Internet phone call to a plain old telephone.



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

Date: 30 May 1997 14:31:13 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: shaug@callamer.com (O'Shaughnessy Evans)
Subject: Re: any editor for perl?--any editor written in Perl?
Message-Id: <8cu3jkve8u.fsf@gadget.cscaper.com>

>>>>> "O'Shaughnessy" == O'Shaughnessy Evans <shaug@callamer.com> writes:

>> I haven't seen it, but I hear that there's a version of vi which uses
>> embedded Perl, so you can use Perl code to edit your files. I've gotta try
>> that. :-)

O'Shaughnessy> Wow, that's a teaser!  Sooo, has anybody else heard of this -- if so,
O'Shaughnessy> howzabout a URL?

It wouldn't be that much of a surprise if you had actually been
looking through the CPAN from time to time as we "goo roos" keep
tellin' y'all to do. :-)

It's been in the CPAN for quite a long time...

	http://www.perl.com/CPAN/src/misc/nvi.tar.gz

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 458 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 30 May 1997 17:52:11 -0400
From: gt6242b@prism.gatech.edu (Mike East)
Subject: decimal to binary converter
Message-Id: <5mni6b$8tu@acmex.gatech.edu>

Does anyone know how to convert decimal numbers to binary numbers in
Perl???

Thanks
Mike
-- 
----------------------------------------------------------------------------- 
   Mike East                       |       Georgia Institute of Technology
   gt6242b@acme.gatech.edu         |       Computer Engineering


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

Date: Fri, 30 May 1997 20:09:46 GMT
From: rsh@cci.com (Shawn Halpenny)
To: psychic@globalserve.net (Earl Curley)
Subject: Re: Desparately Seeking Assistance - Numbers Calculation
Message-Id: <EB0G0B.4KI@sunsrvr6.cci.com>

[ Posted and CC'd as requested ]

>From article:  <psychic-3005970045210001@dialin1756.globalserve.net>
       Author:  psychic@globalserve.net (Earl Curley) {EC}
         Date:  Fri, 30 May 1997 01:45:19 GMT

EC> Boy, do I need a hand.  I'm in a real bind.  I have been trying to
EC> calculate the following with no success.
EC> 
EC> I need to reduce two number down to no higher than 10 or -10.  As an
EC> example if one of the numbers is 178, the number has to be reduced as
EC> such.  178 - 1 + 7 + 8= 16 =1 + 6= 7  the second number simply is the
EC> opposite direction -178 so therefore it would be:  -1 + -7 + -8 = -16
EC> = -1 >+ -6 = -7 .  The high number is a maximum of 210.  
EC> 
EC> If there is a kind soul here, I'd be indebted for life if you could
EC> assist me.	I've read every PERL FAQ and have the whole darn book on
EC> PERL and I'll be darned I can't find how to script this.  
EC> 
EC> I would appreciate help via e-mail since I'm on a time limit here.
EC> 
EC> Thanks in advance.
EC> 

Provided I understood you correctly, I think this will do the trick:

#!/usr/local/bin/perl

Usage() unless ($ARGV[0] =~ /^\d+$/ && $ARGV[0] >= -210 && $ARGV[0] <= 210);

my $num = abs($ARGV[0]);
my $total = 0;

while ($num > 10)
{
	$num =~ s/(.)/$total += $1/eg;
	$num = $total;
	$total = 0;
}

print "The two numbers:  $num, -$num\n";

sub Usage
{
	die <<EOF
Usage:  $0 <num>
  where <num> is a decimal number between -210 and 210, inclusive.
EOF
}

# cut here

--
Shawn Halpenny

"You can't buy the necessities of life with cookies"
                                    - "Edward Scissorhands"


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

Date: Fri, 30 May 1997 18:14:24 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: get the users login name
Message-Id: <EB0Ao0.K29@nonexistent.com>

On Fri, 30 May 1997 10:57:09 +0200, Edwin Gijsbregts
(gijsbree@se.bel.alcatel.be) wrote in comp.lang.perl.misc
<URL: news:338E9665.6C2F@se.bel.alcatel.be>:
++ 
++ is there a way to retrieve the login name of the user who invoked
++ a perl-script  ? (btw. I am new to perl)

perl -lwe 'print scalar getpwuid $>;'



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: 30 May 1997 20:48:22 GMT
From: 39e19fty@fia.net
Subject: GET THIS WHILE U CAN!
Message-Id: <5mneem$s2i@news1-alterdial.uu.net>


6 Million Email Addresses FREE!

   Hottest Bulk Stealth Software Available
        Send up to 1 MILLION per Hour!
*** FREE 10 Day FULLY Functional Program ***

DOWNLOAD @ http://www.mary-world.com/stealth

Bulk Email Web Space and Email Boxes Available
http://www.mary-world.com/webspace


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

Date: Fri, 30 May 1997 18:49:57 GMT
From: kent.dawson@atl.bluecross.ca (M Kent Dawson)
Subject: Re: getting started...
Message-Id: <338f1da0.263628477@news>

On 18 May 1997 15:15:33 GMT, "Arathena Sprankle" <marien@goodnet.com>
wrote:

>#! /perl/bin/perl
>print "Hello, world!";

Just FYI:

"#!" is interpreted by most, if not all, unix shells to provide the
path to the shell in which to run the script.

For example, 

  #!/bin/ksh
  print "Hello\n"

Run under a unix shell,  this script would first invoke a Korne shell
(/bin/ksh), and then run the rest of the script in that shell.

Under unix, this allows you to just type the scriptname at the shell
prompt instead of 'perl scriptname'.  Its a nice feature.

In the case of Win95 and most other non-unix platforms,  the first
line will do absolutely nothing.  It is not necessary at all as it
will just be treated as a comment.

>
>The file is kept in c:\hello.pl
>perl.exe is in c:\perl\bin\perl.exe
>
>when I type "perl c:\hello.pl"
>I get an error "syntax error at - line 3, near "c:"
>

Most likely, the '\' in c:\hello.pl is causing a problem.  I'm no Perl
or Win95 expert, but try double quoting the filespec for the script:

  perl "c:\hello.pl"

Kent...


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

Date: 30 May 1997 19:28:36 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Good Perl Tutorial with exercises ??
Message-Id: <5mn9p4$698@fridge-nf0.shore.net>

Jim Garrison (jhg@austx.tandem.com) wrote:
: Has anyone written a good Perl tutorial that has
: well-written, meaningful exercises?  

Where have you seen a bad tutorial with poorly-written, meaningless 
exercises that caused you to ask?  :-)

There's always the Perl manpages to start with.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: 30 May 1997 20:37:09 GMT
From: ericb@mathworks.com (Eric Brown)
Subject: Help: Accessing Package from variable
Message-Id: <5mndpl$g1l$1@turing.mathworks.com>

In the following code I would like to access "@registry" in the package
specified in $type (i.e. if $type eq "Piece" it would access 
"@Piece::registry").

sub registry {
    my $self = shift;
    my $type=ref($self) || $self;
    my @registry;

    @registry = @$type::registry; # This line is failing

    return @registry; # return the correct one (for Subpiece etc.)
}

In this example perl creates a package "type".  I also tried:
	@registry = @$type::registry;
which errored out.

Is there any way to do this ?

Thanks,
  -ericb
-- 
Eric Brown        |ericb@mathworks.com | I will consider Deep Blue
Tools Engineer    |(508)-647-7352      | intelligent when it tells us it
The Mathworks Inc |www.mathworks.com   | would rather go see a sunset.
                                            A caller on "The Connection"


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

Date: 30 May 1997 19:37:27 GMT
From: n1graphics@aol.com (N1Graphics)
Subject: Looking for a Perl Programmer
Message-Id: <19970530193700.PAA02311@ladder02.news.aol.com>

I am looking to pay someone a modest amount of money to write a PERL/CGI
for Perl 5.003. 

Here's my problem:

I have a form in a frame. A user fills out that part of the form and
clicks next. The data needs to be submitted to a Perl script that will
pass the data back to the browser in a secure environment (I think I can
do this by putting the script on a secure server and linking the ACTION to
it) as a confirmation page. On the bottom of this confirmation page
underneath this display of data I have some HTML already written that
needs to be displayed and includes fields to enter shipping and credit
card information. Now the submit button on the bottom of this confirmation
page has to e-mail the contents of this confirmation page via a CGI script
which somebody sent me the code already (it's on the bottom of this
message). This second CGI (or maybe it can be done with only one?) first
converts all the +'s and %'s to regular format and is then e-mailed. A
thank you page then needs to be displayed. 

This is what I need and I would appreciate if you can contact me as soon
as possible because this part of the site is critical and the customer
wants it up in a few weeks. Again, I'm willing to pay a modest fee for
your services but I can't go too high because the customer will start
arguing with me that's it's too expensive and he won't want to pay for it.
Then I'm up the creek with no paddle (I've already finished the content of
the site -- a catalog). 

Please e-mail me at n1graphics@aol.com as I don't read this group to
often.

Thank you for taking your time to read this message,

Akiva Bergstrom
#1 Graphics Design Company
n1graphics@aol.com


CGI SCRIPT CODE
===============

#!/usr/bin/perl

#parsing routine
# Get the input
read(STDIN, $buf, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@vars = split(/&/, $buf);

foreach $var (@vars) {
   ($name, $value) = split(/=/, $var);

   # Un-Webify plus signs and %-encoding
   $value =~ tr/+/ /;
   $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
   $value =~ s/<!--(.|\n)*-->//g;
   $value =~ s/<([^>]|\n)*>//g;         # get rid of html codes
   #put it all in the %FORM hash
   $FORM{$name} = $value;
 .

######################################
#Specify the sendmail location
#Usually Sys V is /usr/lib, BSD is /usr/sbin
$sendmail="/usr/lib/sendmail";

open(MAIL, "|$sendmail'";
#Insert your email address here, don't forget the backslash
print MAIL "From: youremail\@domain.com\n";
print MAIL "To: $FORM{'EMAIL'}\n";
print MAIL "Subject: Add your subject here\n";

print MAIL <<"_END_";

###Insert your message here

#leave this here
__END__

#send off the message
close(MAIL);

#########################################
#Now print out the "thank you" web page
print "Content-type:  text/html\n\n";
print <<"_END_";

#put the HTML here

#leave this here
_END_

#done!
exit;


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

Date: 30 May 1997 20:50:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: OS/2 : Backticks causing runtime crash
Message-Id: <5mneid$f4e$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Pol GATILLE
<pgatille@online.fr>],
who wrote in article <339065f2.2938586@snews.zippo.com>:

> Backticks spawns sh shell (from env PERL_SH_DIR) 

This is no longer true (from sometime close to 5.003_10).  sh.exe is
used only if metachars are found - even inside backticks and
open(,"|").

The problem of this guy was that he was using the old build 5.003_05,
which had PERL_SH_DIR misdocumented as PERL_SHPATH (and the same wrong
name was wired into binary installer).

Ilya



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

Date: 30 May 1997 20:53:06 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: OS/2 : Backticks causing runtime crash
Message-Id: <5mneni$f4e$2@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Koos Pol
<koos_pol@nl.compuware.com.NO_JUNK_MAIL>],
who wrote in article <5mm46n$pm@news.nl.compuware.com>:
>   print "Hey";
>   `helloworld.cmd`;
> 
> results in:
>   Hey

> From the window title I see that helloworld.cmd is being
> executed, but the output seems to be  going nowhere.

You still did not put Perl docs into your bookbag...

Ilya




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

Date: Fri, 30 May 1997 18:26:46 GMT
From: kent.dawson@atl.bluecross.ca (M Kent Dawson)
Subject: Re: Perl 5.002 socket call on DEC OSF/1   -    HELP
Message-Id: <338f1b7f.263083233@news>

On Wed, 21 May 1997 19:41:56 +1000, loi huynh <lhuynh@newscorp.com.au>
wrote:

>I am running Perl 5.002 on a DEC 2100 with OSF/1 v3.2.  I compiled
>successfully compiled Perl using DEC C and ran h2ph without any error. 
>However something didn't seem right when I use socket call to try the
>following client/server sample below.
>
>Scalar found where operator expected at (eval 58) line 3, near "*($p"
>        (Missing operator before $p?)
>


I tried your client example and got the same thing on an HP box using
HP C and Perl 5.003.  

Perhaps a bug in h2ph?

I don't know; I don't do this kind of stuff very often.  I'd be
interested in the answer, though.

Kent Dawson
PCS Support Analyst
Blue Cross of Atlantic Canada


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

Date: 30 May 1997 17:06:06 GMT
From: rahard@wine.ee.umanitoba.ca (Budi Rahardjo)
Subject: Perl poems?
Message-Id: <5mn1du$hbr$1@canopus.cc.umanitoba.ca>

Long time ago I received the following perl script.
It was runnable (with perl4). Some sort of animation ;-)
Unfortunately it doesn't work with perl5.
I don't know how to get in contact with the author.
Any quick fix?

-- 
Budi Rahardjo <rahard@ee.umanitoba.ca> Just Another Perl Hacker
VLSI,Computer Networks,Operating Systems,Programming Languages,
Formal Methods,NCs,WebTV,UNIX,System Design,Telecommunications.

----- perl peom -----
#!/usr/local/bin/perl

# Ode to My Thesis, a Perl Poem

<<birth                                                                 ;
G
   r
      o
         w
            t
               h
re-
birth

seek                                                                    (
        enlightenment, knowledge, experience                            );

goto MIT;

sleep "too little", study $a_lot,
wait, then                                                              .
        "B.S.",

leave.  then, return to                                                 ;
                MIT                                                     :
now,
        $done = 'a Ph.D.                                                ">&2';

warn pop @mom, "    I'll be here a while                                \n";

study, study, do study;

push                                                                    (
        myself, computers, experiments                                  ),

read                                                                    (
        data, references, books                                         ),

study,
        write,
                write,
                        write,

do more if time                                                         ;
redo if $errors                                                         ;

do more_work if questions_remain                                        ;

$all_are_answered?  yes.

now :
        write,
        chop if length $too_great                                       ;

format                                                                  =
          Thesis
 .
                        tell all,
                        done, finally                                   .
                        now, do rest                                    .

shout.
        and                                                             .
                hear                                                    .
                        it                                              .
                                `echo                                   "

                Now I am $done`

# Craig Counterman
# April 27, 1991



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

Date: Fri, 30 May 1997 19:49:46 GMT
From: shtil@netcom.com (Yuri Shtil)
Subject: perldb on WIndows NT
Message-Id: <shtilEB0F2y.GLB@netcom.com>

I tried perdb from emacs and emacs froze. I had to kill perl.exe from
the task manager.

    Any idea ?






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

Date: 30 May 1997 20:43:26 GMT
From: thomasr@xtek.com (Thomas Rock)
Subject: Please help with IPC problem
Message-Id: <5mne5e$t80$1@news10.gte.net>

Hi,

I am just getting my feet wet with IPC and Internet clients and servers.
So, I started experimenting with the example TCP client and server code
from the perlipc doc.

When I run it, from the server I receive:

   % server.pm
   server.pm 707: Server started on port 2345 at Fri May 30 12:59:16 1997
   server.pm 707: Connection from localhost [ 127.0.0.1 ] at port 1151 at 
Fri May 30 12:59:20 1997
   server.pm 707: begat 709 at Fri May 30 12:59:20 1997
   server.pm 707: reaped 709 with exit 256 at Fri May 30 12:59:20 1997
   server.pm 707: Connection from localhost [ 127.0.0.1 ] at port 1157 at 
Fri May 30 12:59:22 1997
   server.pm 707: begat 711 at Fri May 30 12:59:22 1997
   server.pm 707: reaped 711 with exit 256 at Fri May 30 12:59:22 1997
   server.pm 707: Connection from localhost [ 127.0.0.1 ] at port 1163 at 
Fri May 30 12:59:54 1997
   server.pm 707: begat 713 at Fri May 30 12:59:54 1997
   server.pm 707: reaped 713 with exit 256 at Fri May 30 12:59:54 1997


That seems all well and good. However, from the client, all I receive is:

   % client.pm
   % client.pm
   % client.pm
   %
   
   
Nothing! I should get a hello message and a fortune. In the spawned 
annonymous  subroutine I put print statements to STDERR duplicating the 
prints to STDOUT. That worked fine so I know the anonymous sub is 
running, but the the client seems not to be picking up the output from 
the server.

Any ideas as to the problem?


Also, how would I send info from the client to the server? I tried doing 
a print SOCK from the client and a $line = <STDIN> in the server, but the
server didn't receive anything.


Thanks.
-- 
Thomas Rock
X-Tek Corporation
thomas@x-tekcorp.com


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

Date: Tue, 27 May 1997 09:55:57 GMT
From: pbk@cphzt.sasintern.dk (Poul Kornmod)
Subject: Problem compiling Perl5.003 under SCO5
Message-Id: <338aad3e.1343124@news.dknet.dk>

Dear All,

I've a small problem compiling Perl5.003 under SCO5. The machine is a
compaq LTE5400 pentium. The error message appears when it launches the
command during "make".

---
cc   -o miniperl miniperlmain.o libperl.a -lintl -lsocket -lnsl -lndbm
-ldbm -lld -lm -lc -lcrypt -lPW -lx 
        ./miniperl configpm tmp
        sh mv-if-diff tmp lib/Config.pm
        ./miniperl -Ilib pod/pod2html.PL
*** Termination code 139 (bu21)
---

Does enybody have an idea how to get by this? I'm deptly greatfull and
highly appreciate all help and answers.

Poul


--------------------------------------------------------------------------------------------------------------
Poul Kornmod			Radisson SAS Hotels Worldwide
Systems Analyst			IT-Department (CPHZT)
pbk@cphzt.rdsas.com		70 Amager Boulevard
Telephone: +45 3341 1022	DK-2300 Copenhagen S. 	
Telefax:      +45 3341 1010	Denmark


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

Date: 30 May 97 15:32:23 -0500
From: gpylant@cc.memphis.edu
Subject: Processing many form fields
Message-Id: <1997May30.153223@admin1.memphis.edu>

I am using odbc, MSaccess, and Perl to process a form with 30 or so input 
fields.  Is there any way to use subscripts for the field names on the server
side instead of the usual input{'field1'}, input{'field2'} etc.?
It would be nice if there was something like input{name}[1] or whatever.
Thanks in advance....

Gary Pylant


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

Date: Fri, 30 May 1997 18:55:34 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Read a file to $wholefile
Message-Id: <adelton.865018534@aisa.fi.muni.cz>

Lauri Laakso <lauri@nettipaja.clinet.fi> writes:

> Ho I can read whole $message.dat file to $wholefile, I am using it
> when I send multiple emails.

$/ = undef;
open FILE, $message.dat or die "Error reading $message.dat: $!\n";
$wholefile = <FILE>;
close FILE;

__END__

should work just fine.

Hope this helps!

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 30 May 1997 15:04:25 -0400
From: psmith@baynetworks.com (Paul D. Smith)
To: Lauri Laakso <lauri@nettipaja.clinet.fi>
Subject: Re: Read a file to $wholefile
Message-Id: <p5lo4wg4sm.fsf@baynetworks.com>

%% Lauri Laakso <lauri@nettipaja.clinet.fi> writes:

  ll> Ho I can read whole $message.dat file to $wholefile, I am using it
  ll> when I send multiple emails.

Try:

  open(FH, "<$message.dat") or die "Can't open $message.dat: $!\n";

  undef $/;
  $wholefile = <FH>;
  $/ = "\n";

  close(FH);

Note that the perl manual has many examples, including exactly this type
of thing.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@baynetworks.com>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
     These are my opinions--Bay Networks takes no responsibility for them.


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

Date: 30 May 1997 20:04:14 GMT
From: brew1@voicenet.com (Bruce Schiller)
Subject: Re: reading hashes from a file
Message-Id: <5mnbru$r4e$1@news3.voicenet.com>

Randall S. Willcox (rswillco@acs.ucalgary.ca) wrote:

: I was hoping it would be something as simple as getting the correct
: hidden field value & then doing something like this:

: open (INFILE, "foo.txt");

: %01 = %answers;

: but it appears to be a little more complicated.

What I do is:

require "foo.txt";

and in foo.txt:

%answers = (...insert your own stuff here...
);

# so the required file returns true
1;

# end of foo.txt file

Then you just go ahead and use %answers like the hash it is.  (fr'instance

%01 = %answers; 

as you said. 

I'm doing this in a couple of places.  My current problem is in one case
I'm doing it and it worked a few days ago, but now I made a few minor
changes and it stopped working!  Trouble is it still works in the other
places I do it, and I don't see any difference!!!  (Of course I don't have
the exact code that worked anymore, having 'updated' it). 

Probably a case of temporary blindness.

later..... brew
--
 ==========================================================================
                  Strange Brew   (brew1@voicenet.com)
     Check out my Musician's Online Database Exchange (The MODE Pages)
                        http://www.TheMode.com
 ==========================================================================



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

Date: 30 May 1997 20:17:53 GMT
From: brew1@voicenet.com (Bruce Schiller)
Subject: Re: Standalone web database for Perl?
Message-Id: <5mnclh$r4e$2@news3.voicenet.com>

Hidden (guess@somewhere.com) wrote:
: depending on how large the Database file will be you may not even need a
: Database management system.  Perl can work with text files with the fields
: on separate lines and the records separated with a blank line.

: Name: B J'S CAFE
: Address: 207 S RALEIGH ST
: City: ANGIER
: State: NC
: Zip Code: 27501
: Telephone: (919) 639-0788

Gary.....

Check out Randall's Tiny Database article he wrote for his Unix World
column about two year's ago.  In it he shows sample code how to parse out
the records (set up as above) and sort them various ways.  With a little
work you can make it do anything you want. 

It's on his website, along with the rest of the very informative Unix
World articles, but you'll have to search a little since I don't have the
url at the moment.

later..... 

brew
--
 ==========================================================================
                  Strange Brew   (brew1@voicenet.com)
     Check out my Musician's Online Database Exchange (The MODE Pages)
                        http://www.TheMode.com
 ==========================================================================



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

Date: 30 May 1997 20:39:00 GMT
From: barno@hoi.corp.sun.com (Patrick O'Leary)
Subject: this example won't work..why not?
Message-Id: <5mndt4$e45@jethro.Corp.Sun.COM>

This is an example I cut and pasted from the Sprite.pm

The error I get is:  Can't find string terminator "End_of_Query" anywhere before EOF at testDb.pl line 10.

Any ideas?

TIA,

Patrick

#!/usr/local/lib/perl5/perl
    use Sprite;
    $rdb = new Sprite ();
    # Sets the read delimiter to a comma (,) character. The delimiter
    # is not limited to one character; you can have a string, or even
    # a regexp.
    $rdb->set_delimiter ("Read", ",");
    # Retrieves all records that match the criteria.

    @data = $rdb->sql (<<End_of_Query);
        select * from nba
            where (Points > 25)
    End_of_Query
    # Close the database and destroy the database object (i.e $rdb).
    # Since we did not pass a argument to this function, the data
    # is not updated in any manner.
    $rdb->close ();
    # The first element of the array indicates the status.
    $status = shift (@data);
    $no_records = scalar (@data);
    if (!$status) {
        die "Sprite database error. Check your query!", "\n";
    } elsif (!$no_records) {
        print "There are no records that match your criteria!", "\n";
        exit (0);
    } else {
        print "Here are the records that match your criteria: ", "\n";
        # The database returns a record where each field is
        # separated by the "\0" character.
        foreach $record (@data) {
            $record =~ s/\0/,/g;
            print $record, "\n";
        }
    }






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

Date: 30 May 1997 21:21:19 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: this example won't work..why not?
Message-Id: <5mngcf$dd8@fridge-nf0.shore.net>

Patrick O'Leary (barno@hoi.corp.sun.com) wrote:

: The error I get is:  Can't find string terminator "End_of_Query" anywhere before EOF at testDb.pl line 10.

If your program is indented as it appears, "here docs" MUST be indented like:

print <<FOO;

stuff goes here

FOO

where the end FOO *must* start at the zero'th column of your editor.  The 
indentation before the end doc shouldn't matter.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Fri, 30 May 1997 12:24:36 -0700
From: Tian Chi <tian@esd.sgi.com>
Subject: Why 10000 + 0.63 = 10000.6299999...?
Message-Id: <338F2974.28CC@esd.sgi.com>

I was testing the following Perl script, 
but got a wrong result? Why is that?

#!/bin/perl

$aaa = 0.63;
$bbb = 10000;
$ccc = $aaa + $bbb;

print "aaa = ", $aaa, "\n";
print "bbb = ", $bbb, "\n";
print "ccc = ", $ccc, "\n";

The result is

aaa = 0.63
bbb = 10000
ccc = 10000.629999999999

Any help would be appreciated.

-- 
-Tian


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

Date: 30 May 1997 21:35:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Why 10000 + 0.63 = 10000.6299999...?
Message-Id: <5mnh7r$9f4$1@marina.cinenet.net>

Tian Chi (tian@esd.sgi.com) wrote:
: I was testing the following Perl script, 
: but got a wrong result? Why is that?
: 
: $aaa = 0.63;
: $bbb = 10000;
: $ccc = $aaa + $bbb;
: 
[code to print these snipped]
: 
: The result is
: 
: aaa = 0.63
: bbb = 10000
: ccc = 10000.629999999999

Floating-point numbers cannot in general be represented exactly in the 
fixed bit-width of a storage location.  Certain special cases can be; 
other numbers are represented by the closest available approximation 
which has an exact binary representation in whatever FP scheme your 
machine/OS/language are using.

Remember that FP numbers are represented internally as a base part and an
exponent part.  When adding two numbers of widely differing magnitude, the
exponent of the smaller number must be 'scaled up' to the same exponent as
the larger number to which it's being added (this is actually an
oversimplification, but that's the idea).  In the process, the base-part 
bits get shifted one position right for each increase in the 
(power-of-two) exponent.  Since there are a limited number of base bits, 
less-significant base bits get 'lost' off the right end.  As a result, 
the value actually added becomes a worse approximation of the 'real' 
original value.

If you add a tiny number to a huge number, the tiny number will utterly 
disappear, having been shifted into oblivion.  Try

  print(1e19 + 1);

for an example.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 30 May 1997 17:56:38 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Why is ("a" == 0) true?
Message-Id: <EB09uF.J63@nonexistent.com>

On Thu, 29 May 1997 23:13:36 -0700, Tom Phoenix (rootbeer@teleport.com)
wrote in comp.lang.perl.misc
<URL: news:Pine.GSO.3.96.970529231243.21066F-100000@kelly.teleport.com>:
++ On 29 May 1997 dchen@interport.net wrote:
++ 
++ > The following perl behavior baffles me:
++ > 
++ > perl -e 'if("a" == 0) { print "wow" }'
++ > Output is : wow
++ 
++ The comparison operator you have there compares numbers. What other number
++ would you have "a" be? :-)
++ 
++ If you want to compare strings, use cmp. Hope this helps!


Real fun is:
#!/usr/local/bin/perl -w
 
use strict;
 
my $foo =  0.0;
my $bar = "0.0";
 
if ($foo) {print "Foo is TRUE\n";} else {print "Foo is FALSE\n";}
if ($bar) {print "Bar is TRUE\n";} else {print "Bar is FALSE\n";}
 
print "Foo is Bar\n" if $foo == $bar;
 
__END__
Foo is FALSE
Bar is TRUE
Foo is Bar


I was once boggled by the division by zero error I got on:
$avg = $total / ($time || 0.01);
untill I realized I got $time by doing a match for '\d+(\.\d*)?'



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: Wed, 28 May 1997 14:41:15 GMT
From: csh@henktech.com.REMOVE (Charles Henkel)
Subject: WinNT Build 306: %var = {}; fails
Message-Id: <338c4334.157973500@news.avana.net>

Context:
	WinNT 4.0 SP3
	Perl 5.003 build 306 (binaries from activeware)
	
Problem:

I sometimes initialize my hashes to the null hash before using them:

%hash = {};

This is giving me the following error under 5.003 build 306:

F:\BOC\uds>perl -e "%hash = {};"
Odd number of elements in hash list at -e line 1.

What's up with that?


Charles S. Henkel
Henkel Technical Computing
P.O. Box 921446
Norcross, GA  30092
csh@henktech.com


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 545
*************************************

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