[17772] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5192 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 24 03:05:37 2000

Date: Sun, 24 Dec 2000 00:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977645110-v9-i5192@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 24 Dec 2000     Volume: 9 Number: 5192

Today's topics:
        Argument isn't numeric and Win32::API <bjoern@hoehrmann.de>
    Re: Argument isn't numeric and Win32::API <rick.delaney@home.com>
    Re: Contribute scripts ? (delete duplicate lines) (Martien Verbruggen)
    Re: Contribute scripts ? (delete duplicate lines) <uri@sysarch.com>
    Re: Contribute scripts ? (delete duplicate lines) <tony_curtis32@yahoo.com>
    Re: Contribute scripts ? (delete duplicate lines) (Martien Verbruggen)
        cookie accepted or not ? vthnts@hotmail.com
    Re: cookie accepted or not ? <rick.delaney@home.com>
    Re: DBIProxy question <loy_x@yahoo.com>
    Re: DBIProxy question <loy_x@yahoo.com>
    Re: FAQ asking madness (was Re: Simple REGEX question) <rick.delaney@home.com>
    Re: file size - outside url? (Martien Verbruggen)
    Re: Help with SSI Parser for html pages. <bwalton@rochester.rr.com>
    Re: Help with SSI Parser for html pages. <Jodyman@usa.net>
    Re: Help: modulus problem, docs confusing (Chris Fedde)
    Re: Help: modulus problem, docs confusing (Chris Fedde)
    Re: infinite loop (Garry Williams)
        my simple perl application didn't work <peter.cch@excite.com>
    Re: Newbie but serious - Problems reading file from mul <simonis@myself.com>
        Perl's BigInts/BigFloats <rwan@cs.mu.OZ.AU>
    Re: Perl's BigInts/BigFloats <bwalton@rochester.rr.com>
    Re: problem with awk in perl script <monty@primenet.com>
    Re: problem with awk in perl script (Garry Williams)
    Re: problem with awk in perl script <you.will.always.find.him.in.the.kitchen@parties>
    Re: PWS - perl (ATTN: cwrites) (cwrites)
    Re: use strict (do I have enough hair to use it?) <uri@sysarch.com>
    Re: use strict (do I have enough hair to use it?) <pat@sluggo.org>
    Re: use strict (do I have enough hair to use it?) <pat@sluggo.org>
    Re: using perl (Chris Fedde)
    Re: Using Rational Rose with Perl for UML (Chris Fedde)
    Re: what's the 1st line os perl script ? (cwrites)
    Re: Where to obtain the perlrtfm podpage? <rick.delaney@home.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 24 Dec 2000 06:12:04 +0100
From: Bjoern Hoehrmann <bjoern@hoehrmann.de>
Subject: Argument isn't numeric and Win32::API
Message-Id: <3a878219.39924939@news.bjoern.hoehrmann.de>

Hi,

The following script:

#!perl -w
use strict;
use Win32::API;
my $AgtGrpOpen = new Win32::API('AgtDll','AgtGrpOpen', ['P', 'P'], 'N');
my $AgtGrpClose = new Win32::API('AgtDll','AgtGrpClose', ['N'], 'N');
my $AgtGrpCount = new Win32::API('AgtDll','AgtGrpCount', ['N'], 'N');

my $path = 'e:\temp\agt\data\\';
my $HGrp = "";

$AgtGrpOpen->Call($path, $HGrp);
print $AgtGrpCount->Call($HGrp);
$AgtGrpClose->Call($HGrp);

Perl complains 'Argument "" isn't numeric in subroutine entry'. I don't
know, how I can change this, the value of $HGrp is under control of the
DLL function, I can only set the initial value to something numeric, but
if I do so, the script stops working, i.e. $count is -1 instead of the
correct value 18373.

Any clues? TIA,
-- 
Björn Höhrmann ^ mailto:bjoern@hoehrmann.de ^ http://www.bjoernsworld.de
am Badedeich 7 ° Telefon: +49(0)4667/981ASK ° http://bjoern.hoehrmann.de
25899 Dagebüll # PGP Pub. KeyID: 0xA4357E78 # http://learn.to/quote [!]e
      "XSL requires thinking -- not chatting" -- Dimitre Novatchev      


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

Date: Sun, 24 Dec 2000 06:41:44 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Argument isn't numeric and Win32::API
Message-Id: <3A459E46.5EB63E03@home.com>

[posted & mailed]

Bjoern Hoehrmann wrote:
> 
> my $path = 'e:\temp\agt\data\\';
> my $HGrp = "";
> 
> $AgtGrpOpen->Call($path, $HGrp);
> print $AgtGrpCount->Call($HGrp);
> $AgtGrpClose->Call($HGrp);
> 
> Perl complains 'Argument "" isn't numeric in subroutine entry'. I don't
> know, how I can change this, the value of $HGrp is under control of the
> DLL function, I can only set the initial value to something numeric, but
> if I do so, the script stops working, i.e. $count is -1 instead of the
> correct value 18373.

I know nothing about Win32::API, but what number are you passing?  If it
works with "" but gives you that warning, then I'd expect it would work
without the warning if you passed 0.  Then again, you have 3 different
calls so I don't know if the warning is only coming from one of them.

You can always turn off warnings.  Trim scope accordingly:

{
  local $^W;
  $AgtGrpOpen->Call($path, $HGrp);
  print $AgtGrpCount->Call($HGrp);
  $AgtGrpClose->Call($HGrp);
}

perldoc perlvar

Or, instead of -w, put 'use warnings' at the top of your script.  Then
you won't see warnings from Win32::API but will still see those in your
script.

perldoc warnings
perldoc perllexwarn

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 24 Dec 2000 12:02:24 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Contribute scripts ? (delete duplicate lines)
Message-Id: <slrn94aip0.8i7.mgjv@martien.heliotrope.home>

On Sat, 23 Dec 2000 07:19:00 GMT,
	janardan@my-deja.com <janardan@my-deja.com> wrote:
> 
>   This basically deletes duplicate entries (even non-contiguous)
>   in a file without sorting or changing sequence of lines.

I hate to burst your bubble, but...

Perl FAQ, part 4:

       How can I remove duplicate elements from a list or array?

You could do your program as a one-liner with one hash.

perl -ne 'print unless $saw{$_}++' file_in > file_out

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd.   | make up 3/4 of the population.
NSW, Australia                  | 


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

Date: Sun, 24 Dec 2000 03:43:44 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Contribute scripts ? (delete duplicate lines)
Message-Id: <x7elyycwlr.fsf@home.sysarch.com>

>>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:

  MV> You could do your program as a one-liner with one hash.

  MV> perl -ne 'print unless $saw{$_}++' file_in > file_out

you ingoramous! you should be coding python instead of perl. how could
you blow such a simple coding problem. this is the correct answer which
i posted earlier:

perl -ne 'print unless $seen{$_}++' infile > outfile

note the major differences of 'seen' vs. saw and the order of 'in/out'
and 'file'.

just face it, your code sucks and mine r00lz!!

uri



















<for those already inebrieated or who soon will be, a belated large :)>

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 23 Dec 2000 21:48:11 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Contribute scripts ? (delete duplicate lines)
Message-Id: <87n1dmeays.fsf@limey.hpcc.uh.edu>

>> On Sun, 24 Dec 2000 03:43:44 GMT,
>> Uri Guttman <uri@sysarch.com> said:

> note the major differences of 'seen' vs. saw

Uri, you seem very tense.

t
-- 
Eih bennek, eih blavek.


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

Date: Sun, 24 Dec 2000 17:33:00 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Contribute scripts ? (delete duplicate lines)
Message-Id: <slrn94b64s.8i7.mgjv@martien.heliotrope.home>

On Sun, 24 Dec 2000 03:43:44 GMT,
	Uri Guttman <uri@sysarch.com> wrote:
>>>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:
> 
>  MV> You could do your program as a one-liner with one hash.
> 
>  MV> perl -ne 'print unless $saw{$_}++' file_in > file_out
> 
> you ingoramous! you should be coding python instead of perl. how could
> you blow such a simple coding problem. this is the correct answer which
> i posted earlier:
> 
> perl -ne 'print unless $seen{$_}++' infile > outfile
> 
> note the major differences of 'seen' vs. saw and the order of 'in/out'
> and 'file'.
> 
> just face it, your code sucks and mine r00lz!!

Heh. And this comes from the man who doesn't even know what the correct
bracing style is, as he has unashamedly admitted in this very newsgroup
in the past. It is most definitely clear that my code is better than
your code since it is one character shorter without sacrificing any
clarity in the naming of variables. infile and outfile could be taken to
be marginally better than file_in and file_out, but to be absolutely
correct, you'd have to write in_file and out_file. 

Face it, Uri, you screwed this one up. 

Martien












And a ditto grin here.

Now, the infidel bracers had code without guile.
The berkeley bracers had programs with style.
The blocks weren't big. They were really quite small
You might think that braces wouldn't matter at all.

But, even though they were wrong, the whole infidel crew
would brag: we're much better coders than you.
With their snoots in the air, they would sniff and they'd snort
We'll have nothing to do with the berkeley sort.

And whenever they met, they got out the flames
they'd even criticise variable names.



Yes, I have a three year old, and read too much of that stuff.


Happy holidays and see you in a few days.

Martien

-- 
Martien Verbruggen              | 
Interactive Media Division      | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd.   | crops where there ain't no crops.
NSW, Australia                  | 


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

Date: Sun, 24 Dec 2000 05:40:33 GMT
From: vthnts@hotmail.com
Subject: cookie accepted or not ?
Message-Id: <92428h$b29$1@nnrp1.deja.com>

Hi.

I use print "Set-cookie ..." to install a cookie.
It works fine.

But I wonder how to know, before moving forward into my script, if the
cookie has REALLY been installed.

i.e. how to know if the "evil user" accepted or not my "poor innocent
cookie" ?! ;-)

Does anyone have an easy solution to this problem ?
Thanks.

Vince.


Sent via Deja.com
http://www.deja.com/


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

Date: Sun, 24 Dec 2000 06:26:50 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: cookie accepted or not ?
Message-Id: <3A459AC9.7EBCE4C4@home.com>


vthnts@hotmail.com wrote:
> 
> i.e. how to know if the "evil user" accepted or not my "poor innocent
> cookie" ?! ;-)

Why don't you ask him?  Your question has nothing to do with Perl.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 23 Dec 2000 18:09:23 -0800
From: news <loy_x@yahoo.com>
Subject: Re: DBIProxy question
Message-Id: <3A455AD3.284EA24C@yahoo.com>

Yeah, same error on client side, the following output on
server(windows/dbiproxy side):

Sat Dec 23 18:05:15 2000 debug, Server starting in operation mode single
Sat Dec 23 18:05:15 2000 notice, Server starting
Sat Dec 23 18:05:15 2000 debug, Writing PID to c:\temp\dbiproxy.pid
Sat Dec 23 18:05:37 2000 debug, Connection from [myip], port 3863
Sat Dec 23 18:05:37 2000 debug, Child clone:
DBI::ProxyServer=HASH(0x1f0c16c)

Sat Dec 23 18:05:37 2000 debug, New child starting
(DBI::ProxyServer=HASH(0x1f0c
16c)).
Sat Dec 23 18:05:37 2000 debug, Accepting client from [myip], port 3863
Sat Dec 23 18:05:37 2000 debug, Client logs in: Application
dbi:ODBC:mattsdb, ve
rsion 0.2003, user [user]
Sat Dec 23 18:05:37 2000 debug, Connecting to dbi:ODBC:mattsdb as [user]
Sat Dec 23 18:05:37 2000 debug, Accepting client
Sat Dec 23 18:05:38 2000 debug, Child terminating.

Honza Pazdziora wrote:

> On Thu, 21 Dec 2000 20:00:07 -0800, news <loy_x@yahoo.com> wrote:
> >
> > $ dbiproxy --debug --mode=fork --logfile=STDERR
> > --configfile=c:/temp/dbiproxy.conf
> >
> > and my configfile contains:
> >
> > {
> >     'localport' => 4321,
> >     'pidfile' => 'c:\temp\dbiproxy.pid',
> >     'logfile' => 1,
> >     'debug' => 1,
> >     'mode' => 'fork',
>
> Does the single mode work, for a start?
>
> --
> ------------------------------------------------------------------------
>  Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
>    .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
> Petition for a Software Patent Free Europe http://petition.eurolinux.org
> ------------------------------------------------------------------------



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

Date: Sat, 23 Dec 2000 18:10:53 -0800
From: news <loy_x@yahoo.com>
Subject: Re: DBIProxy question
Message-Id: <3A455B2D.C16F8FD9@yahoo.com>

IOW, single mode does not work.

news wrote:

> Yeah, same error on client side, the following output on
> server(windows/dbiproxy side):
>
> Sat Dec 23 18:05:15 2000 debug, Server starting in operation mode single
> Sat Dec 23 18:05:15 2000 notice, Server starting
> Sat Dec 23 18:05:15 2000 debug, Writing PID to c:\temp\dbiproxy.pid
> Sat Dec 23 18:05:37 2000 debug, Connection from [myip], port 3863
> Sat Dec 23 18:05:37 2000 debug, Child clone:
> DBI::ProxyServer=HASH(0x1f0c16c)
>
> Sat Dec 23 18:05:37 2000 debug, New child starting
> (DBI::ProxyServer=HASH(0x1f0c
> 16c)).
> Sat Dec 23 18:05:37 2000 debug, Accepting client from [myip], port 3863
> Sat Dec 23 18:05:37 2000 debug, Client logs in: Application
> dbi:ODBC:mattsdb, ve
> rsion 0.2003, user [user]
> Sat Dec 23 18:05:37 2000 debug, Connecting to dbi:ODBC:mattsdb as [user]
> Sat Dec 23 18:05:37 2000 debug, Accepting client
> Sat Dec 23 18:05:38 2000 debug, Child terminating.
>
> Honza Pazdziora wrote:
>
> > On Thu, 21 Dec 2000 20:00:07 -0800, news <loy_x@yahoo.com> wrote:
> > >
> > > $ dbiproxy --debug --mode=fork --logfile=STDERR
> > > --configfile=c:/temp/dbiproxy.conf
> > >
> > > and my configfile contains:
> > >
> > > {
> > >     'localport' => 4321,
> > >     'pidfile' => 'c:\temp\dbiproxy.pid',
> > >     'logfile' => 1,
> > >     'debug' => 1,
> > >     'mode' => 'fork',
> >
> > Does the single mode work, for a start?
> >
> > --
> > ------------------------------------------------------------------------
> >  Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
> >    .project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
> > Petition for a Software Patent Free Europe http://petition.eurolinux.org
> > ------------------------------------------------------------------------



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

Date: Sun, 24 Dec 2000 06:06:27 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: FAQ asking madness (was Re: Simple REGEX question)
Message-Id: <3A459601.AA86FBC9@home.com>


Randy Harris wrote:
> 
> Tad McClellan <tadmc@metronet.com> wrote in message
> news:slrn94987d.9m1.tadmc@magna.metronet.com...
> >
> > 'harrisr' couldn't be troubled to check the Perl FAQ before
> > posting to the Perl newsgroup, and so asked a question that
> > has been asked (and answered) here *hundreds* of times
> > (that in not an exaggeration, it is literal).
> 
> Tad, go ahead and killfile me, because your response is bullshit. You
> are wrong on several counts. I did not ask a FAQ. I did search for the
> answer in the FAQ before asking the question. My question was not 'what
> is the most efficient way to trim spaces'.

No, your question was:

    Why won't
    $str =~ s/^\s*()\s*$/$1/;
    trim both ends?

The answer to that question is because the regexp is wrong.  Would that
answer have satisfied you?

Most people around here will try to help questioners by going a little
further than answering the literal text of the question.  I don't think
it was unreasonable for anyone to assume that you wanted to know how to
trim whitespace from both ends of a string.  Since *that* question is a
FAQ, the proper response would be a pointer to the FAQ.

Pointing you to correct ways to trim whitespace from strings might
answer why the above doesn't do what you expected.  Once you study the
answer in the FAQ and understand how it works, you might understand how
the above works.  Knowing how the above works may explain why it doesn't
work as you expect.

No one here has any idea what could lead you to believe that the above
could trim whitespace from both ends of a string.  It is very hard to
answer that question without knowing where your misunderstanding is
coming from.  If I ask, "Why doesn't this print 'HELLO, WORLD'?"

    print "Hello, world";

how do you answer that?  You don't know what makes me think it would. 
Is it because I think all strings get printed uppercase?  Do I think the
double quotes do it?  The print function?  The phase of the moon?

Answering questions is easy.  Asking them is hard.  It is because it is
hard that people try to cut you some slack and give you an answer they
hope will be useful to you.  They hope that the answer they provide to
their guess at your *real* question will be more useful than the
non-response that your literal quesion warrants.

You might want to check out this loosely related article:

    http://perl.plover.com/Questions.html

> Rick Delaney did provide a very informative and helpful explanation of 
> the area that had confused me, specifically the difference between 
> (.*) and (.*?).

This was not in your original question.  The question, "why is (.*)
different from (.*?)" is a lot more specific and easier to answer. 
However, I am guilty here also, since I should have pointed you to
perlfaq6:

  What does it mean that regexes are greedy?  How can I get around it?

>  Yes, he could have simply pointed to another FAQ but I don't think 
> his answer wasted all that much of your time.

Have you stopped beating your wife?

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sun, 24 Dec 2000 12:11:33 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: file size - outside url?
Message-Id: <slrn94aja5.8i7.mgjv@martien.heliotrope.home>

On Sat, 23 Dec 2000 16:10:55 +0100,
	Karol Nowakowski <karol@imm.org.pl> wrote:
> Uzytkownik "Jeff Helman" <jhelman@wsb.com> napisal w wiadomosci
> news:3A44ADFD.BC59EAE2@wsb.com...
>> Karol Nowakowski wrote:
>> > Could You give some more info, maybe an example?
>> Go to a command prompt (or DOS prompt or whatever) and type:
>> perldoc lwpcook
> 
> but unfortunetaly I don't have LWP module on my ISP virtual server and I
> don't have telnet connection, so I'm not able to install this module there
> 
> the command I'm getting is:
> Malformed header from CGI script: Can't locate LWP/Simple.pm in @INC (@INC
> contains: /usr/perl/i386-freebsd /usr/perl /usr/perl/site_perl/i386-freebsd
> /usr/perl/site_perl /usr/perl/site_perl .) at /sws/temp4.pl line 3. BEGIN
> failed--compilation aborted at /sws/temp4.pl line 3

This most likely means that the LWP modules aren't installed, or are
installed in a non-standard place. alk to your ISp to see whether they
are willing to install it. If they aren't, you'll have to find a way to
get it on that machine. I'm pretty sure that LWP is all pure perl, so it
shouldn't be impossible to install by copy, but it's going to be a lot
of work. It would help if you have a machine available with a unix on
it. That way you can follow the advice in Perl FAQ, part 8, about how to
install modules in your own place, and then copy that tree over to the
target machine. This will work for pure perl modules between any
unices, and maybe even from win32 to unix, although there may be other
considerations there. If you have any C components, you'll have to make
sure you have the same platform (freebsd in this case).


By far the easiest is to just ask your ISP to do it for you.

Martien
-- 
Martien Verbruggen              | Since light travels faster than
Interactive Media Division      | sound, isn't that why some people
Commercial Dynamics Pty. Ltd.   | appear bright until you hear them
NSW, Australia                  | speak?


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

Date: Sun, 24 Dec 2000 02:49:12 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Help with SSI Parser for html pages.
Message-Id: <3A4564A0.7A19E886@rochester.rr.com>

Jody Fedor wrote:
> 
> #######  The question  ##########
> 
> #I have this script I've been working on but don't know
> #how to evaluate or execute the command I've parsed.  Can
> #anyone help?  This is the program:
> 
> #test1.htm contains the following for testing:
<much of program deleted>
> #$ssicommand now contains: if (-e '/home/usr61/specials/tspec.htm')
> #{ &prochtm; $specials = "<TD WIDTH=100
> ROWSPAN=9><CENTER>$htmlin</CENTER></TD>\n" }
> #$htmfile now contains: /home/usr61/specials/tspec.htm
> 
> #I know you can eval a variable but it's not the same as
> #executing a variable is it?
> 
> #I would like to execute the perl command contained in the
> #$ssicommand variable.  Can any one help here?
> 
> #PS - If there is a more perlish way to accomplish this, please let me know.
> 
> #Jody
Jody, the eval command with parentheses (not braces) is the one you
want.  That will compile and execute the string presented as the
argument.  Don't forget to check for success following the eval, as it
might not compile, or might give an error during execution.
-- 
Bob Walton


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

Date: Sat, 23 Dec 2000 23:54:02 -0500
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Help with SSI Parser for html pages.
Message-Id: <923vf4$60r$1@plonk.apk.net>


Bob Walton wrote in message <3A4564A0.7A19E886@rochester.rr.com>...

<snip Jody's ramble>

>Jody, the eval command with parentheses (not braces) is the one you
>want.  That will compile and execute the string presented as the
>argument.  Don't forget to check for success following the eval, as it
>might not compile, or might give an error during execution.


Thanks Bob,

        After a little more digging in my 13 Perl books, I came across
eval.  I knew you evaluate a string to do things like addition and
subtraction but never had used commands in a string before.  After
I saw there weren't any posts, I figured it must be something real,
REAL obvious, so.....   I started digging in the perl docs and found
it.   It's those times you would like to be able to recall a post or
delete it so you don't look so dumb!  LOL.  I appreciate the message
and the post.

Thanks for your help.

Jody




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

Date: Sun, 24 Dec 2000 06:04:48 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <4mg16.439$B9.189511680@news.frii.net>

In article <977599047.656@itz.pp.sci.fi>,
Ilmari Karonen  <usenet11314@itz.pp.sci.fi> wrote:
>In article <922rf9$g2m$1@nnrp1.deja.com>, richardstands@my-deja.com wrote:
>>
>>given code:
>>print( ( 100.123 % 23 ), "\n" );
>>
>>I get:
>>8
>
>I'd classify this as a misfeature in perl.  The modulus operator could
>be well defined for all reals, but in the current implementation it
>only works for integers.  Sorry.
>

I'm a bit confused.  I might not have enough higher math but I
understand that the modulus operation is not undefined for reals.
Modulus, as I understood from abstract algebra returns the remainder
after integer division.  What is the remainder after integer division
of real arguments?

BTW I do find the documentation for the operator a bit obtuse.  What's
wrong with the word 'remainder'?

chris
-- 
    This space intentionally left blank


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

Date: Sun, 24 Dec 2000 06:25:19 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Help: modulus problem, docs confusing
Message-Id: <jFg16.440$B9.170957824@news.frii.net>

In article <922rf9$g2m$1@nnrp1.deja.com>,  <richardstands@my-deja.com> wrote:
>Hi all,
>
>I was working on a progress bar for an FTP upload and got all tangled
>up in figuring the percentage and wound up using the modulus operator
>(math is not my strong suit). 
>

You are looking at a simple scaling problem.  I'm not sure what modulus
will do for you.   Here is a demo.

    use strict;
    use warnings;

    my $size = 3402292;   # Size of 'file'
    my $width = 40;       # size of the progress bar
    my $transfer = 0;
    $| = 1;

    while ($transfer < $size) {

	$transfer += rand(30);

	my $marker = $transfer * $width/$size;
	print "we've done this much: [".
	    ("*" x $marker). (" " x ($width - $marker)). "]\r";
    }

    print "\n";

chris
-- 
    This space intentionally left blank


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

Date: Sun, 24 Dec 2000 01:38:19 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: infinite loop
Message-Id: <fsc16.1026$Kk5.50626@eagle.america.net>

On Sat, 23 Dec 2000 20:09:30 GMT, Mike Wescott <wescott@conterra.com>
wrote:
>while(<LYNX>) {
>   break if /standard\.def/;
>}  ^^^^^
>exit unless $_;		# is this eof or /standard\.def/ ?

 s/break/last/;

-- 
Garry Williams


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

Date: Sun, 24 Dec 2000 15:49:06 +0800
From: "Peter Chan" <peter.cch@excite.com>
Subject: my simple perl application didn't work
Message-Id: <3a45abaa.0@news.tm.net.my>

I'm new to PERL and I've install the ActivePerl in my PC, then i still can't
run my simple cgi in my PC.
Then i post this problem to Newsgroup, what i get is they suggest me to get
Apache installed in my PC.

So, I've download it, and I'd install it.
I think i've install it successfully because when i key in this
http://127.0.0.1/ at the address of my browser and enter,
it display a page that say if i can read that page, it mean that i've
successfully install it(Apache Server).

Now i'm going to test my CGI progam(a simple counter only), but it still not
working.
I don't know what's the problem and where is it happen.

The following is my files info:
location of my cgi(the counter)         D:\My Documents\HTML\Home
Page\walink\walink_page\hitcounter.cgi
location of my testpage.html            D:\My Documents\HTML\Home
Page\walink\walink_page\testpage.html
my ActivePerl installed at                C:\Perl\
my Perl compiler(perl.exe)               C:\Perl\bin\perl.exe

My perl program:
#!C:\Perl\bin\perl.exe

#texthitcounter.cgi
#By Dora Chow
#
#simple hit counter

$datafile="counter.dat";        # data file that contains current visitors

($fsec,$fmin,$fhour,$fday,$fmon,$fyear,$fwday,$fyday,$fisdst) =
localtime(time);

print "Content-type: text/html\n";
print "Pragma: no-cache\n\n";

open(COUNTER, $datafile);
 $count=<COUNTER>;
close COUNTER;
$count++;

open(COUNTER, ">$datafile");
 print COUNTER $count;
close COUNTER;

print "$count";
exit;

Note: this perl program work when I double click on it, it will print out
the number

My testpage code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head><title>testpage</title></head>
<body>
<!--#include virtual="hitcounter.cgi"-->
</body>
</html>

If you need further info of my files in my PC, do tell me.
Thanks for helping.


Regard,
Peter





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

Date: 24 Dec 2000 03:48:50 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: Newbie but serious - Problems reading file from multipart forms (no  binmode!)
Message-Id: <3A457106.D8E6C844@myself.com>

[Cc'd]

Chris Fedde wrote:
> 
> 
> For me this returns...
> 
>     [Fri Dec 22 23:47:15 2000] cgicrud: Can't call method "param" on an
>     undefined value at cgicrud line 8.
> 

Gee, is this an attempt at sarcasm?  Did what I posted look like a
complete script or a code snippet?  *Ding*, you win the prize.  Since
the OP was already using the param() method, I made the obvious
assumption that he would know enough to include the CGI.pm module.
Glad to see that you, however, didn't catch that one.  

The only reason I mentioned this:

# be sure to include this in your script
use CGI::Carp qw(fatalsToBrowser);

was because I changed the:

print "<br><b>$0 ERROR: $!</b><br>"; 
-to-
die "ERROR: $!\n";

which might have had the side effect of placing an error message
in an area where the poster might not have had access or awareness.

So while I appreciate your intentions, I do not appreciate your
apparent efforts to insult me.  Oh, and I'll read Usenet with
whatever font I damn well want to, thank you very much.


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

Date: Sun, 24 Dec 2000 10:50:18 +1100
From: Raymond WAN <rwan@cs.mu.OZ.AU>
Subject: Perl's BigInts/BigFloats
Message-Id: <Pine.LNX.3.96.1001224104442.11587A-100000@vike.cs.mu.OZ.AU>


Hi all,

	This was a reply to a question I posted a while back about using
BigInts and BigFloats that Dan sent to me via e-mail.  Very nice of him to
reply.  It was sort of an old question, but truthfully, I still don't
fully understand yet.

	I did something else which is probably wrong, but worked for some
reason.  Instead of explicitly creating a BigFloat with the new operator,
I did something like this:

	$a = "4000000000000";

	And it knew $a was a BigFloat as opposed to doing the same without
quotes.  I'm sure it treated $a as a BigFloat because when I print $a or
$a added to some $b, I got a seemingly sensical number and not 2^32.

	Does this sound alright?

	Thanks a lot for the reply, Dan!

Ray

===== ORIGINAL REPLY =====

Date: Fri, 22 Dec 2000 22:45:11 -0500
From: Dan Harasty <harasty@penvision.com>
To: rwan@cs.mu.OZ.AU
Subject: Perl's BigInts/BigFloats

Raymond,

I saw your netnews posting about Perl's BigInts/BigFloats.

I had trouble posting a reply, so here you get the benefit of some
personal tutoring: 

Here's what you are missing:

Once you include this:

	use Math::BigFloat;

You still need to create a big integer, like this:

	$a = new Math::BigFloat "3.45e+1000";

Then you can do normal arithmetic on $a; Perl will "detect" you are using
a "BigFloat" object, and use that module's version of "+", "*", "/", etc. 

Some operations are not implemented, like log(), exp()...

(If you can please post this as an answer to your question, so others can
benefit, too.  Thanks.) 

- Dan Harasty
harasty@my-deja.com



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

Date: Sun, 24 Dec 2000 02:39:41 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl's BigInts/BigFloats
Message-Id: <3A456266.196F343C@rochester.rr.com>

Raymond WAN wrote:
 ...
>         This was a reply to a question I posted a while back about using
> BigInts and BigFloats that Dan sent to me via e-mail.  Very nice of him to
> reply.  It was sort of an old question, but truthfully, I still don't
> fully understand yet.
> 
>         I did something else which is probably wrong, but worked for some
> reason.  Instead of explicitly creating a BigFloat with the new operator,
> I did something like this:
> 
>         $a = "4000000000000";
> 
>         And it knew $a was a BigFloat as opposed to doing the same without
> quotes.  I'm sure it treated $a as a BigFloat because when I print $a or
> $a added to some $b, I got a seemingly sensical number and not 2^32.
> 
>         Does this sound alright?
> 
>         Thanks a lot for the reply, Dan!
> 
> Ray
<Jeopardy posting of original note deleted>
No, $a will be treated as an ordinary float when used in numeric
context, which has around 17 digits of precision on many platforms.  It
will accurately hold integers up to about 2**53, not 2**32.  Thus, your
$a above will work fine.  Try something with 18 or more zeros.  Then
you'll find things like $a+1==$a is true, for example.  Were $a a
BigFloat (or a BigInt), that wouldn't happen.
-- 
Bob Walton


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

Date: 24 Dec 2000 05:08:02 GMT
From: Jim Monty <monty@primenet.com>
Subject: Re: problem with awk in perl script
Message-Id: <9240bi$6f9$1@nnrp2.phx.gblx.net>

Andrew N McGuire <anmcguire@my-deja.com> wrote:
> ... Now, there are cases where the use of an external
> program is warranted, or even the best thing to do. Sorting
> springs to mind quickly as an example. ...

Ok, I'll bite: Why would using the external sort command be
"warranted, or even the best thing to do", as opposed to just using
Perl's built-in sort function?

-- 
Jim Monty
monty@primenet.com
Tempe, Arizona USA


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

Date: Sun, 24 Dec 2000 05:18:18 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: problem with awk in perl script
Message-Id: <uGf16.1056$Kk5.51846@eagle.america.net>

On 24 Dec 2000 05:08:02 GMT, Jim Monty <monty@primenet.com> wrote:
>Andrew N McGuire <anmcguire@my-deja.com> wrote:
>> ... Now, there are cases where the use of an external
>> program is warranted, or even the best thing to do. Sorting
>> springs to mind quickly as an example. ...
>
>Ok, I'll bite: Why would using the external sort command be
>"warranted, or even the best thing to do", as opposed to just using
>Perl's built-in sort function?

The perl sort() needs all of its data in memory.  The sort(1) program
will sort a file without the need to store it entirely in memory
(although it will need to use temporary work files, if the file is
large enough).  

-- 
Garry Williams


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

Date: Sun, 24 Dec 2000 18:39:37 +1300
From: "Tintin" <you.will.always.find.him.in.the.kitchen@parties>
Subject: Re: problem with awk in perl script
Message-Id: <977636522.754043@shelley.paradise.net.nz>


"Jim Monty" <monty@primenet.com> wrote in message
news:9240bi$6f9$1@nnrp2.phx.gblx.net...
> Andrew N McGuire <anmcguire@my-deja.com> wrote:
> > ... Now, there are cases where the use of an external
> > program is warranted, or even the best thing to do. Sorting
> > springs to mind quickly as an example. ...
>
> Ok, I'll bite: Why would using the external sort command be
> "warranted, or even the best thing to do", as opposed to just using
> Perl's built-in sort function?

In most cases, something like GNU sort is *significantly* faster than Perl's
sort.




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

Date: Sun, 24 Dec 2000 06:04:11 GMT
From: bconnats@bellsouth.net (cwrites)
Subject: Re: PWS - perl (ATTN: cwrites)
Message-Id: <3a459171.57960239@news.lig.bellsouth.net>

I don't use a header. My PWS runs on Windows 98, and I run my finished
scripts on an NT server, both of which do not require a shebang to
tell the script where the interpreter is.

Brad

On Sat, 23 Dec 2000 13:26:44 +0100, snef <snef@soneramail.nl> wrote:

>In article <3a43ef13.23786830@news.lig.bellsouth.net>, 
>bconnats@bellsouth.net says...
>> Here is the content of my autoexec.bat file:
>> 
>> C:\PROGRA~1\NETWOR~1\MCAFEE~1\SCAN.EXE C:\
>> @IF ERRORLEVEL 1 PAUSE
>> @ECHO OFF
>> @REM Setup for QR, BW & HIBERNATE
>> @PATH
>> C:\CPQS\SAVEREST;C:\CPQS\TOOLS;C:\WINDOWS\COMMAND;C:\WINDOWS;%PATH%;C:\PERL\BIN
>> @IF EXIST C:\APPL.ZIP\*.* IF EXIST C:\WINDOWS\SMARTDRV.EXE
>> C:\WINDOWS\SMARTDRV.EXE
>> @IF EXIST C:\CPQS\SAVEREST\QRSETUP.* CALL C:\CPQS\SAVEREST\QRSETUP
>> /MFG C: D: E: F:
>> CALL c:\hibernat\hibchk.bat
>> CALL C:\CPQS\TOOLS\WINPATH.BAT
>> @ECHO OFF
>> 
>> After adding "C:\PERL\BIN" to the @PATH, my PWS worked fine.
>> 
>> Brad
>> 
>> <CUT>
>> 
>What kind of header do you use?
>#!/usr/bin/perl ?
>#!perl ?
>
>snef.
>(I now installed indigo perl with an apache ntegrated. works ok, but i've 
>some problems installing modules. The modules installed fine with 
>activestate/PWS....that's why I want to use PWS...)
>
>
>Snef



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

Date: Sat, 23 Dec 2000 23:11:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <x7itoad97v.fsf@home.sysarch.com>

>>>>> "PJM" == Pat J Magnan <pat@sluggo.org> writes:

  PJM> I'll be honest, i've been naughty in the past and not bothered with the
  PJM> following two good practices:

  PJM> 1 - #!/usr/bin/perl -w
  PJM> 2 - use strict;

the perl santa will like you much better then.

  PJM> warning from the following chunk of code that is driving me nuts. I get:
  PJM> Use of unitialzied value at ... line ...

which line? the code below shows the line but i see no way it can
enerate that error.

  PJM> Is Perl so unlike other languages that $varname = ""; (or
  PJM> $varname = 0;) doesn't count as explicit initialization? I know
  PJM> this is not the case, but

those are proper initializations but you don't need to do that if you
just assign again later on. they are needed if you USE those variables
in expressions where a string or number is expected and the variable
value is still undef.

  PJM> sub html_header
  PJM> {
  PJM> my ($title, $css, @scripts) = @_;
  PJM> my $script;
  PJM> my $header = "";

the my is good, but as i said above you don't need to init $header as
you just assign to it here.

  PJM> ## this is the line perl bitches about:
  PJM> $header = qq!
  PJM> <html>

  PJM> <head>
  PJM> more of the HTML i Want to puke out here !;

there is nothing there i see that would trigger a uninitialized
warning. you don't interpolate any variables in there which is the only
way to get that warning in a string.

are you posting the actual code or some edited version of it? 

another point is that is it considered better style to use here docs for
multiline strings (such as html!). you don't need the qq operator and
dealing with the ; being far away from the main part of the statement.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 23 Dec 2000 23:14:17 GMT
From: "Pat J. Magnan" <pat@sluggo.org>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <dla16.54418$Z9.3293278@news1.rdc1.mb.home.com>

Jeff:

thanks for pointing out my brainfart!

> Say you call this routine with just one paramater for the title.  The
> first line of your script would then set $title to your single passed
> parameter, $css to undef and @scripts to an empty state.  Thus, when you
> explicitly include $css or an element of @scripts in your definition of
> $header, since it is undefined, the warning is issued.

i do occaisionally call the function without $css or @scripts defined.. i
guess i should have included the whole block. In my efforts to slim down the
bandwidth i was consuming, i left out the really important bits.

I also forgot that $var = qq! !; is only one line, thus the compiler was
unable to indicate the beginning of the problematic code.

thanks much.





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

Date: Sat, 23 Dec 2000 23:17:32 GMT
From: "Pat J. Magnan" <pat@sluggo.org>
Subject: Re: use strict (do I have enough hair to use it?)
Message-Id: <goa16.54419$Z9.3293509@news1.rdc1.mb.home.com>


>
> btw- the code you posted generates no warning
>      messages.  It might be a good idea to check
>      that your code snippet is representative
>      of the problem you're having before posting
>      it next time.

i hang my head in shame, i realized that after jeff's reply. and yes, the
problem is indeed in the bits I omitted. i will keep this in mind, thanks




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

Date: Sun, 24 Dec 2000 05:36:40 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: using perl
Message-Id: <IXf16.438$B9.189122560@news.frii.net>

In article <slrn94a0d8.rpg.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>karthy muthiah kasi (kasi@students.uiuc.edu) wrote on MMDCLXXI September
>MCMXCIII in
><URL:news:Pine.GSO.4.10.10012221940480.4256-100000@ux7.cso.uiuc.edu>:
>`' Hi, 
>`' 	I am new to the Perl language and I have a question regarding its
>`' use. 	I am thinking of using perl to do the database processing and
>`' using visual c++ as a front end to an application.  Is there an advantage
>`' in terms of speed of using perl to do the database processing?  Thanks for
>`' any help.   
>
>
>If it's a comparison of Perl vs C++, with all other things equal
>(same algorithms, good programmers), the speed of Perl will be a
>disadvantage - C++ ought to be (much) faster than Perl.
>
>But you say you want to do 'database processing'. Are you talking
>about letting Perl do work instead of you database? If you have a
>decently written database server, you are probably better off in
>letting the database server do the work - it's my experience that
>trying to outsmart a database server seldomly pays off.
>

I have to agree with Abigail here.  And I also want to point out
that in my experiance most of the performance bottleneck in database
centric code is in the database. 

YMMV
chris
-- 
    This space intentionally left blank


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

Date: Sun, 24 Dec 2000 07:22:54 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Using Rational Rose with Perl for UML
Message-Id: <ivh16.442$B9.189123072@news.frii.net>

In article <91snbd$rrg$1@nnrp1.deja.com>,
Steve Button  <steve_button@my-deja.com> wrote:
>Hi,
>
>We've recently started using Rational Rose to model our systems and
>will ultimately be building the systems in Perl.
>
>Does anyone have any experiences of using UML with Perl ?
>

Rational will probably bark at you when you say you are using their
tools for a typeless language.  Most of what Rational Rose excels
at is building all those function templates for the interfaces that
make it so hard to make any progress using C++.

In Perl all that stuff disappears in a puff of AUTOLOAD.  If you
are really in the market for a design methodology that applies
itself well to design and development using Perl or other typeless
languages take a look at XP. 

Good Luck
chris
-- 
    This space intentionally left blank


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

Date: Sun, 24 Dec 2000 06:13:36 GMT
From: bconnats@bellsouth.net (cwrites)
Subject: Re: what's the 1st line os perl script ?
Message-Id: <3a459379.58480111@news.lig.bellsouth.net>

Hello. You don't need the shebang for Windows OS. You tell your system
were to find the Perl interpreter by modifying the register. You can
use Regedit to do that. If you do a search on the Web, you can find
instructions for setting up Perl on Windows OS. It's been a while
since I did it. Active state may have something.

Brad

On Sat, 23 Dec 2000 21:20:58 +0800, "Peter Chan"
<peter.cch@excite.com> wrote:

>i've install the ActivePerl on my windows PC, then i try to run my perl
>program in the HTML that i create.
>But it don't work, then i try to edit the 1st line where it state the
>location of the PERL compiler to where it is.
>
>Example:
>#! /perl/bin/perl
>
>but it doesn't work, i'd tried many times but still the same.
>
>the PERL on my PC info:
>compiler located at C:\Perl\bin\perl.exe
>
>so, what's the 1st line that I should put in my perl program ?
>
>Thanks for helping
>
>



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

Date: Sun, 24 Dec 2000 06:19:20 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Where to obtain the perlrtfm podpage?
Message-Id: <3A459906.BB1C9314@home.com>


Tad McClellan wrote:
> 
> A deja "power search" in clp.misc for 'perlrtfm' finds this:
> 
>  >I
>  >wanted to play around with it recently but have been unable to connect
>  >to the URL you had posted earlier
>  >(doriath.perl.com/misc/perlman-alpha0.tar.gz)
> 
>  Glunk!  I can't even get there myself.  The whole network seems
>  hosed today.  I'll see what I can see.
> 
> Tom wrote that last paragraph on Dec 19th. Guess it's not fixed yet...

I'm not sure why that's the best article returned.  I thought Tom posted
the actual pod here.  Deja's archives are very poor, lately.  

Still, an early version can be found here (I inserted a newline after
the "?" to keep the lines short):

http://www.xray.mpe.mpg.de/cgi-bin/extract-mbox/perl5-porters/2000-05?
25048%2E957207786%40chthon

-- 
Rick Delaney
rick.delaney@home.com


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

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


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