[8030] in Perl-Users-Digest
Perl-Users Digest, Issue: 1655 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 16 14:17:29 1998
Date: Fri, 16 Jan 98 11:00:38 -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 Fri, 16 Jan 1998 Volume: 8 Number: 1655
Today's topics:
Re: Can I create a Linked List in Perl tobez@plab.ku.dk
Re: Efficiency: for high number indicies, use array or <dha@panix.com>
Re: EMTY FILE? (I R A Aggie)
first perl script bfisk@pacbell.net
Re: Getting the first two chars of a string - URGENT! (John Moreno)
Re: globs passed from command line tobez@plab.ku.dk
Re: globs passed from command line <jacklam@ulrik.uio.no>
Re: help - errors installing libwww-perl on FreeBSD tobez@plab.ku.dk
Help - problem installing perl jmahtani@hotmail.com
How to find timezone? <steves@wco.com>
Re: How to find timezone? <jhi@alpha.hut.fi>
Re: HTTP post (Smith and O'Halloran)
Is there a way to list all source used by perl pgm? (Richard Frenkel)
Re: Newbie: perl scripts search floppy drive tobez@plab.ku.dk
Re: Newbie: perl scripts search floppy drive (binkley)
Re: Parsing SQL server dumps. (Brian Wheeler)
Re: perl -- a language for LEARNING programming? (Steve Linberg)
perl build error on Solaris w/ gcc <dkhosla@compaq.com>
Re: Please help me find the error here... (I R A Aggie)
Re: Read STDERR from child? (M.J.T. Guy)
Re: recomended Perl books ? <jeffw@golem.ties.k12.mn.us>
Redirect <snx@snx.com>
Re: Redirect charlot@SPAM-FREE.org
Re: reg exp question <*@qz.to>
Re: source into binary code (John Stanley)
Re: source into binary code (John Stanley)
Syntax errors with nested braces??? <Sukumar.Patel@mail.tju.edu>
Re: WWW-pages generated by Perl-scripts <courcoul@campus.qro.itesm.mx>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 16 Jan 1998 18:38:45 +0100
From: tobez@plab.ku.dk
Subject: Re: Can I create a Linked List in Perl
Message-Id: <34BF9B25.22F8@plab.ku.dk>
Abigail wrote:
> ++ Don't forget there's more than one kind of efficiency. This linked list
> ++ implementation may be more efficient in terms of running time, but it's
> ++ less efficient with regards to memory usage, programmer effort and
> ++ maintainer effort. :-)
> Uhm, it took me 5 minutes to write those handful of functions; well
[skip]
> put it in a module, how much time does 'use DataStructures::LinkedList;'
> take to type?
[skip]
> I tend to find a O (n) vs O (1) trade off something to seriously consider.
Well, I'd like to say that quite often people don't really need linked
lists
in their programs written in C, i.e. the operation of inserting/deleting
an element to/from the middle of the list is very rare. Instead, the
basic
arbitrary size array is actually required, to operate as it is, or as
a stack, or as a queue etc. And it is easier to implement a linked
lists
than a growing array in C.
Perl is the completely different in this sense, and one will often be
tempted to use arrays even when linked lists are better suited to the
task.
Not mentioning that for those operations which are O(1) for both lists
and
arrays, in the case of Perl, that nasty constant factor cries to use
arrays.
Anton.
------------------------------
Date: 16 Jan 1998 11:37:53 -0500
From: David Adler <dha@panix.com>
Subject: Re: Efficiency: for high number indicies, use array or hash?
Message-Id: <vx97m80ml27.fsf@panix.com>
drummj@mail.mmc.org (Jeffrey R. Drumm) writes:
> I've got to be missing something here, knowing how far down the
> "Perl perfection" scale I am, but it seems to me you don't have to
> waste any space at all, assuming your invoice numbers are otherwise
> consecutive a your > starting invoice number is 100000. Why not:
> $index = $invoice_num - 100000;
> $invoice_data = $invoices[$index];
Just to stem the tide here (before everyone starts telling me this
:-), this blinding flash of the obvious has since been pointed out to
me. D'oh!
Thanks all!
> "Broken? Hell no! Uniquely implemented!" - me
I like it!
--
David H. Adler - <dha@panix.com>
"The perversity of the Universe tends towards a maximum."
------------------------------
Date: Fri, 16 Jan 1998 13:09:33 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: EMTY FILE?
Message-Id: <fl_aggie-1601981309340001@aggie.coaps.fsu.edu>
In article <EMuA37.FHq@bcstec.ca.boeing.com>, ced@bcstec.ca.boeing.com
(Charles DeRykus) wrote:
+ In article <34BE1434.F478E6F0@xarch.tu-graz.ac.at>,
+ Jahnel Klaus <jahnel@xarch.tu-graz.ac.at> wrote:
+ > How can i test a file weather its empty or not (but not with the testing
+ > of the file size)
+ perl -ne 'END {print "empty\n" unless $.}' file
TMTOWTDT:
if (-z $file) {
print "zero size for file: $file\n";
}
This is more efficient if the file is a significant non-zero sized file.
Page 85 of the Blue Camel has a list of the various and sundry file test
operators.
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: Fri, 16 Jan 1998 11:41:54 -0600
From: bfisk@pacbell.net
Subject: first perl script
Message-Id: <884956832.831389703@dejanews.com>
Below is my first attempt at writing any kind of perl script, just looking
for some honest critics about making this a little better.
The input file is formated something like this.
host HOSTNAME garbage garbage etc.
garbage
garbage
container CONTAINER_NAME HOSTNAME: /HOSTNAME
container GARBAGE_CONTAINER_NAME /GARBAGE_HOSTNAME:/garbage
garbage
the script is as follows,
open(PATFILE, "operator.dt");
$i = 0;
$c = 0;
while ($line = <PATFILE>) {
if ($line =~ "host") {
$HOST[$i] = [ split ' ', $line];
$HostList[$i] = $HOST[$i][1];
$i++;
}
if ($line =~ "container") {
$ContList[$c] = $line;
$c++;
}
}
close PATFILE;
foreach $host (@HostList) {
foreach $cont (@ContList) {
if ($cont =~ /($host):( |$)/) {
$container[0] = [ split ' ', $cont];
print $container[0][1] . " " . $host, "\n";
}
}
}
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 16 Jan 1998 12:34:14 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Getting the first two chars of a string - URGENT!
Message-Id: <1d2y7iz.1952hve7hc8zgN@roxboro0-060.dyn.interpath.net>
Ben Holness <bholness@nortel.ca> wrote:
> Hi all,
>
> If anyone knows how to return the first two chars of a string, please
> could you let me know as soon as possible.
>
> The situation is as follows:
>
> I have a variable ($temp) which holds a string similar to "4R65" or
> "Q6E2" etc.
>
> I would like to be able to get just the first two chars of the string,
> ie "4R" or "Q6" (as in the examples above).
>
> Does anyone know how to do this?
Yes.
Don't take this the wrong way, but Read The Fucking Manual.
Anybody who has spent five minutes with perl ought to be able to figure
out several ways of doing this, and if they can't reading the manual's
will tell them how.
--
John Moreno
------------------------------
Date: Fri, 16 Jan 1998 19:09:58 +0100
From: tobez@plab.ku.dk
Subject: Re: globs passed from command line
Message-Id: <34BFA276.CAF@plab.ku.dk>
Tom Christiansen wrote:
> In comp.lang.perl.misc, ben.glazer@mail.utexas.edu (Ben Glazer) writes:
> :But if I don't pass in the wildcard in double quote marks, perl
> :apparently resolves it into a single filename which it then passes to
> :$ARGV[0]. How can I avoid this restriction? I want to be able to say
> : perl mew.pl *.txt
>
> It's not Perl. It's your shell. The general answer is:
>
> Don't do that.
Don't do what?
perl mew.pl *.txt ???
Why not? What's wrong with doing something with all text files? :-)
Ben, instead of doing glob in your case,
go through your @ARGV, it already has *.txt expanded.
Anton.
------------------------------
Date: Fri, 16 Jan 1998 19:31:26 +0100
From: "Peter J. Acklam" <jacklam@ulrik.uio.no>
Subject: Re: globs passed from command line
Message-Id: <34BFA77D.ABD@ulrik.uio.no>
tobez@plab.ku.dk wrote:
> Don't do what?
>
> perl mew.pl *.txt ???
>
> Why not? What's wrong with doing something with all text files? :-)
>
> Ben, instead of doing glob in your case,
> go through your @ARGV, it already has *.txt expanded.
That depends on the port. Both the Web2c port for Win32 and
G. Sarathys port for Win32 would have *.txt in $ARGV[0] when
given something like
perl mew.pl *.txt
Peter
PS. ActiveState's port for Win32 is the only one I know
where the glob is expanded.
------------------------------
Date: Fri, 16 Jan 1998 18:00:05 +0100
From: tobez@plab.ku.dk
Subject: Re: help - errors installing libwww-perl on FreeBSD
Message-Id: <34BF9215.2C3F@plab.ku.dk>
Ken Gaugler wrote:
> The error messages suggest that MD5 is not installed, but I did
> install it successfully in the /usr/src/perl5.004_04/ext/MD5-1.7
> directory. Does it need to be somewhere else? What did I do wrong?
Personally, I have it as /usr/local/lib/perl5/site_perl/MD5.pm.
I think you've got to be sure that /usr/src/perl5.004_04/ext/MD5-1.7
is in your @INC (and I doubt that, alas), or to install MD5 into
the place your @INC is pointing to.
Remember, Perl will only look into directories mentioned in @INC
trying to load any kind of modules.
Hope this helps,
Anton.
------------------------------
Date: Fri, 16 Jan 1998 12:03:41 -0600
From: jmahtani@hotmail.com
Subject: Help - problem installing perl
Message-Id: <884973239.357892106@dejanews.com>
Hello,
I am trying to install perl on a sparc20 running solaris 2.5.1.
After giving
# sh Configure
I gave make, but I get the following error :
# /usr/ccs/bin/make
make: Warning: Both 'makefile' and 'Makefile' exist
rm -f libperl.a ar rcu libperl.a perl.o malloc.o gv.o toke.o perly.o op.o
regcomp.o
dump.o
util.
o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o
doop.o
doio.
o regexec.o taint.o deb.o universal.o globals.o perlio.o
sh: ar: not found
*** Error code 1
make : Fatal error: Command failed for target libperl.a'
I am pretty new to unix, so I am sorry if this is a silly question.
I would be very much obliged if someone could let me know of what the
problem is and how do I fix it.
Please reply to jmahtani@hotmail.com and not to dejanews.
Waiting for a response.
Jeetandra
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: Fri, 16 Jan 1998 09:50:29 -0800
From: Steven Smith <steves@wco.com>
Subject: How to find timezone?
Message-Id: <34BF9DE5.60D5@wco.com>
How do you determine what timezone you're in.
The closest I've found is
use POSIX tzname;
@tz = POSIX::tzname();
but this returns GMT, which implies that the timezone isn't
getting set on my host. The only other option I see is to
look at /etc/default/init but this doesn't look very portable.
Thanks
Steve Smith
DSC Communications
Petaluma, CA
------------------------------
Date: 16 Jan 1998 20:06:57 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: How to find timezone?
Message-Id: <oeelnwguwce.fsf@alpha.hut.fi>
Steven Smith <steves@wco.com> writes:
>
> How do you determine what timezone you're in.
> The closest I've found is
> use POSIX tzname;
> @tz = POSIX::tzname();
>
> but this returns GMT, which implies that the timezone isn't
> getting set on my host. The only other option I see is to
> look at /etc/default/init but this doesn't look very portable.
Sorry but there isn't portable way to do that. At least in UNIXes you
can try $ENV{TZ} but that of course depends on whether your system
support is doing their job. Be also warned that what you get
might be complexish: for me $ENV{TZ} is
"EET-2EET DST-3,M3.5.0/03:00,M10.5.0/04:00"
Some RFC should explain the stuff after the space. It tells the exact
switching points for the daylight saving time.
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: 16 Jan 1998 10:40:35 -0800
From: inwap@best.com (Smith and O'Halloran)
Subject: Re: HTTP post
Message-Id: <69o9j3$aph$1@shell3.ba.best.com>
In article <69n5mq$3bo$1@news1.inet.tele.dk>, Vagn Nielsen <news@zzz.dk> wrote:
>print S "POST /cgi-bin/test.cgi HTTP/1.0\n\n";
>print S "Content-Length: 17\n";
>print S "string=teststring";
That should be
print S "POST /cgi-bin/test.cgi HTTP/1.0\n";
print S "Content-Length: 18\n\n";
print S "string=teststring\n";
The blank line comes AFTER Content-Length, not before.
You'll find answers to questions like this in comp.lang.perl.misc .
--
INWAP.COM is Joe and Sally Smith, John and Chris O'Halloran and our cats
See http://www.inwap.com/ for "ReBoot", PDP-10, and Clan MacLeod.
------------------------------
Date: 16 Jan 1998 12:22:22 -0500
From: infobord@shore.net (Richard Frenkel)
Subject: Is there a way to list all source used by perl pgm?
Message-Id: <69o50e$mp6@northshore.shore.net>
I use CPAN modules extensively and it takes my Sparc 1.43 CPU seconds to
assemble all the code from the calls inside calls inside calls inside
calls (you get the idea) and .02 CPU seconds to run the thing.
Without proof, I strongly suspect if I could gather all the modules in one
file the parsing of the file would be much faster than fetching them from
all over the file system. This is not really precompiling since everything
would be left in source code, but it would help reduce at least one source
of overhead.
Anyone have any ideas?
Thanks
rich@infoboard.com
------------------------------
Date: Fri, 16 Jan 1998 18:06:22 +0100
From: tobez@plab.ku.dk
Subject: Re: Newbie: perl scripts search floppy drive
Message-Id: <34BF938E.5F0E@plab.ku.dk>
bspiker@wiesbaden.netsurf.de wrote:
> I've heard that there is a "@INC" that is te path for searching for
> libraries, but I haven't found any references to it yet.
Since you are on the platform where nobody can be sure how to write
one-liners, try this:
perl<CR>
print "@INC\n";<CR>
<^Z>
It should print you your current @INC.
It is very unlikely, though, that you'll find there any mention of A:\,
so there is probably exists another reason for such a strange behavior.
To change @INC during runtime, see ``use lib'' description.
Hope this helps,
Anton.
------------------------------
Date: Fri, 16 Jan 1998 12:41:44 -0500
From: "B. K. Oxley (binkley)" <binkley@bigfoot.com>
Subject: Re: Newbie: perl scripts search floppy drive
Message-Id: <69o64m$b3d$1@ndnws01.ne.highway1.com>
Sadly, your example is almost, but not quite, right. Try this:
perl<CR>
print "@INC\n";<CR>
<^Z><CR>
Because of the way the input works for the command shell, to make
command-line editing works, you have to use the "Enter" (Return, etc.) key
even after the end-of-input marker (!).
But, plausibly, this concern could be specific to Win32 (NT4). I haven't
sat at a true DOS command line in years.
--binkley
tobez@plab.ku.dk wrote in message <34BF938E.5F0E@plab.ku.dk>...
>bspiker@wiesbaden.netsurf.de wrote:
>
>> I've heard that there is a "@INC" that is te path for searching for
>> libraries, but I haven't found any references to it yet.
>
>Since you are on the platform where nobody can be sure how to write
>one-liners, try this:
>
>perl<CR>
>print "@INC\n";<CR>
><^Z>
>
>It should print you your current @INC.
>It is very unlikely, though, that you'll find there any mention of A:\,
>so there is probably exists another reason for such a strange behavior.
>
>To change @INC during runtime, see ``use lib'' description.
>
>Hope this helps,
>
>Anton.
------------------------------
Date: 16 Jan 1998 18:06:49 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: Re: Parsing SQL server dumps.
Message-Id: <69o7jp$m39$1@flotsam.uits.indiana.edu>
In article <01bd229d$2cc108e0$1c1c2f81@bkiefer.hh.com>,
"b kiefer" <bkiefer@hollandhart.com> writes:
> SQL server can output to a file, but the file is 80 characters wide (or any
> width you specify).
>
> Whats the best way to find the end of the text and the beginning of the
> white space?
>
> I know something like:
>
> s/\W.*//
>
> will replace anything after the first word with nothing, but I would like
> to kill the white space and maintain the new line.
>
> i.e.,
> 34567;ClientName;8901;MatterName; {--white space to 80 characters--}
> 12345;ClientName;6789;MatterName; {--white space to 80 characters--}
> {etc}
you might try something like this:
open(HANDLE,"sql.log") || die;
while(<HANDLE>) {
chomp; # take off newline
s/\s$//g; # remove whitespace at end of line ($ is the end of the line)
print "$_\n";
}
close(HANDLE);
Its probably not what you're really looking for, but the s/\s$//g should
get you started...
Brian Wheeler
bdwheele@indiana.edu
------------------------------
Date: Fri, 16 Jan 1998 12:06:44 -0500
From: see@my-sig.com (Steve Linberg)
Subject: Re: perl -- a language for LEARNING programming?
Message-Id: <see-1601981206440001@pri03-031.oldcity.dca.net>
In article <ken-1601981100400001@news.swarthmore.edu>,
ken@forum.swarthmore.edu (Ken) wrote:
> I'm thinking of teaching a beginning high school class on programming next
> year (if I can convince the school...), and if I do the language will be
> Perl, not C. This is mainly because I know it better than C, but also
> because I find it less frustrating to learn. Anyway, I'm interested in
> following this thread to see what people say.
One thing I wonder when I follow this thread is how long people
participating have been programming, and whether this has any correlation
with their languages of choice.
I started programming about 20 years ago (at age 11), and so when I was
learning, there was nothing remotely like Perl anywhere (that I knew of).
I outgrew Basic and Pascal quickly, dabbled in Forth and Logo and a few
others, then found myself doing mostly 6502 assembler by the time I was
about 16. Much of what I know about computers, and the various intuitions
I've developed (which I feel have served me immensely over the years) came
from REALLY having my hands in the guts of the machine. And in 1982, 128k
of RAM was about the best you could do (to think the Mac I'm writing this
with has 192mb - 1,500 times as much! Will my machine in 2013 have 288
gb?). I would rewrite large sections of assembly to save 30 bytes of
space because things just wouldn't fit otherwise.
Going to C from there was a huge step UP. Writing hybrid C/assembly was a
great way to wrench speed and power from the machine when you needed it
but retain the relative ease of C structures. And compared to assembly, C
is very high-level and greatly speeds development in most cases, although
I still feel that it is the hardest language I know.
I don't write assembly anymore, mostly because I don't need to. Also, the
processors out there are far more complex than the good ol' 6502. It's a
whole different world. C is about as close to the "guts" of the machine
as most people get these days.
I still write a lot of code in C. But when Perl came along, it blew me
away. I couldn't believe how easy it made dealing with text. Associative
arrays were so brilliantly simple that it took me a while to really
understand them. Not needing to declare variables, not having types, not
having to worry about running out of room seemed unbelievable to me. My
intuition still causes me to wonder what the hell is really going on under
there - all these routines that can't fail. For a simple example, what if
I do this?
$strVeryLong = "This is a VERY long string. " x 100000000000000000;
No error code is returned. Does it crash the machine? Does it use up
every available byte of memory and then fail quietly? Does it preserve a
certain amount of free space and then fail? It makes me nervous. There
are many examples like this that I could think of where Perl's behavior is
undefined in extreme circumstances.
That said, however, it's a joy to program and it hasn't failed me yet. I
do think, however, that the intuitions and sensibilities I developed
programming C and assembler over the years make me a better Perl
programmer.
--
slinberg .com
@crocker
Try that one, spambots!
------------------------------
Date: Fri, 16 Jan 1998 17:40:28 GMT
From: "Deepak Khosla" <dkhosla@compaq.com>
Subject: perl build error on Solaris w/ gcc
Message-Id: <01bd22a6$6173daa0$b90e12ac@print-tst01>
Hi,
I get an error when I am building perl 5_004_01 (tried 02 also). The error
is when it tries to compile util.c:
"No. of args does not match prototype". I am using GCC 2.7.2.2 compiled on
this box as an earlier step. The sytem is a Solaris 2.5.
I looked thru' the README and it mentioned about fixinc being the problem.
I could not run fixinc - it appeared it was more for 'cross-compiling' or
getting binaries and installing them. I am at a loss - is there a Solaris
specific FAQ or has someone experienced the same? If not, any place I can
get binaries?
Thanks for the help
------------------------------
Date: Fri, 16 Jan 1998 13:16:29 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Please help me find the error here...
Message-Id: <fl_aggie-1601981316300001@aggie.coaps.fsu.edu>
In article <69m0uc$l2i$1@hermes.seas.smu.edu>, "Scott Norris"
<777snorris@post.cis.smu.edu> wrote:
+ 1> I am trying to write a program that will add a line of data to a list.
+ Pretty simple, but my server always returns " your script crashed." I am
+ just learning perl, so perhaps there is something that I am missing here.
+ The routine to get data from STDIN was copied from a book, so it should be
+ fine, and the actual code is *very* simple. I will talk to my webmaster to
+ see if it's something on this end.
No, its something in your code. Did you know you could run perl in a
syntax checking mode?? I ran your code against it, and I got:
% perl -c usenet
Can't find string terminator "HTML" anywhere before EOF at usenet line 7.
Whoops.
+ print <<"HTML";
Ah, there's the tag HTML...
+ HTML
and there it is, again...but not really. What you have there is:
" HTML" which is NOT "HTML"!!! Spaces _count_ in these things.
+ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
[rest of URL decoding removed]
*sigh* Don't do that. Use CGI.pm instead. It has many features that
makes its use highly desirable. Yeah, yeah, I know, its somebody else's
code...
James
--
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 16 Jan 1998 17:42:11 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Read STDERR from child?
Message-Id: <69o65j$34k$1@lyra.csx.cam.ac.uk>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> METHOD 3:
> use IPC::Open3;
> $pid = open3(\*HIS_IN, \*HIS_OUT, \*HIS_ERR, $CMD);
> close(HIS_IN); # give end of file to kid, or feed him
> @outlines = <HIS_OUT>;
> @errlines = <HIS_ERR>;
> print "STDOUT:\n", @outlines, "\n";
> print "STDERR:\n", @errlines, "\n";
Strictly, that's not correct - it is liable to deadlock if the
command outputs a large amount on STDERR before closing STDOUT.
This is in practice rare, since programs usually only put a few lines
of errors on STDERR and the buffering is enough to cope.
And the same for METHOD 4.
Mike Guy
------------------------------
Date: 16 Jan 1998 17:35:38 GMT
From: Jeffrey Weiss <jeffw@golem.ties.k12.mn.us>
Subject: Re: recomended Perl books ?
Message-Id: <69o5pa$gbq$1@thor.ties.k12.mn.us>
Tiago Stock <tiagosdelete@gdn.net> wrote:
: Please follow this thread in recommending your favorite Perl reference book.
These are the book I can't do without:
PERL 5 Interactive Course by John Orwant. There may be a 2nd rev by now.
I find it to be much better organized than the "bibles", quite comprehensive,
has many good examples, and summarizes vital data in its appendices.
But I never found the online course part to be convenient or useful.
That said, I find that Jeffrey Friedl's book "Mastering Regular
Expressions" is excellent and useful; the regexp stuff will trip one
up every time if you don't understand it.
And every shelf must have "Programming Perl" and "Learning Perl" because,
aside from the thorough online documentation, they ARE the ultimate references.
I haven't looked in a while but as there are probably many good books out
there now, and a number of buggy ones. Pick a book for its utility for
*you*, not simply by recommendation. Learning/browsing styles differ.
Thanks to Larry Wall for this invaluable tool!!!
jw
--
Jeffrey Weiss UNIX administrator weiss@ties.k12.mn.us
TIES - Technology and Information Educational Services
PGP signed/encrypted mail accepted
------------------------------
Date: Fri, 16 Jan 1998 12:15:55 -0400
From: Stacy Hunter <snx@snx.com>
Subject: Redirect
Message-Id: <34BF87B7.5E96625A@snx.com>
I have the following line in my script which is intended to send the
browser to another page on submit:
print "location: http://www.url.com/redirect.html\n\n";
It is not working. Does anyone know why?
Thanks in advance.
Stacy
------------------------------
Date: 16 Jan 1998 12:54:18 -0500
From: charlot@SPAM-FREE.org
Subject: Re: Redirect
Message-Id: <69o6sa$130@ocean.CAM.ORG>
In article <34BF87B7.5E96625A@snx.com>, Stacy Hunter <snx@snx.com> wrote:
>I have the following line in my script which is intended to send the
>browser to another page on submit:
>
>print "location: http://www.url.com/redirect.html\n\n";
>
>It is not working. Does anyone know why?
>
That depends on what you mean by "not working". When you run your script from
the command-line, does it print "location: http://www.url.com/redirect.html"
followed by two newlines ? If it does, then the Perl script is ok... (meaning
this is not a Perl problem, but a CGI one, and your question should have been
posted to a CGI newsgroup).
But try to print "Location:" instead of "location:", and see if it cures
your problem.
Richard.
--
Richard Bellavance -- charlot(at)cam(dot)org -- http://www.cam.org/~charlot/
"All along this path I tread / My heart betrays my weary head
With nothing but my love to save / From the cradle to the grave"
(Eric Clapton, "From the cradle")
------------------------------
Date: 16 Jan 1998 17:31:19 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: reg exp question
Message-Id: <qz$9801161213@qz.little-neck.ny.us>
Bob Wilkinson <bw@pindar.com> wrote:
> Ian Goldstein wrote in message <34BD338A.B1A09D42@ny.ubs.com>...
> >I want to extract all instances of duplicate consecutive
> >characters from a string. I came up with a simple algorithm,
> >but was wondering if there was a "shorter" method.
>
> $string =~ tr/a-z//s;
> will do the same as the code below.
Really?
:r! echo My bookie books better bets | perl -wpe 'tr/a-z//s'
My bokie boks beter bets
#!/usr/local/bin/perl5
$string = $ARGV[0];
$_= $string;
while ( /([a-z])\1/ ) {
print "dupe $1\n";
$_ = $';
}
__END__
:r! perl -x % "My bookie books better bets"
dupe o
dupe o
dupe t
Sure looks like the scripts do very different things. Maybe you
want to read the post next time?
As for a shorter method, use /g instead of resetting $_ on each
iteration:
#!/usr/local/bin/perl5
$string = $ARGV[0];
$_= $string;
while ( /([a-z])\1/g ) {
print "dupe $1\n";
}
__END__
:r! perl -x % "My bookie books better bets"
dupe o
dupe o
dupe t
This is shorter code and (possibly much) more efficient.
Elijah
------
tr///s is not a good replacement for m//
------------------------------
Date: 16 Jan 1998 18:16:13 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: source into binary code
Message-Id: <69o85d$5m1$1@news.orst.edu>
In article <69ni9a$js9$1@csnews.cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> wrote:
>You know, if you give your code away, they can't steal it. :-)
I tried giving the mortgage company a perl routine I wrote. Seems that
they weren't interested in software, they wanted money. Ditto the
grocery store. Ditto the dentist. Ditto the doctor. Ditto the gas
station attendant.
If writing perl code were the way I wanted to make a living, I guess I
couldn't do very well at it by giving it away, now could I?
------------------------------
Date: 16 Jan 1998 18:25:46 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: source into binary code
Message-Id: <69o8na$b6t$1@news.orst.edu>
In article <69n1oh$616$9@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Bleh. You don't need to run anything or decompile that box.
>There is about one thing you can do:
>
> perl -we 'system "black_box", @ARGV'
And when all the student needs to do is "more black_box" to see the
source code, he learns nothing about how to solve a problem given
limited input.
>As it is impossible to determine what an algorithm does based on
>a limited set of inputs.
You need to get out more. Perhaps read one of the recent issues of
Electronic Design News, I think it was. They put together a
web server that had 2 analog outputs and 6 analog inputs (two of which
were just sampling the outputs), connected to a "black box" electronic
circuit. People could submit what voltages they wanted on the outputs,
and the server told them the 6 voltages they got back.
I might have considered it impossible for anyone to know what the
circuitry was in the black box, and I certainly couldn't do it, but
there were people who figured it out. It was four diodes in series. Not
only did people figure that out, but some people could tell it was 4
germanium diodes.
------------------------------
Date: Fri, 16 Jan 1998 13:14:37 -0500
From: Sukumar Patel <Sukumar.Patel@mail.tju.edu>
Subject: Syntax errors with nested braces???
Message-Id: <34BFA38D.BDE35EF1@mail.tju.edu>
This is a multi-part message in MIME format.
--------------684244D2AC3AF6BABD881A42
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am running perl5.004_04, perl5.003_93 and perl5.002 (on AIX 3.2.5, AIX
4.1.2, AIX 4.1.5, HPUX 9.04 and HPUX 10.10) all give me the same errors:
Command: perl -e '$a = ${P{${S{$k}{'s'}}}{'s'}};'
Error: syntax error at -e line 1, near "}}"
But if I run
Command: perl -e '$a = $P{${S{$k}{'s'}}}{'s'};'
or
Command: perl -e '$m = ${S{$k}{'s'}};$a = ${P{$m}{'s'}};'
I get no errors.
Is this a bug or something peculiar with the platforms that I have?
Could others please check this out?
Thanks,
Sukumar Patel
Thomas Jeferson Univ.
Sukumar.Patel@mail.tju.edu
--------------684244D2AC3AF6BABD881A42
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Sukumar Patel
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Sukumar Patel
n: Patel;Sukumar
email;internet: Sukumar.Patel@mail.tju.edu
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------684244D2AC3AF6BABD881A42--
------------------------------
Date: Fri, 16 Jan 1998 11:46:10 -0600
From: "Juan M. Courcoul" <courcoul@campus.qro.itesm.mx>
To: Paul Weingarten <paulweingarten@hotmail.com>
Subject: Re: WWW-pages generated by Perl-scripts
Message-Id: <34BF9CE1.F8F524B5@campus.qro.itesm.mx>
Paul Weingarten wrote:
>
> It is very comforable to use a script that gets
> data from a text file and writes it out as a HTML-page.
> The updating procedure will be very easy, when
> it is possible to get the data directly from a product
> database etc.
...
> Another problem is signs that needs to be formatted, like
> i to é. How is this done automaticly?
>
> I would be very grateful for answers, please include the full
> Perl-code since I am a beginner on Perl.
By all means take a good and close look at Lincoln Stein's CGI.pm
module. It should already be installed on your system, if you have a
reasonably recent and complete version of Perl. Try issuing a
perldoc CGI.pm
which will get you all the built-in documentation in the module. If that
doesn't work, you can check it out at the source:
http://www.genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
This module takes care of generating all the HTML (and even some HTTP)
code, including escaping out the special &xxx; codes, so you can
concentrate on the content.
Cheers,
John Courcoul
ITESM Queretaro
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1655
**************************************