[11193] in Perl-Users-Digest
Perl-Users Digest, Issue: 4793 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 31 23:07:19 1999
Date: Sun, 31 Jan 99 20:00:18 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 31 Jan 1999 Volume: 8 Number: 4793
Today's topics:
Re: advertising script problem (Abigail)
Re: CGI form processing <chromyak@usa.net>
DBI and Win32::ODBC - build or download???? <tomw@action.cnchost.com>
Re: HELP!!! Using XS With C++ <chloe_fung@hotmail.com>
how to code a between() with regex? (Duane Lunday)
Re: how to code a between() with regex? (Sam Holden)
Match first character of string? <delphine@qx.net>
Re: Match first character of string? (Sam Holden)
Re: ok please don't shoot me for this question (Abigail)
Re: ok please don't shoot me for this question (Abigail)
Re: Perl Crashes IIS4! (Abigail)
Re: Perl Crashes IIS4! <Richard.Walker@west-server.com>
Re: Perl Crashes IIS4! (Sam Holden)
Re: Perl Criticism [summary] <mds-resource@mediaone.net>
Re: Perl Criticism (Sam Holden)
Re: Perl Criticism (Sam Holden)
Re: Perl Criticism (Leslie Mikesell)
Regexp problem [possible] ()
Re: Using integers in perl (Tyler Hutcheon)
Re: Using integers in perl (Andre L.)
Re: Visual Perl? <jdf@pobox.com>
Writing binary files after reading <ricks@acpub.duke.edu>
Re: Writing binary files after reading (Sam Holden)
Re: Writing binary files after reading <jdf@pobox.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Feb 1999 02:03:59 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: advertising script problem
Message-Id: <79322f$hds$6@client2.news.psi.net>
myname@mydomain.com (elst.fels@nospam.ping.be) wrote on MCMLXXVIII
September MCMXCIII in <URL:news:78ubsr$a3f$1@news3.Belgium.EU.net>:
-- Can anyone give me an idea how to make a script that:
--
-- - displays one bannerimage for instance 50% of the time
-- and other banners at an other percentage of time.
-- - it is not the idea to show the same banner time and time over till the 50%
-- is done
-- it must come between the other banners otherwise the advertising is not
-- balanced over time.
There's nothing Perl specific to your question, is there?
The easiest solution: don't display banners at all. Then 50% of the shown
banners are the one banner. And each of the other banners also take 50%
of the sightings! You can charge your customers more! Each ad is shown
50% of the times ads are shown!
Abigail
--
perl -we '$@="\145\143\150\157\040\042\112\165\163\164\040\141\156\157\164".
"\150\145\162\040\120\145\162\154\040\110\141\143\153\145\162".
"\042\040\076\040\057\144\145\166\057\164\164\171";`$@`'
------------------------------
Date: Mon, 1 Feb 1999 00:33:57 -0300
From: "Kostyantyn Chromyak" <chromyak@usa.net>
Subject: Re: CGI form processing
Message-Id: <Pj9t2.16$6b.983202@news.randori.com>
Hi!
First of all, this question is not perl-specific
and therefore this group is not the best place to
post it. You need web-programming and it is *not*
exactly perl (however perl can be used and frecuently
is used for this purpose). You should look for help
in (for example) comp.infosystems.www.authoring.cgi
or comp.lang.javascript rather then comp.lang.perl.misc.
Secondly, the answer is *yes*, you can do it
with perl using CGI or any other server-side
technology, and can do the job with client-side
programming too; what is the best for you,
depends on your biases ;-) and (alas!) details
about the error you want to be processed.
For example, if your user have forgotten
to type his address in mail order form,
you can detect this error in situ, and process it
locally, without quering a server; javascript
or vbscript or (if your browser support it!!!)
client-side perl all are appropiate for this
purpose; this way you win the performance.
But if the problem is that (for example) your
database can't save the duplicate record, you
probably don't know about this error before submit
the data to server-side script. This way you
could process the first error (empty field) too.
Server-side processing is much more universal,
secure and flexible. But you pay for it by
loosing the performance.
What I am trying to say you is that the optimal
solution depends on many details and in many cases
the best way is to combine the server-side and
client-side processing for different errors.
You can find a lot of books in virtually
every bookstore; there are a lot of tutorials
in web; you have to search for CGI or javascript.
And of course you have to write this short
script in language of your choice.
If you will need the professional help,
(i.e. to outsource this job), let me know.
It is simple and therefore is not expensive.
But I'll need more details.
Good luck. Kostyantyn.
--
__________________________________
The best solutions in programming, physics,
electronics and automatic control.
To reply delete ".NOSPAM" from reply address.
I don't read (filter!) letters from well-known spammers.
I don't read(filter) anything @yahoo.com
e-mail: <chromyak@usa.net.NOSPAM>
________________________________
ICQ 13497907, tel. (54-11) 4811-7913
(ukranian, spanish, english, russian)
Kostyantyn Chromyak
________________________________
Olivier escribis en mensaje <36b3ec40.0@news.one.net>...
>Hello,
>
>I am new to PERL. I am lookng to process a form . I found a lot of
>freeware but nothing that does what I want. Usually when there is some
>error checking done on the form input, the error message appears on a
>separate HTML page which end by " please go back, etc...". I'd like to
>generate my error message at the top of the actual form which would
still
>contain the answers previously given by the user. Is this doable in
PERL ?
>If so is there any code out there I could start from ?
>
>Thank you for any help,
>
>Olivier
>
>
------------------------------
Date: 31 Jan 1999 17:56:56 PST
From: Tom Williamson <tomw@action.cnchost.com>
Subject: DBI and Win32::ODBC - build or download????
Message-Id: <36B50605.8F4DD282@action.cnchost.com>
I am working on a Perl project on Windows NT, trying to connect to
MS-SQL Server. (I know this is going over great with the Solaris and
Oracle folks.) Anyway, I have never worked with Perl before. I have
inherited some legacy code from the previous programmer which uses
DBI::W32ODBC and Win32::ODBC modules, neither of which I have.
I downloaded and installed Perl from ActiveState and have the basic Perl
5 modules. The previous programmer on the project swears that DBI came
with his Perl installation and that he was able to download and install
a pre-built version of Win32::ODBC.
I am already way behind on this project from having to come up to speed
on Perl itself. I am really hoping that I can download and install
these modules from someplace, and avoid having to build them from
scratch. Is there anyone out there who can point me to a location where
I can get pre-built DBI and Win32::ODBC?????? Or, to put it more
bluntly - HELLLLLLP!
Thanks - Tom
tomw@action.cnchost.com
------------------------------
Date: Mon, 1 Feb 1999 10:21:00 +0800
From: "Chloe" <chloe_fung@hotmail.com>
Subject: Re: HELP!!! Using XS With C++
Message-Id: <7932oh$d2s$1@imsp009a.netvigator.com>
Hi Edwin,
Thanks for your message. I didn't declare functionA as "extern int C"
before. However, when I tried, I found I can't just declare functionA as
extern "C" as it is a member function of my C++ class. I have tried
declaring the whole C++ class as extern "C". The result is still the same.
Actually, I can call the member function functionA with correct in and out
parameters and return value. The only problem I got is functionA can't
correctly access the data members set in the constructor since functionA is
using another object reference from the constructor. I don't know why the
object references for functionA and constructor are different as on the perl
side they are the same.
I suspect one problem may be in the typemap file, I wrote:
OUTPUT
O_OBJECT
sv_setref_pv($arg, CLASS, (void*) $var);
Will this function bless another object reference to return to perl so that
the object reference that is returned to perl is another C++ object
reference which is not the one that I have just called constructor for.
Does Edwin or anybody encounter this before?
Thanks a lot for your kindest help.
Chloe
Edwin Litterst wrote in message <36b44961.7599090@news>...
>>I have been trying to write a perl module which invokes functions in its
C++
>>counterpart object, based on the perlxs documentation. I create a C++
>>object in the perl module like,
>> $c_obj = MyClass::new("MyClass"); // this constructor
>>initializes some data members in the C++ object
>>
>>and then invoke the C++ function like,
>> $c_obj->functionA();
>
>Did you declare functionA as "extern int C"?
>
>Eddie
>
------------------------------
Date: Mon, 01 Feb 1999 01:10:39 GMT
From: dlunday@airmail.net (Duane Lunday)
Subject: how to code a between() with regex?
Message-Id: <1103_917831699@c690507-a>
I've been poring over the online faqs as well as "Perl 5 Complete", and can't find an example of what
i need.
Basically here's some pseudo code of what i want...
My $var = " 3] (Kinda_Weird_Filename) With Some Spaces.EXE :::SIZE 1024k" #this comes
from a file read..
#here's what i'd usually do:
My NewVar$ = Between( $var, '] ', ".EXE")
In other words, return a substring of $var that starts with ']' (exclusive) and
ends with ".EXE" (inclusive)
or put YET another way, I want to see NewVar$ look like this:
NewVar$ = "(Kinda_Weird_Filename) With Some Spaces.EXE"
Also (sorry), if i was going to search thru say 10000 lines for this string, would it be
easier/better/faster/cooler to save NewVar$ to a hash or array?
Thanks in advance,
Duane Lunday
canter@bigfoot.com
------------------------------
Date: 1 Feb 1999 01:42:29 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: how to code a between() with regex?
Message-Id: <slrn7ba1k5.4tu.sholden@pgrad.cs.usyd.edu.au>
On Mon, 01 Feb 1999 01:10:39 GMT, Duane Lunday <dlunday@airmail.net> wrote:
>I've been poring over the online faqs as well as "Perl 5 Complete", and can't find an example of what
>i need.
May I suggest :
perldoc perlsyn
perldoc perlre
>
>Basically here's some pseudo code of what i want...
Some code that you tried but which didn't work would be much more useful.
>
>My $var = " 3] (Kinda_Weird_Filename) With Some Spaces.EXE :::SIZE 1024k" #this comes
>from a file read..
>#here's what i'd usually do:
>My NewVar$ = Between( $var, '] ', ".EXE")
>
>In other words, return a substring of $var that starts with ']' (exclusive) and
>ends with ".EXE" (inclusive)
>or put YET another way, I want to see NewVar$ look like this:
>NewVar$ = "(Kinda_Weird_Filename) With Some Spaces.EXE"
You could try something like :
/\] (.*\.EXE)/
Of course by the look of your code which is contains at least one obvioud perl
syntax error on each line you mightn't understand that.
I can only suggest that you read the documentation that comes with perl.
>
>Also (sorry), if i was going to search thru say 10000 lines for this string, would it be
>easier/better/faster/cooler to save NewVar$ to a hash or array?
It depends entirely on how you are going to access them later...
--
Sam
You can blame it all on the internet. I do...
--Larry Wall
------------------------------
Date: Sun, 31 Jan 1999 22:32:14 -0500
From: Delphine Coupal <delphine@qx.net>
Subject: Match first character of string?
Message-Id: <36B5203E.567209D4@qx.net>
What's the easiest way to match the first non-space character of
a string?
What I'm trying to do is capitalize the first word in a
sentence..
Thank you!
------------------------------
Date: 1 Feb 1999 03:45:27 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Match first character of string?
Message-Id: <slrn7ba8qn.9bg.sholden@pgrad.cs.usyd.edu.au>
On Sun, 31 Jan 1999 22:32:14 -0500, Delphine Coupal <delphine@qx.net> wrote:
>What's the easiest way to match the first non-space character of
>a string?
>
>What I'm trying to do is capitalize the first word in a
>sentence..
You would start by learning perl and reading documentation that comes with
perl. The perlfunc, perlfaq4, and perlre manuals would be of assistance.
--
Sam
Perl was designed to be a mess (though in the nicest of possible ways).
--Larry Wall
------------------------------
Date: 1 Feb 1999 01:54:08 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: ok please don't shoot me for this question
Message-Id: <7931g0$hds$4@client2.news.psi.net>
Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote on MCMLXXVIII
September MCMXCIII in <URL:news:1dmf91o.1g1xn61t6fghcN@bay1-458.quincy.ziplink.net>:
$$
$$ Yes, judging from the number of people who come to clpm asking for help
$$ with actually getting Matt's scripts to work, Matt's Script Archive is
$$ depressingly popular. Specifically, they are outdated, buggy, and
$$ unsupported, and they don't do such things as error checking or file
$$ locking.
And unless someone sets up a site with better scripts offering at least
the same functionality, Matt's Archive will remain popular, no matter
how often it's said those scripts are outdated, buggy and unsupported.
Abigail
--
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
for (??;(??)x??;??)
{??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'
------------------------------
Date: 1 Feb 1999 01:57:36 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: ok please don't shoot me for this question
Message-Id: <7931mg$hds$5@client2.news.psi.net>
Randal L. Schwartz (merlyn@stonehenge.com) wrote on MCMLXXIX September
MCMXCIII in <URL:news:m1pv7vk0j0.fsf@halfdome.holdit.com>:
## >>>>> "Murali" == Murali Ravipudi <myparu@_usa_.net> writes:
##
## Murali> How about putting up all the scripts made by people in clpm at
## Murali> some site ( if the owner is willing to share it ) , so that we
## Murali> can direct newbies there, where we know everything is mostly
## Murali> perfect and all that... :)
##
## OK, <type type type> there... done!
##
## Actually, it was done a long time ago.
##
## It's called the CPAN. There are dozens of mirrors all around the world.
## Find your closest using the redirector at www.perl.com/CPAN/, or just
## hop to www.cpan.org.
Uhm, CPAN/scripts/CGI is depressingly empty.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|8;
.qq;8768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F;
.qq;76777$=56;;$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V
/=$^U}while$^V!=$^W'
------------------------------
Date: 1 Feb 1999 01:51:44 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl Crashes IIS4!
Message-Id: <7931bg$hds$3@client2.news.psi.net>
Richard Walker (Richard.Walker@west-server.com) wrote on MCMLXXIX
September MCMXCIII in <URL:news:36B4BD6C.E32145D7@west-server.com>:
&& I R A Aggie wrote:
&& >
&& > In article <790p07$92m$4@client2.news.psi.net>, abigail@fnx.com wrote:
&& >
&& > + Richard Walker (Richard.Walker@west-server.com) wrote on MCMLXXVIII
&& > + September MCMXCIII in <URL:news:36B39BAF.60761156@west-server.com>:
&& > + **
&& > + ** Every time I run a PerlScript in ASP that uses IO::Sockets, it executes,
&& > + ** then promptly shuts my IIS4 server down.
&& > +
&& > + Sounds like a bug in IIS to me.
&&
&& Why does this sound like a bug?
A server that calls an external program should not shut down regardless
of what that external program does. Even if ActiveState, or the Perlscript
are buggy as hell, the server should not shut down.
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Sun, 31 Jan 1999 21:59:10 -0500
From: Richard Walker <Richard.Walker@west-server.com>
Subject: Re: Perl Crashes IIS4!
Message-Id: <36B5187E.EE32BD1C@west-server.com>
Abigail wrote:
>
> Richard Walker (Richard.Walker@west-server.com) wrote on MCMLXXIX
> September MCMXCIII in <URL:news:36B4BD6C.E32145D7@west-server.com>:
> && I R A Aggie wrote:
> && >
> && > In article <790p07$92m$4@client2.news.psi.net>, abigail@fnx.com wrote:
> && >
> && > + Richard Walker (Richard.Walker@west-server.com) wrote on MCMLXXVIII
> && > + September MCMXCIII in <URL:news:36B39BAF.60761156@west-server.com>:
> && > + **
> && > + ** Every time I run a PerlScript in ASP that uses IO::Sockets, it executes,
> && > + ** then promptly shuts my IIS4 server down.
> && > +
> && > + Sounds like a bug in IIS to me.
> &&
> && Why does this sound like a bug?
>
> A server that calls an external program should not shut down regardless
> of what that external program does. Even if ActiveState, or the Perlscript
> are buggy as hell, the server should not shut down.
Consider this scenario. What if I found a web site that allowed me to
execute /usr/bin/perl (say it is an alias on the web directory tree),
and I sent an argument to run a shell command to shut down the web
server. Does that mean that that web server software is buggy?
--
What is time? If no one asks me, I know; if I wish
to explain to one who asks, I do not know.
-- St. Augustine
------------------------------
Date: 1 Feb 1999 03:20:47 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Crashes IIS4!
Message-Id: <slrn7ba7cf.7gf.sholden@pgrad.cs.usyd.edu.au>
Richard Walker <Richard.Walker@west-server.com> wrote:
>Abigail wrote:
>>
>> Richard Walker (Richard.Walker@west-server.com) wrote on MCMLXXIX
>> September MCMXCIII in <URL:news:36B4BD6C.E32145D7@west-server.com>:
>> && I R A Aggie wrote:
>> && >
>> && > In article <790p07$92m$4@client2.news.psi.net>, abigail@fnx.com wrote:
>> && >
>> && > + Richard Walker (Richard.Walker@west-server.com) wrote on MCMLXXVIII
>> && > + September MCMXCIII in <URL:news:36B39BAF.60761156@west-server.com>:
>> && > + **
>> && > + ** Every time I run a PerlScript in ASP that uses IO::Sockets, it executes,
>> && > + ** then promptly shuts my IIS4 server down.
>> && > +
>> && > + Sounds like a bug in IIS to me.
>> &&
>> && Why does this sound like a bug?
>>
>> A server that calls an external program should not shut down regardless
>> of what that external program does. Even if ActiveState, or the Perlscript
>> are buggy as hell, the server should not shut down.
>
>Consider this scenario. What if I found a web site that allowed me to
>execute /usr/bin/perl (say it is an alias on the web directory tree),
>and I sent an argument to run a shell command to shut down the web
>server. Does that mean that that web server software is buggy?
No it means the web server configuration is buggy, since you shouldn't be able
execute arbitrary programs and code on the web server. The bug mightn't be
in the server, but it's in the administrator for being so brain-dead.
A CGI script should not have permission to shut down the web server anyway,
unless you really trust your users (and so qualify as brain-dead I guess).
The bug is still server related and not external program related though.
--
Sam
Just don't create a file called -rf. :-)
--Larry Wall
------------------------------
Date: Sun, 31 Jan 1999 18:00:27 -0600
From: "Michael D. Schleif" <mds-resource@mediaone.net>
Subject: Re: Perl Criticism [summary]
Message-Id: <36B4EE9B.69470877@mediaone.net>
topmind@technologist.com wrote:
>
> In article <36B40A41.B3A8CA99@mediaone.net>,
> "Michael D. Schleif" <mds-resource@mediaone.net> wrote:
>
> > topmind@technologist.com wrote:
> >
> > > So you propose living with archaic, silly, illogical, inconsistant systems
> to
> > > benefit those who have the ability to master illogical cryptology?
> > >
> > > I sentence you to read and write ONLY in Chinese characters!
> >
> > And this is your `technical' argument?
> >
> > Sorry, but I've already stated that English is my language, which you've
> > also insulted; but, I'll stay with it anyway. It suits me.
> >
> > In fact, as you may know, the bard William Shakespeare used English to
> > great advantage. As well as linguists such as Chomsky and another of
> > whom you may have heard, Larry Wall.
> >
> > Of course, they all took pride in their spelling, grammar and syntax.
> > Could this be _why_ none of them are rushing to transmogrify Perl }:-^
> >
> > Perhaps, you would trivialize Sanskrit and Hebrew, too, for their great
> > learning curves? It seems that that attitude would dismiss some of the
> > world's most important philosophy -- unless, of course, Big Brother
> > topmind, is about to impart profound wisdom to us, his eager acolytes,
> > after which we will no longer need the words of Jesus nor Buddha ???
>
> Are we talking art and asthetics or productivity?
Seriously, topmind, I'm sorry if we are wearing you to a frazzle; but,
please, read your own comments.
How can any of us be truly productive without *art* in our lives?
Without discipline? Without appreciation for the truly beautiful that
surrounds us, in fact, totally immerses us in an amazing universe that
can only be approximated by fractals?
Without spelling, grammar and syntax, language is reduced to some
proprietary encryption, to which none of us are privy. Of course, in
that context, we truly *do not* understand what it is you mean to say,
because you have intentionally obfuscated your meaning in repeated
violations of commonly accepted standards for language, whether spoken,
written or compiled.
In so doing, do you *not* actually violate the English language
identically to how you accuse Perl programmers of obfuscating source
code?
Let's simplify. In which specific and significant ways do spoken
languages and computer programming languages differ? Are they both
fundamental to some intrinsic need to communicate? Are they not both
subject to some potential curse of Babel? Is it not possible that you
are as guilty, with English and other commonly spoken languages, of
precisely that about which you accuse us Perl aficionados?
None of this, mind you, is intended to ratify your criticisms of Perl
nor Perl users; rather, is this *not* the proverbial pot calling the
kettle black?
And lastly, I've rarely encountered intelligent life likely to be moved
from their own viewpoint solely on the merit of another's criticism.
Usually, it takes presentation of succinct hypotheses that can be
rigorously tested and correlated to that original viewpoint. Only when
these new hypotheses are demonstrably superior to the older, diproven
dogma, only then are others likely to be persuaded. Hence, the common
request for working examples of your theories.
This is called the scientific method. Although, typically thought to be
a product of western thinking, it has worked for the likes of
Copernicus, Martin Luther, Isaac Newton, Leonardo da Vinci, Albert
Einstein and Larry Wall. I humbly suggest that you consider the merits
of such a system -- you will sleep much better at night ;)
--
Best Regards,
mds
mds resource
888.250.3987
"Dare to fix things before they break . . . "
"Our capacity for understanding is inversely proportional to how much we
think we know. The more I know, the more I know I don't know . . . "
------------------------------
Date: 1 Feb 1999 00:50:57 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Criticism
Message-Id: <slrn7b9ujh.4tu.sholden@pgrad.cs.usyd.edu.au>
On Sun, 31 Jan 1999 22:26:52 GMT, topmind@technologist.com wrote:
>In article <36B27526.5F4D4B6A@mediaone.net>,
> "Michael D. Schleif" <mds-resource@mediaone.net> wrote:
>>
>> topmind@technologist.com wrote:
>> >
>> > Yes, they confused me, and I am NOT A DUMB PERSON!
>>
>> Debatable; but, definitely *not* worth the bandwidth }:-^
>>
>> > If they confuse me, I guarentee they will confuse a good many
>> > programmers, perhaps a majority.
>>
>> Even if we accept `majority,' what does that have to do with the
>> integrity of Perl?
>
>
>I was talking about referants/pointers in Perl, not Perl in general.
>
>Their Power-to-Confusion ratio is not very high.
If you honestly believe this then I'm sorry to say that you are a dumb
person. References are one of the most powerful constructs in procedural
programming. Object Oriented programming tends to rely on them as an
almost the fundamental building block.
References allow the existance of data structures such as trees. You can
claim all you want that you don't need them but if you do you are simply
wrong. Take a graph for example, each node can have 0 or more edges which
lead to other nodes. If you didn't have references how would you point
to those other nodes?
You could construct a matrix representation of the graph, but that gets
out of hand for graphs with huge numbers of nodes (especially if there are
not many edges).
So please explain how you would represent a large sparse graph without
references in a reasonably efficient way. Soft references count as references
as well (they are in fact messier than real references since there is not as
much information telling the reader of the code that that is a reference and
not some other information).
Please email me your answer since I'm honestly interested if you know of an
such an method (I don't claim to know everything about graphs specifically
or computer science in general - in fact I have been very impressed by the
ingenuity in a number of data structures I have seen which manage to do things
that I would never have thought of. Email is sholden@cs.usyd.edu.au but that
should be obvious anyway.
Oops, I replied to a troll again...
Anyway I await your explanation (taking it to only mail would be good, since
most people really don't want to hear I suspect).
--
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: 1 Feb 1999 01:03:04 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Perl Criticism
Message-Id: <slrn7b9va8.4tu.sholden@pgrad.cs.usyd.edu.au>
On Sun, 31 Jan 1999 23:03:13 GMT, topmind@technologist.com wrote:
>Reply to Kirby Krueger (1/29):
>
>>> Passing more than one complex parameter to a function (such as arrays and
>hashes.) <<
>
>Why are pointers necessary for this? Other
>languages can pass arrays without pointers.
Name a language that passes variable length arrays and hashes around without
using pointers, the language would have to allow both pass by reference and
pass by value of course.
>
>>> Object-oriented Perl uses references like crazy. (Whether or not OOP Perl is
>good is another topic. I have my doubts.) <<
>
>Other languages have OOP without pointers.
>(I am not an OOP fan either.)
Name an OO language that doesn't use pointers.
>
>>> Efficient argument passing. (You don't want to pass a hash of 10000 elements
>around much.) <<
>
>Many languages support the idea of by-reference
>and by value parameters. You use by-reference
>so that a copy does NOT have to be made. (There
>are further variations to consider.)
Name a language that uses by-reference semantics without using references.
>
>>> Complex data structures, such as arrays of hashes, hashes of hashes, etc.
>Anyone who has done a lot of programming will understand that sometimes a well
>designed data structure can save you a lot of trouble, even if the design
>itself is somewhat complex. <<
>
>There are probably other ways to do these that
>just simply never occured to you. (I don't
>know about in Perl, but in other languages and
>paradigms.)
>
>
>>> The claim that Perl would be better off without references is incredibly
>absurd. <<
>
>
>Well, I stand behind that claim until proven
>otherwise.
You can do that, and no one else will really care. Of course a little evidence
on your part for you statements would be a novel idea.
References are useful in Perl because they enable the efficient construction
of dynamic data structures that make code more efficient and more readable.
That way instead of having pages and pages of if elses, or cases you have
simple readable code that lets the data structure handle the special cases.
I think it's generally called encapsulation which most consider a good
thing.
But then again what business does a few decades of computer science research
have compared with the all-knowing topmind.
I have requested some simple facts from you, and I suspect you to answer them.
I have asked simple things like this before and you haven't bothered answering.
To make sure everyone wins I hearby state that if topmind does not answer my
requests I will not bother replying to his amazing declarations without any
evidence that contradict most of the last 20 years of computer science research.
And everyone says 'amen' and hopes that topmind won't answer. I however, hope
he will actually provide some evidence for his statements and that maybe I
will learn something... or maybe he will...
--
Sam
compiling kernels is what I do most, so they do tend to stick to the
cache ;) --Linus Torvalds
------------------------------
Date: 31 Jan 1999 20:36:16 -0600
From: les@MCS.COM (Leslie Mikesell)
Subject: Re: Perl Criticism
Message-Id: <7933v0$8b0$1@Mars.mcs.net>
In article <36b2b938.1076639@news.skynet.be>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>>Look at the Perl gunk people use for signitures. You are telling
>>me you can look at that and easily tell what are variables, routines,
>>parameters, what is being passed to each, etc?
>
>Sure you can. That's what the $ @ & () {} [] are for. Most people find
>those annoying, but they DO tell you what is what.
I've considered perl >4 to be a 'write-only' language. I can write
the above constructs in several variations and sort-of know how
to use the ones I've written, but still have a lot of trouble with
other peoples obsfucations (which they, of course, think are
perfectly clear). Is there a step-by-step guide for human parsing
of an arbitrary perl expression? How would the size of such a
thing compare to other languages?
Les Mikesell
les@mcs.com
------------------------------
Date: 1 Feb 1999 00:38:54 GMT
From: hdiwan@diwanh.stu.rpi.edu ()
Subject: Regexp problem [possible]
Message-Id: <slrn7b9tq9.efc.hdiwan@diwanh.stu.rpi.edu>
Keywords: Parsing Samba
I have undertaken developing an intranet search engine. To map out the files, I
have chosen to use a series of perl scripts. The format of the file is:
Interesting ports on resnet-####.dynamic.rpi.edu (128.113.1##.###)
Port State Protocol Service
139 filtered tcp netbios-ssn
I would like to extract the IP address and this is the script I'm using:
#!/usr/bin/perl -w
use strict;
use diagnostics;
use Env qw (HOME);
use vars qw ($ipAddress @now);
open IN, "/tmp/machines.txt" or die "run getmachines.pl, $!\n";
open OUT, ">/tmp/names.dat" or die "Hara kiri!!!! $!";
$/="netbios-ssn";
my $ip;
while (<IN>) { tr /^Starting//; tr /^No//;tr /second$//;
tr /^Nmap\brun\bcompleted//;}
close IN;
open IN, "/tmp/machines.txt" or die "run getmachines.pl $!";
while (<IN>) {
@now = split / /,$_;
my @iptemp = split /\b/, $now[-35];
$ip = $iptemp[1].$iptemp[2].$iptemp[3].$iptemp[4].$iptemp[5].$iptemp[6].
$iptemp[7];
print OUT "$ip\n";
}
Problem arises when I'm finished with certain subnets, instead of grabbing the
IP #, it grabs the word Interesting and a bunch of blanks.
--
Hasan Diwan
------------------------------
Date: Sun, 31 Jan 1999 23:54:47 GMT
From: hutcheon@iaw.on.ca (Tyler Hutcheon)
Subject: Re: Using integers in perl
Message-Id: <36b7ead9.2332482@news.iaw.on.ca>
On Mon, 1 Feb 1999 00:48:07 +0100, "Aboe" <aboe_bakr@_X_excite.com>
wrote:
>Hi!
>
>I would like to know how I can use a integer from a form. I can add 2 of
>those integers, but I can't compare them with another integer(which is
>already in the database).
>
>It's meant to make a database for an agenda. I hoped I could put an integer
>on each 4th line of the database. This integer should be : year, month and
>day sticked together like : 04-10-1998 => 19980410, so you can very easily
>sort the list.
>
>Thanks,
>Pascal.
If that's the exact format, then try using:
$input = "04-10-1998";
($month,$day,$year) = split(/-/, $input);
$output = "$year,$month,$day";
That takes the input (04-10-1998) and cuts it apart at the dashes (-)
into the varibles: $month, $day, and $year, it then takes the
variables and pastes them together into the order you want.
Tyler/
hutcheon@iaw.on.ca
http://www.iaw.on.ca/~hutcheon/
[CC'd to your email]
------------------------------
Date: Sun, 31 Jan 1999 21:40:24 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Using integers in perl
Message-Id: <alecler-3101992140240001@dialup-726.hip.cam.org>
In article <36b7ead9.2332482@news.iaw.on.ca>, hutcheon@iaw.on.ca wrote:
> If that's the exact format, then try using:
>
> $input = "04-10-1998";
> ($month,$day,$year) = split(/-/, $input);
> $output = "$year,$month,$day";
>
> That takes the input (04-10-1998) and cuts it apart at the dashes (-)
> into the varibles: $month, $day, and $year, it then takes the
> variables and pastes them together into the order you want.
Except that it also inserts commas, and you don't want that.
$output = "$year$month$day";
or
$output = $year.$month.$day;
HTH,
Andre
------------------------------
Date: 01 Feb 1999 04:16:09 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: des@d-lab.demon.co.uk
Subject: Re: Visual Perl?
Message-Id: <m390eizudi.fsf@joshua.panix.com>
des@d-lab.demon.co.uk ("D.Taylor") writes:
> Hi, what I meant was is there a sort of PageMill type WSYWYG program
> that would allow you to fill in the blanks ie a form creation program
> that would write the perl like visual html editors do.
Have you seen SpecTcl and SpecPerl? You must learn to use the Perl Tk
bindings, but it saves a good deal of drudgery.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: Sun, 31 Jan 1999 21:48:27 -0500
From: ricks <ricks@acpub.duke.edu>
Subject: Writing binary files after reading
Message-Id: <36B515FB.FAE6752D@acpub.duke.edu>
I'm trying to write a binary file that I'm reading in from a CGI script
to a file (file upload).
the problem is, it doesn't seem to be working. The file is sort of
there, but not quite. I'm using gif files, and they don't seem to come
out okay (they're garbled). But when I simple pass them to the browser,
it appears okay.
My perl is:
# Writing out to file
$file_name = param('file_name');
open (OUTFILE,">/html/file.gif") || die "Error creating file";
while (read($file_name,$data,1024)) {
print OUTFILE $data; }
close(OUTFILE);
If, instead, I write the binary file out as:
# writing out to browser
$file_name = param('file_name');
print header('image/gif');
while(read($file_name,$data,1024)){
print $data; }
then the gif displays correctly in the browser. So the file should be
being uploaded correctly; I'm not writing out correctly.
I expect I'm missing something simple. Can anyone provide some guidance?
(Using NT BTW).
Rick
--
ricks@duke.edu http://www.duke.edu/~ricks
------------------------------
Date: 1 Feb 1999 03:17:07 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Writing binary files after reading
Message-Id: <slrn7ba75j.7gf.sholden@pgrad.cs.usyd.edu.au>
On Sun, 31 Jan 1999 21:48:27 -0500, ricks <ricks@acpub.duke.edu> wrote:
>
>I'm trying to write a binary file that I'm reading in from a CGI script
>to a file (file upload).
>
>the problem is, it doesn't seem to be working. The file is sort of
>there, but not quite. I'm using gif files, and they don't seem to come
>out okay (they're garbled). But when I simple pass them to the browser,
>it appears okay.
<snip sample code>
>I expect I'm missing something simple. Can anyone provide some guidance?
>(Using NT BTW).
perldoc -f binmode
perlfaq4 : How do I handle binary data correctly?
--
Sam
Even if you aren't in doubt, consider the mental welfare of the person
who has to maintain the code after you, and who will probably put parens
in the wrong place. --Larry Wall
------------------------------
Date: 01 Feb 1999 04:19:22 +0100
From: Jonathan Feinberg <jdf@pobox.com>
To: ricks <ricks@acpub.duke.edu>
Subject: Re: Writing binary files after reading
Message-Id: <m3679mzu85.fsf@joshua.panix.com>
ricks <ricks@acpub.duke.edu> writes:
> I'm trying to write a binary file that I'm reading in from a CGI script
> to a file (file upload).
perldoc -f binmode
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
http://pobox.com/~jdf
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 4793
**************************************