[13740] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1150 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 22 10:06:28 1999

Date: Fri, 22 Oct 1999 07:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940601113-v9-i1150@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 22 Oct 1999     Volume: 9 Number: 1150

Today's topics:
    Re: (PERL/XML):Subroutine access by Reference. <sganapat@cisco.com>
    Re: chomp() nested in split() doesn't work - why? (Sam Holden)
        determining the weeknumber with perl/win32 <thorsten0209@my-deja.com>
    Re: Expr or block as 1st param: Compiler magic needed? (Anno Siegel)
    Re: Expr or block as 1st param: Compiler magic needed? (Anno Siegel)
        Help - Text Formatting <adadams@ix.netcom.com>
    Re: Help - Text Formatting (Brett W. McCoy)
    Re: HELP- WILL PAY!!! (Tad McClellan)
    Re: How can print a HTML file? <gellyfish@gellyfish.com>
    Re: How to round a number? <rhomberg@ife.ee.ethz.ch>
    Re: HTML Mail <gellyfish@gellyfish.com>
    Re: Ignore the idiots (Brett W. McCoy)
    Re: in need of example... (Randal L. Schwartz)
    Re: in need of example... <newsposter@cthulhu.demon.nl>
    Re: in need of example... (Brett W. McCoy)
    Re: in need of example... (Brett W. McCoy)
    Re: Increase stack size in perl5 ? <gellyfish@gellyfish.com>
        Is there a module to parse a HTML-file like this? <MHasenoehrl@de.lhsgroup.de>
    Re: Mail::Send module doesn't work on NT <wyzelli@yahoo.com>
        making a "find" shell command <970482@grupiara.dcc.unicamp.br>
    Re: making a "find" shell command <gellyfish@gellyfish.com>
    Re: making a "find" shell command (Brett W. McCoy)
    Re: newbie problem writing/reading a file <Rik@fast-speed.demon.nl>
    Re: newbie <jspangen@my-deja.com>
    Re: Passing function as parameter. xxaxx@my-deja.com
    Re: Perl and NT IIS4 <gellyfish@gellyfish.com>
        Perl Exam Beta Testers Required - How good are you? <msuri@recruitsource.com>
    Re: perl for win32 and date <sb@sdm.de>
        Redundant POD (was Re: Underlying data structure behind <gellyfish@gellyfish.com>
    Re: Redundant POD (was Re: Underlying data structure be <jeffp@crusoe.net>
    Re: Reference challenge <jeffp@crusoe.net>
        REFERENCE CHALLENGE: final (?) realref() test <jeffp@crusoe.net>
    Re: sorting hashes in an array of hashes c_j_marshall@my-deja.com
    Re: stealing the news: how hard can it be? <dsparling@my-deja.com>
    Re: Using "use strict" and "Getopt" together <gellyfish@gellyfish.com>
    Re: WIn32::OLE <jmn.ac.delete@abanet.it>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 22 Oct 1999 17:31:29 +0800
From: Subalakshmi GanapathiRaman <sganapat@cisco.com>
Subject: Re: (PERL/XML):Subroutine access by Reference.
Message-Id: <38102EF1.2CC4FE2D@cisco.com>

Hi,

Thanks a lot for the information.
Where can I get latest version of XML::Parser  (XML-Parser-2.27) ?

Can I integrate this with the Perl 5.004_04 library that I am using ,
or should I be necessarily using 5.005_xx ?

This module would only be an add-on to the existing
Perl library (that by default does not come with the XML related libraries
?!?), isn't it ?
Please correct me if I am wrong.

Thanks in advance for your help.

Arved Sandstrom wrote:

> In article <7uk15q$553$1@nntp3.atl.mindspring.net>, ebohlman@netcom.com
> (Eric Bohlman) wrote:
>
> > Subalakshmi GanapathiRaman (sganapat@cisco.com) wrote:
> > : "Modification of a read-only value attempted at Expat.pm line 126"
> >
> > What Perl version are you using?  I believe there's a bug in 5.004 that
> > can cause this to happen, particularly if you're also using DBI.
>
> Or to phrase that slightly differently, unless you have the patched 2.26
> version of XML::Parser, or the 2.27 (latest) version of XML::Parser, you
> will sometimes see the dreaded line 126 error if you are also using 5.004
> Perl. :-)
>
> Arved Sandstrom

--
Subalakshmi GanapathiRaman




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

Date: 22 Oct 1999 13:16:13 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: chomp() nested in split() doesn't work - why?
Message-Id: <slrn810ost.6r5.sholden@pgrad.cs.usyd.edu.au>

On 22 Oct 1999 10:58:45 -0000,
	Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>Ala Qumsieh  <aqumsieh@matrox.com> wrote in comp.lang.perl.misc:
>
>[...]
>
>>Contrary to the behaviour of chop(), chomp() does NOT return the
>>variable after chomp()ing.
>
>Neither does chop().

; perldoc -f chop
=item chop VARIABLE

=item chop LIST

=item chop

Chops off the last character of a string and returns the character
chopped. 

#!/usr/local/bin/perl -w
use strict;
my $test = "A string";
print chop $test;

That prints 'g' for me...

Of course since you know the only possible string chomp could remove,
since you know what $/ is... it wouldn't be very useful for chomp 
to do that anyway.

-- 
Sam

Basically, avoid comments. If your code needs a comment to be
understood, it would be better to rewrite it so it's easier to
understand.	--Rob Pike


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

Date: Fri, 22 Oct 1999 11:22:03 GMT
From: Thorsten Belka <thorsten0209@my-deja.com>
Subject: determining the weeknumber with perl/win32
Message-Id: <7uphcq$mt1$1@nnrp1.deja.com>

Hi people...

within a perl script under winNT and activestate perl i want to
determine to which number of week (1...52) the day before belongs to.
Should be no Problem under Unix but is this possible under NT.
Is there any module for activestae pearl i could use?
Any sugestions?




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


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

Date: 22 Oct 1999 12:44:49 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Expr or block as 1st param: Compiler magic needed?
Message-Id: <7upm81$pop$1@lublin.zrz.tu-berlin.de>

Alan Curry <pacman@defiant.cqc.com> wrote in comp.lang.perl.misc:
>In article <MPG.127907c3b909876598a0ec@nntp.hpl.hp.com>,
>Larry Rosler  <lr@hpl.hp.com> wrote:
>>print any_expr_or_block(qw(foo foobar)), "\n";
>>print any_expr_or_block(qw(foo baz)), "\n";
>>print any_expr_or_block(sub { /foo/ }, qw(foobar)), "\n";
>>print any_expr_or_block(sub { /foo/ }, qw(baz)), "\n";
>
>But that's not like grep. With grep, you can omit the "sub" keyword before
>your anonymous sub. That's the compiler magic.

you can get that with prototypes:

  sub any_expr_or_block (&@);

Anno


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

Date: 22 Oct 1999 12:51:08 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Expr or block as 1st param: Compiler magic needed?
Message-Id: <7upmjs$pq9$1@lublin.zrz.tu-berlin.de>

Larry Rosler  <lr@hpl.hp.com> wrote in comp.lang.perl.misc:

[...]

>Here is a simple single function that does what you want.  I refuse to 
>name it with jaggy caps, though.  Those belong to Java, not here.  I 
>also avoid your unnecessary copying of the input.
>
>
>#!perl -w
>use strict;
>
>  sub any_expr_or_block {
>    defined(my $match = shift) or
>        die "\nNo first argument.\n"; 
>    unless (ref $match) {
>        foreach (@_) { return 1 if m/$match/; }
>    } elsif (ref $match eq 'CODE') {
>        foreach (@_) { return 1 if &$match; }
>    } else {
>        die "\nFirst argument must be an expr or a block.\n" 
>    }
>    return 0;
>  }
>
>print any_expr_or_block(qw(foo foobar)), "\n";
>print any_expr_or_block(qw(foo baz)), "\n";
>print any_expr_or_block(sub { /foo/ }, qw(foobar)), "\n";
>print any_expr_or_block(sub { /foo/ }, qw(baz)), "\n";

print any_expr_or_block(sub { $_[0] eq 'bar' }, qw( foo bar)); # ?

The call to &$match should probably be &$match( $_).

Anno


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

Date: Fri, 22 Oct 1999 09:15:59 -0400
From: "Earle R. Adams" <adadams@ix.netcom.com>
Subject: Help - Text Formatting
Message-Id: <3810638E.2E3572C0@ix.netcom.com>

Hello, I am a new user to perl and I was wondering if anyone out
there has any example scripts of using perl for text formatting?
My goal is to use perl in order to format data output from one
software package into another.

Thank you.
earle adams



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

Date: Fri, 22 Oct 1999 13:34:03 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Help - Text Formatting
Message-Id: <slrn810q70.omc.bmccoy@moebius.foiservices.com>

Also Sprach Earle R. Adams <adadams@ix.netcom.com>:

>Hello, I am a new user to perl and I was wondering if anyone out
>there has any example scripts of using perl for text formatting?
>My goal is to use perl in order to format data output from one
>software package into another.

Your question is too vague to be able to give you an example.  Perl was
created with text extraction and formatting in mind.  What exactly are you
trying to do?  Be specific.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Fri, 22 Oct 1999 04:32:09 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP- WILL PAY!!!
Message-Id: <9e7pu7.st.ln@magna.metronet.com>

Gary Kelley (gary@cowboyfurniture.com) wrote:

: Subject: HELP- WILL PAY!!!

: I need someone to write some perl (?) scripting for me, I am not coherent
: enough to do it myself.


   Do you realize that many experienced Perl programmers will
   not even _see_ your message?

   You have hit *two* common "kill me" features.

      1) SHOUTING in the Subject:

      2) using superfluous punctuation!!!


   And you also posted a job ad to a discussion newsgroup.

   You should post job ads to newsgroups where job ads are welcomed
   (most of them have 'jobs' in the newsgroup name).



   Help yourself.

   Read    news.announce.newusers    if you want to post to Usenet.


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


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

Date: 22 Oct 1999 12:28:02 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How can print a HTML file?
Message-Id: <38104a42_2@newsread3.dircon.co.uk>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> Jing Shi <Jing.Shi@usa.alcatel.com> wrote:
>> Will that print out the file with all the HTML tags?
>> Yes, I can use HTML::Parse to get rid of those tags. But I mean
>> how  I can get the print out just like I print it from Netscape?
>> 
> 
> You may be able to find an HTML to Postscript filter or something like
> that but this is not a Perl question - you should look perhaps at freshmeat
> <http://freshmeat.net>
> 

Actually I couldnt find one myself on Freshmeat but the obviously named
html2ps was found straight away on Altavista ....

/J\
-- 
"Buzz Aldrin was the second man to walk on the moon and the first to
fill his pants" - Violet Berlin, The Big Bang


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

Date: Fri, 22 Oct 1999 12:36:14 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: How to round a number?
Message-Id: <38103E1E.1C8EACCA@ife.ee.ethz.ch>

Francois Dupradeau wrote:
> 
> Dear All,
> 
> Is there a function in Perl to round off the 2nd or the thrird (or the
> 5th, etc...) number after the decimal point of a number?
> ex:
> 3.123456789 => 3.123 (WITHOUT exponential)

How about 
a) reading the faq:
perldoc -q round
Found in /usr/lib/perl5/5.00503/pod/perlfaq4.pod
 .... printf("%.3f", 3.1415926535);       # prints 3.142

b) cutting your .sig by about 10 lines

- Alex


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

Date: 22 Oct 1999 12:16:51 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: HTML Mail
Message-Id: <381047a3_2@newsread3.dircon.co.uk>

Don Stefani <customk9@home.com> wrote:
> I have a free Mail list program that I would like to send html in the body
> of the message.
> The body tags in the cgi script are
> 
> print "Body of the e-mail:<br>\n";
> print "<textarea name=\"body\" cols=\"60\" rows=\"10\"
> wrap=\"virtual\"></textarea><br>\n";
> 
> Is this were I would make changes to use html in the body?
> If so, and if it's not too much hassel, could someone tell me how?
> 

You use the module MIME::Lite generally ... The HTML is irrelevant.

/J\
-- 
"Nourishes at the root and penetrates right to the tip" - Pantene
Advertisement


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

Date: Fri, 22 Oct 1999 13:39:40 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Ignore the idiots
Message-Id: <slrn810qhh.omc.bmccoy@moebius.foiservices.com>

Also Sprach A.J. Norman <nja@le.ac.uk>:

> I think what's perhaps needed is a c.l.p.m. FAQ - not the huge Perl FAQ
> that Tom C used to post in chunks in a neverending cycle, but a small
> one with pointers to the Perl FAQ, perl.com and other useful sites, and
> advice similar to Greg's (post tested code, check the Perl FAQ before
> posting, give the exact text of any error messages[1][2], say what you
> think the probable cause of the problem is, etc).

There is such a FAQ, posted rather frequently, if I recall, on how to find
the Perl FAQ and make good use of it.  It showed up in c.l.p.announce this
morning.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: 22 Oct 1999 06:34:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: in need of example...
Message-Id: <m1emenbjt8.fsf@halfdome.holdit.com>

>>>>> "Jonathan" == Jonathan Stowe <gellyfish@gellyfish.com> writes:

Jonathan> Erik van Roode <newsposter@cthulhu.demon.nl> wrote:
>> Scratchie <AgitatorsBand@yahoo.com> wrote:
>> 
>>> Or just try 
>> 
>>> my @graphics = `ls *.jpg *.gif`;
>> 
>> Which only works if you happen to have a program 'ls' in your path
>> that lists files. Even then, you get a newline after each filename
>> that you have to filter out.
>> 

Jonathan> But the original poster explicitly said that he was using Linux - which
Jonathan> last time I looked had a program ls in its path ...

Jonathan> The newline is trivially dealt with:

Jonathan> chomp(my @files = `ls *.jpg *.gif`);

This solution is still very wrong.

1) what if there's a directory named "foo.jpg" in the current directory?
2) what if a filename has a newline in it?
3) what if there are more names than /bin/sh can handle for an expansion?
4) why fire off a /bin/sh to do the expansion, only then to call ls to verify
   that each of those names exists?

Jonathan> Of course one generally would recommend using
Jonathan> opendir/readdir but there's no point in being dogmatic about
Jonathan> it ...

Yes there is, when it leads to expensive and potentially dangerous
solutions.  And the proper solution is FEWER keystrokes, thus also
winning Perl golf.

  my @files = <*.jpg *.gif>;

Simple and plain, but doesn't handle item #3 above.  For that, you
gotta use readdir.

print "Just another Perl hacker,

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 22 Oct 1999 13:42:18 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: in need of example...
Message-Id: <7uppjq$qob$1@internal-news.uu.net>

Jonathan Stowe <gellyfish@gellyfish.com> wrote:

> But the original poster explicitly said that he was using Linux - which
> last time I looked had a program ls in its path ...

> The newline is trivially dealt with:

> chomp(my @files = `ls *.jpg *.gif`);

I know that ...

> Of course one generally would recommend using opendir/readdir but there's
> no point in being dogmatic about it ...

  Ofcourse, the answer should have mentioned: "this only works on
machines running some flavor of unix". The point I'm trying to make
is that it's better to use code that is not platform dependant.
Fortunately most newbies don't seem to read this group so they
don't get the wrong ideas.

Erik



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

Date: Fri, 22 Oct 1999 13:41:31 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: in need of example...
Message-Id: <slrn810ql1.omc.bmccoy@moebius.foiservices.com>

Also Sprach lt lindley <ltl@rgsun40.viasystems.com>:

>Then we couldn't argue about your Perl (code bloat not
>withstanding).  But your style sense is still fair game.  :-)

Certainly.  Perl has lots of such great conversation pieces, no?

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Fri, 22 Oct 1999 13:44:42 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: in need of example...
Message-Id: <slrn810qr0.omc.bmccoy@moebius.foiservices.com>

Also Sprach Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>:

>>For the benefit of writing portable (and secure) code, using the Perl
>>supplied functions (or modules, if your an OOP geek :-) ) is safer.  What
>                        ^^^^^^^             ^^^
>
>What do modules have to do with objects?  You can have one, the other,
>or both independently.

Sorry, bad nomenclature.  I did put a smiley at the end, though.

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: 22 Oct 1999 12:21:09 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Increase stack size in perl5 ?
Message-Id: <381048a5_2@newsread3.dircon.co.uk>

Helmut Buchner <helmut.buchner@tcs.co.at> wrote:
> Could anyone tell me how i can increase the stack ??
> 
> I wrote a html converter. it works ok for 99% of input files. On to 
> large input files i get the following message:
>>Stack overflow: pid 25550, proc perl5, addr 0x11fdfffe8, pc 0x1200ae8a4
>>Segmentation fault (core dumped)
> 

I would rewrite the program so it doesnt do things that use the stack so
much ... alternatively you will probably need to recompile your perl 
with a compiler option that gives a bigger stack if that is possible
on your platform ...

/J\
-- 
"Some saw Noel Edmonds as a stinking slimy downmarket local rep from a
package holiday firm. His critics were less kind" - Victor Lewis-Smith,
TV Offal


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

Date: Fri, 22 Oct 1999 15:12:26 +0200
From: "Markus Hasenöhrl" <MHasenoehrl@de.lhsgroup.de>
Subject: Is there a module to parse a HTML-file like this?
Message-Id: <381062c1@news.lhsgroup.com>

Hello!

I'am looking for a simple way to extract links from a HTML-file in such a
way that a Text/HREF- hash is build, i.e. from a HTML file containing links
like

<A HREF=/location1>Link1</A> ...  <A HREF=/location2>Link2</A> ... <A
HREF=/location3>Link3</A>

I want to generate a hash (lets say) %Links with

$Links{Link1}="/location1",
$Links{Link2}="/location2",
$Links{Link3}="/location3"...

Is there a module to do such a thing?

Thanks for every hint.




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

Date: Fri, 22 Oct 1999 23:16:02 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Mail::Send module doesn't work on NT
Message-Id: <uUZP3.1$Vd2.1111@vic.nntp.telstra.net>

>
> If you read the ActiveState FAQ, it tells you that you need a command
> line tool for sending mail from WinNT. I recommend that you get a copy
> of BLAT from Tim Charron at http://www.interlog.com/~tcharron/blat.html
>
> After you've installed and configured BLAT (about 2 minutes), just
> modify your script to write the mail to a temporary file and use a
> system() call or backticks to launch BLAT.
> --
> # James Greene - Informatics Consulting - D-79539 Loerrach, Germany
> # http://www.informatics-consulting.com
>

Or download and install sendmail for windows from http://www.demobuilder.com

It is syntactically identical to sendmail on Unix so scripts are more
portable.  It is well worth the $49 if you want to keep it after the 30 day
eval period.

It certainly has made my scripting a whole lot easier!

Wyzelli




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

Date: Fri, 22 Oct 1999 09:53:17 -0200
From: DANIEL HENRIQUE ALVES LIMA <970482@grupiara.dcc.unicamp.br>
Subject: making a "find" shell command
Message-Id: <Pine.GSO.4.10.9910220949490.27536-100000@grupiara.dcc.unicamp.br>


    Please, i would like to know if anyone has a perl code for the
unix shell command "find". 
    
    Could anyone help me ???


						Thanks.


 -----------------------------------------------------------
|          ________                                         |
|   o     |   __   | Daniel Henrique Alves Lima , RA:970482 |
|    \_O  |  |__|  | Ciencia da Computacao 97 / Unicamp     |
| ____/\  |___WW___| E-mail : 970482@dcc.unicamp.br         |
| __/  /      ||                                            |
|             ||                                            |
|             ||                                            |
| ____________||___________________________________________ |
 -----------------------------------------------------------



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

Date: 22 Oct 1999 14:51:27 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: making a "find" shell command
Message-Id: <38106bdf_2@newsread3.dircon.co.uk>

DANIEL HENRIQUE ALVES LIMA <970482@grupiara.dcc.unicamp.br> wrote:
> 
>     Please, i would like to know if anyone has a perl code for the
> unix shell command "find". 
>     

So you havent spoken to your classmates about the likelihood of your 
getting help with your homework here ...

/J\
-- 
"Childbirth is god's way of telling you that heterosexuality isn't
natural. It's got to be easier to get a penis up your arse than a baby
out of your vagina" - Graham Norton


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

Date: Fri, 22 Oct 1999 13:46:16 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: making a "find" shell command
Message-Id: <slrn810qtt.omc.bmccoy@moebius.foiservices.com>

Also Sprach DANIEL HENRIQUE ALVES LIMA <970482@grupiara.dcc.unicamp.br>:

>    Please, i would like to know if anyone has a perl code for the
>unix shell command "find". 

Have you looked at the documentation for find and finddepth, both perl
functions in File::Find?

-- 
Brett W. McCoy                             bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek)   http://www.foiservices.com
FOI Services, Inc./DIOGENES                301-975-0110
---------------------------------------------------------------------------


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

Date: Fri, 22 Oct 1999 14:00:23 +0200
From: Rik Driever <Rik@fast-speed.demon.nl>
Subject: Re: newbie problem writing/reading a file
Message-Id: <lMfvCDAXHFE4IwUa@fast-speed.demon.nl>

Hi All,

I finally solved the problems with the read file. Thanks to your help, I
can display the values from a text file with my perl script. (See below)

#!/usr/local/bin/perl -w
$file = 'score.txt';
open(MYFILE,"<$file") or die "$file: $!\n";
@lines = <MYFILE>;
print "Content-Type: text/html\n\n";
print "<HTML><BODY>";
print "<p>";
print "@lines";
print "</p>";
print "</BODY></HTML>";
close(MYFILE);

but my problem with inserting values from a form still exist, so any
help with that would be appreciated.

I think I should open the file like this:
open(MYFILE,">>$file") or die "$file: $!\n";

but I don't know how to assign the values from my form to a variable in
Perl.

Thanks in advantage,
Rik Driever.

************************************************************************


In article <bjB$2DAoIDE4IwRD@fast-speed.demon.nl>, Rik Driever
<Rik@fast-speed.demon.nl> writes
>Hi all,
>
>As I said in my first posting here, I'm completely new to Perl.
>The code shown below IS my *real* code, and if you say that it won't
>compile...I believe you!
>All I did, was upload the code to my cgi-bin directory and test it, but
>I get errors, so now I want to know what I'm doing wrong. 
>
>>open(MYFILE, >>$file);
>Why is this wrong? Because of the space? According to a tutorial this
>would be the code for appending to a file...right?
>
>>#!/usr/local/bin/perl
>Why add -w? What does it do?
>
>>use strict; 
>What does it? Why use it?
>
>I think you all will have a good laugh at me, because this will seem
>rather stupid, but I have know idea where to find awnsers on questions
>like this, so I hope someone will be so kind to awnser my questions, so
>I can upload a code that actually works.
>
>Greetings Rik Driever.
>
>
>
>
>
>In article <s0uine5gr0160@corp.supernews.com>, Craig Berry
><cberry@cinenet.net> writes
>>Rik Driever (Rik@fast-speed.demon.nl) wrote:
>>: OK I will:
>>: 
>>: #!/usr/local/bin/perl
>>
>>No -w?  No use strict?
>>
>>: #This code is for appending the values to the file 
>>: $file = 'score.txt';            
>>: open(MYFILE, >>$file);          
>>
>>That doesn't even compile!  You're cheating.  Show us your *real* code.
>>
>

-- 
Rik Driever


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

Date: Fri, 22 Oct 1999 12:16:18 GMT
From: Johannes <jspangen@my-deja.com>
Subject: Re: newbie
Message-Id: <7upkig$p5l$1@nnrp1.deja.com>

In article <MPG.1276bc85db15c36a98a0c5@nntp.hpl.hp.com>,
  Larry Rosler <lr@hpl.hp.com> wrote:
> In article <7uige5$pgg$1@nnrp1.deja.com> on Tue, 19 Oct 1999 19:23:01
> GMT, jspangen@my-deja.com <jspangen@my-deja.com> says...
>
> ...
>
> > > I want to do something like the following:
> > >
> > > while ($line = <FILE>) {
> > >    ($word, $number, $array_of_files) = split(" ", $line);
> > >
> > > but how would I get the array_of_files to work?
> > almost correct, try:
> >
> > ...
> > while (defined ($line = <FILE>)) {
> >   ($word, $number, @files) = split / /,$line;  # @files = array
>
> 'split / /' is not the same as 'split " "'.
>
> >   $word =~ s/^.*:$/; # ;-)
>
> What did you intend by that non-compilable line of code?  Is that why
> there is a smiley?

Upps sorry, looks like I typed a little bit to fast. But it should
compile anyway. Of course you should use split " ", $line;
or:

open FILE, "$dat" or die "Can't open $dat:$!\n";
while (<FILE>) {
        my ($word, $number, @files) = split;
        chop $word; # get rid of the :
        foreach $file (@files) {print "$file\n";}
}
close FILE;

>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>


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


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

Date: Fri, 22 Oct 1999 13:13:29 GMT
From: xxaxx@my-deja.com
Subject: Re: Passing function as parameter.
Message-Id: <7upntn$rji$1@nnrp1.deja.com>

Thanks to all for the great feedback and suggestions.
The perldoc suggestion was good.
I will also look at the existing FIND function.

Since I'm basically self-taught in PERL it is extremely easy to not know
about very useful references and existing functions. That is one of the
unfortunate aspects of not having formal training in a subject and not
working as part of a larger team. In addition I've had to be careful of
any material which relies upon modules which are not part of the basic
PERL system. I'm developing for websites hosted by low-end servers which
allow private cgi-bin directories but freakout at the prospect of
installing a new module. One I'd love to have access to but can't get
the ISPs to install is the LWP system.

Thanks again for the help.
Claude Needham


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


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

Date: 22 Oct 1999 12:56:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl and NT IIS4
Message-Id: <381050e8_1@newsread3.dircon.co.uk>

Tom Dawson <tomd@istar.ca> wrote:
> We recently got a copy of Apian's Survey Pro with its Net.Collect module to
> provide web enabled surveys.
> 
> The paper based version of this is great but I have been struggling trying
> to get the .pl file to run on our IIS 4 server.
> 

Download and install the latest ActivePerl from <http://www.activestate.com>
and then read the instructions in the documentation installed regarding
configuring the server to work with Perl.

Further IIS questions should be directed to the group

   comp.infosystems.www.servers.ms-windows


/J\
-- 
"You're blowing me off for a monkey?" - Joey, Friends


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

Date: Fri, 22 Oct 1999 09:58:21 -0400
From: "Munish Suri" <msuri@recruitsource.com>
Subject: Perl Exam Beta Testers Required - How good are you?
Message-Id: <s10rjhqpr0110@corp.supernews.com>

My company is working on an online technical screening system that is
to-be-shortly released. We are looking for experienced individuals to test
our Perl exams.

Please respond ASAP if you are interested.

Thanks,

Munish Suri
Exam Development
RecruitSource
msuri@recruitsource.com




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

Date: 22 Oct 1999 12:03:42 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: perl for win32 and date
Message-Id: <7upjqu$pkh$1@solti3.sdm.de>

In article <7unj3j$c1m$1@nnrp1.deja.com>,
BabyHawk <Baby_Hawk@hotmail.com> wrote:

> within a perl script under winNT and activestate perl i want to
> determine to which number of week (1...52) the day before belongs to.
> How can that be done?

Install Date::Manip or Date::Calc which come with your ActiveState Perl
or are available from the ActiveState's web site in binary form.

To compile yourself and install, download these modules from
    http://www.perl.com/CPAN/modules/by-module/Date/
and follow their installation instructions (basically "perl Makefile.PL;
nmake; nmake test; nmake install" for MS VC++, and "dmake" instead of
"nmake" for Borland C++).

HTH.
-- 
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)


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

Date: 22 Oct 1999 12:38:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Redundant POD (was Re: Underlying data structure behind blessed reference.)
Message-Id: <38104cac_2@newsread3.dircon.co.uk>

Jeff Pinyan <jeffp@crusoe.net> wrote:
> =cut
> 
> =begin FOR HUMANS
> 
> This message can be sent through pod2text (or any other converter).  It is
> readable in this format, though.  You can check
> 
>   perldoc perlpod
> 
> for more information on this handy documentation markup.
> 
> =end FOR HUMANS
> 

Jeff why are you doing this ?  You are preaching to the choir as regards 
anyone who will be in a position to do anything with the article other
than look at  it in their browser - the people who dont know what POD
is and how to view it are also unlikely to know how to extract the text
from the article and save it as the appropriate file type ... I would
also be interested to know what the proportion of people who will read
this will be seeing it on Deja News wherein all bets are off ...

As far as *I* am concerned seeing all this (redundant) stuff at the top
of the  post just disinclines me to read the article.

/J\
-- 
"Mr Creutzfeldt and Mr Jakob: No-one had ever heard of these two eminent
medical men until someone had the


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

Date: Fri, 22 Oct 1999 07:57:26 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Redundant POD (was Re: Underlying data structure behind blessed reference.)
Message-Id: <Pine.GSO.4.10.9910220755410.15158-100000@crusoe.crusoe.net>

On Oct 22, Jonathan Stowe blah blah blah:

> As far as *I* am concerned seeing all this (redundant) stuff at the top
> of the  post just disinclines me to read the article.

I do it to help introduce less experienced Perl folk to the concept of
POD, the proximity of the docs via perldoc; but also because I find it
helps me structure my response in a way that helps the receiver the most.
If people would prefer, I will run my POD answer through pod2text before
posting it.

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

Date: Fri, 22 Oct 1999 07:13:23 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Reference challenge
Message-Id: <Pine.GSO.4.10.9910220704420.15158-100000@crusoe.crusoe.net>

In fact, here is a pseudo-builtin function, realref.

NOTE:
  I had to employ craftiness to get around the satanic (;$) prototype,
  which shits out here:

    print realref $foo, "\n";

  If realref had a prototype of ;$, this would give me a "too many args"
  error.  This kind of upsets me.  I mean, the prototype of ref is ;$ as
  well, but it is a true builtin, so it gets special treatment.

  Notice my craftiness of the ;$@ prototype.


So here is my realref function.


  BEGIN { realref (;$@) }  # allows sans-parens calls
                           # or just place the whole damn thing in BEGIN

  sub realref (;$@) {
    my $obj = shift;
    $obj = $_ unless defined $obj;
    my $type = ref $obj;
    my $ret;

    unless ($type =~ /./){ wantarray ? return ("", @_) : return }

    $obj =~ s/^\Q$type=//;
    ($ret) = $obj =~ /([A-Z]+)\(0x[a-f0-9]+\)\z/;
    wantarray ? return ($ret, @_) : return $ret;
  }

I call this a pseudo-builtin, because you can use it the following ways:

  print realref($a), "\n";
  print realref $a, "\n";
  print realref, "\n";    # defaults to $_, which is local() at worst
  print realref(), "\n";  # ditto

The function returns false if it must, but it also returns the other
arguments to it, so you can use it like you would use any other function.

Does this measure up, Sean?

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

Date: Fri, 22 Oct 1999 09:32:47 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: REFERENCE CHALLENGE: final (?) realref() test
Message-Id: <Pine.GSO.4.10.9910220928540.15158-100000@crusoe.crusoe.net>

Following is a test of two realref() functions that I have found to work
perfectly.  The realref2 function uses no regular expressions, while
realref1 does.  I've found realref2 to be just a bit faster on my machine.

If people would like to try for themselves, go right ahead.  Report any
bugs you find.  I'll be happy to send along documentation to anyone
curious enough.



#!/usr/bin/perl

use Benchmark qw( timethese );
use strict;

sub realref1 (;$@);
sub realref2 (;$@);

my @test = (
	bless([], "FOO"),
	bless({}, "BAR"),
	sub {},
	"ARRAY(0xfffff)",
	bless([], "HASH=ARRAY"),
	bless({}, "This\nIs\nFruity=ARRAY(0xffffff)"),
	bless([], ""),
	bless({}),
	bless(sub {}, "GLOB"),
	"ARRAY(0xfffff)",
	bless(\*STDOUT, "HASH=ARRAY"),
	bless(\[], "This\nIs\nFruity=ARRAY(0xffffff)"),
);

timethese(300000, {
	'1 - regex' => q{ for (@test){ $ref = realref1 } },
	'2 - str' => q{ for (@test){ $ref = realref2 } },
});


sub realref1 (;$@) {
	my $save = my $obj = (defined $_[0] ? shift : $_);
	my ($type,$ret) = ref $obj;
	wantarray ? return (undef, @_) : return unless $type =~ /./;
	$obj =~ s/^\Q$type=//;
	($ret) = $obj =~ /([A-Z]+)\(0x[a-f0-9]+\)$/;
	$ret = "REF" if
		(caller())[3] ne "main::realref1" and
		$ret eq "SCALAR" and
		realref1($$save);
	wantarray ? return ($ret, @_) : return $ret;
}


sub realref2 (;$@) {
	my $save = my $obj = (defined $_[0] ? shift : $_);
	my ($type,$ret) = ref $obj;
	wantarray ? return (undef, @_) : return unless $type =~ /./;
	my $lhs = (index($obj,"$type=") != -1 and length("$type="));
	$ret = substr($obj,$lhs,rindex($obj,"(")-$lhs);
	$ret = "REF" if
		(caller())[3] ne "main::realref2" and
		$ret eq "SCALAR" and
		realref2($$save);
	wantarray ? return ($ret, @_) : return $ret;
}


-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

Date: Fri, 22 Oct 1999 11:51:24 GMT
From: c_j_marshall@my-deja.com
Subject: Re: sorting hashes in an array of hashes
Message-Id: <7upj3r$o2c$1@nnrp1.deja.com>


> # This, IMO, is much better and cleaner
> foreach my $href (@ptr)
> {
> 	print "\n";
> 	foreach my $term ( sort { $href->{$a} <=> $href->{$b} } keys %{$href}
)
> 	{
> 		print "$term -> $href->{$term}\n";
> 	}
> }
>

This worries me because my first reaction to accessing an array of
hashes would be:

foreach my $hash_ref (@array)
{
	# de-ref the hash
	my %hash = %$hash_ref;
	foreach my $keyfield (sort keys %hash)
	{
		print "$keyfield : $hash{$keyfield}\n";
	}
}

I don't doubt for a minute this is the slowest and least efficient way
of doing things - but would like to learn why.

Cheers,
Chris



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


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

Date: Fri, 22 Oct 1999 13:46:05 GMT
From: dsparling <dsparling@my-deja.com>
Subject: Re: stealing the news: how hard can it be?
Message-Id: <7uppqs$t0m$1@nnrp1.deja.com>

In article <7uo8pu$5v2$5@nickel.uunet.be>,
  michel.dalle@usa.net (Michel Dalle) wrote:
> In article <7uo0ai$lvj$1@nnrp1.deja.com>, dsparling <dsparling@my-
deja.com> wrote:
> >I'm curious of the legal ramifications if I want to do this on a
> >commercial site...I've written a Perl CGI script to pull weather info
> >from rainorshine.com that I'd like to use on one of my projects.
> >
> Have you checked with the original site to see what their copyright
policy
> is ?
>
> I would imagine that they would be quite unhappy if you simply rip
> off everything and do as if YOU provided that service.
> But a limited extract with a pointer to the originating site may make
> them happy...
>
> >Sent via Deja.com http://www.deja.com/
> >Before you buy.
>
> Now why would I want to buy Deja.com ?
>
> Michel.

It turns out that they offer a free service anyways. However, I do
agree with your assesment. At least I got to learn LWP.
>


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


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

Date: 22 Oct 1999 14:55:54 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Using "use strict" and "Getopt" together
Message-Id: <38106cea_2@newsread3.dircon.co.uk>

c_j_marshall@my-deja.com wrote:
> 
> I've been perling for a couple of years now - and I try to be a good boy
> and use 'use strict' all the time.
> 
> But for the life of me I have been unable to get a clean compile and
> working code whenever I use the Getopt module (which I am fairly reliant
> on).
> 

This is explicitly addressed in the manpage for Getopt::Std :

       Note that, if your code is running under the recommended
       use strict 'vars' pragma, it may be helpful to declare
       these package variables via use vars perhaps something
       like this:

           use vars qw/ $opt_foo $opt_bar /;

       For those of you who don't like additional variables being
       created, getopt() and getopts() will also accept a hash
       reference as an optional second argument.  Hash keys will
       be x (where x is the switch name) with key values the
       value of the argument or 1 if no argument is specified.



/J\
-- 
"Mr Creutzfeldt and Mr Jakob: No-one had ever heard of these two eminent
medical men until someone had the


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

Date: Fri, 22 Oct 1999 14:23:11 +0200
From: John McNamara <jmn.ac.delete@abanet.it>
Subject: Re: WIn32::OLE
Message-Id: <DVQQOCPsbed=0Aw+yA8CojRLL5Vc@4ax.com>

On Fri, 22 Oct 1999 09:32:05 +0200, "williams, mark"
<mwilliams@europarl.eu.int> wrote:

>I would like to use Excel for something like this  
>
>(Neat but does not work)
>	$Sheet->Range("A1")->{WorksheetFunction.Sum}= 'B1:B499';
>
>This is not  neat but works
>	$Sheet->Range("A1")->{Value}= "=SUM(R[1]C[1]:R[499]C[1])";

If neat means the A1 format as opposed to the R1C1 format, then
try the following:

# A1 format: Returns formula
  $Sheet->Range("A2")->{Value}   = "=SUM(B1:B499)";

# More flexible:
  $myrange = "B1:B499";
  $Sheet->Range("A3")->{Value}   = "=SUM($myrange)";

# A1 format: Also returns formula
  $Sheet->Range("A4")->{Formula} = "=SUM(B1:B499)";

# Example calling WorksheetFunction: Returns result not formula
# $xlApp is whatever Win32::OLE->new() returned
  $ Sheet->Range("A5")->{Value}   =
$xlApp->WorksheetFunction->SUM($Sheet->Range("B1:B499"));


Try recording some Excel macros to see how the VBA syntax works
and translate that to Perl.

HTH,

John McNamara



---------------------------------------------------
The Mosiac code has replaced the law of the jungle.
                               James Joyce, Ulysses


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

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


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