[6384] in Perl-Users-Digest
Perl-Users Digest, Issue: 9 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 08:17:14 1997
Date: Tue, 25 Feb 97 05:00:27 -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 Tue, 25 Feb 1997 Volume: 8 Number: 9
Today's topics:
BEGINNER: Help with <mark.hagan@sophia.ncr.com>
compiling perl <mb420@hi.ft.hse.nl>
Converting date "serial number" back to a "normal" date <apollock@bit.net.au>
Discussion on language (was:Re: How to spam - legitimat (Antti-Juhani Kaijanaho)
Re: futur de perl et java-script <pb@ecce-terram.de>
Re: Generating a randomly sorted list of integers <dbenhur@egames.com>
Re: Generating a randomly sorted list of integers (Stephen Frost)
help on debug MacPerl (Keith Warner Colvin)
Re: Libwww, Simple.pm and env_proxy.al? @INC trouble. (Scott Meyer)
Re: Libwww, Simple.pm and env_proxy.al? @INC trouble. <aas@bergen.sn.no>
Re: Module installation in $HOME and dependences (Brooks Davis)
Re: Multiple values to/from subroutines... (Jonathan King)
Re: Perl Munitions T-Shirt (Michael Tempsch)
perl probs with files <igandham@prestel.net>
PERL script for HTTP transfer ? <iae@exchange.spb.inkom.ru>
PERL what is it ? what can it do ? <mb420@hi.ft.hse.nl>
Re: Perl5/Tk for Win95/NT (Steve Tarver)
Q: How to delete several files in one operation (newbie (Jarle Aasland)
Running a program under a specific group. <libeson@pdb.pdb.bnl.gov>
sockets <vivaldi_jorge@info.upf.es>
The fabulous pink camel (or red, if you prefer that), a (Tom Grydeland)
Re: Win32/NT problems with ARGVand .pl association (Steve Tarver)
Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 25 Feb 1997 11:15:00 GMT
From: Mark Hagan <mark.hagan@sophia.ncr.com>
Subject: BEGINNER: Help with
Message-Id: <3312C9B3.2CF8@sophia.ncr.com>
Help!!
I've inherited a Perl script tied to a Web page form which I need to
modify and I have no Perl background. The problem I am encountering is
that the Web form is sending tailing spaces to the Perl script. This is
a problem since the Perl script is preparing these fields to be plugged
into another application and the tailing spaces are causing a problem.
So, I need to be able to eliminate all trailing spaces from a string
using Perl. Any ideas how I can do this? I am RTMFing as we speak but
of course, this is something that needs to be done quickly - as always.
Thanks in advance for any assistance any of you Perl gurus can provide.
Regards,
Mark
------------------------------
Date: Tue, 25 Feb 1997 12:13:39 GMT
From: "NT_server" <mb420@hi.ft.hse.nl>
Subject: compiling perl
Message-Id: <01bc2316$a2763600$2222b18f@nt_server>
how ?????
how do you compile perl scripts. Is there a compiler available ?
Thanks, Allard
awp@poboxes.com
------------------------------
Date: 25 Feb 1997 10:29:42 GMT
From: "Andrew Pollock" <apollock@bit.net.au>
Subject: Converting date "serial number" back to a "normal" date
Message-Id: <01bc22fe$6d64ee60$011618cb@caesar.bit.net.au>
Hi,
I am trying to convert the output of a /bin/date +%j back into a normal
date. I understand that this value is not the Julian date in the manner of
speaking that the Date modules I have looked at from CPAN are talking
about. Is there any easy way of doing this?
Eg. date +%j = 056, 56 = Feb 25, 1997.
Thanks in advance
Andrew
--
----
Andrew Pollock Senior (hey I'm the only one) Programmer
apollock@bit.net.au http://www.bit.net.au/~apollock
Brisbane Internet Technology
------------------------------
Date: Tue, 25 Feb 1997 11:18:51 GMT
From: gaia@sci.fi (Antti-Juhani Kaijanaho)
Subject: Discussion on language (was:Re: How to spam - legitimately)
Message-Id: <3311f9c6.18204122@news.sci.fi>
somsky@dirac.phys.washington.edu (William R. Somsky) wrote in
comp.mail.misc:
>By the by, does anyone know if there are established terms for the
>two different types/usages of nouns I'm referring to here as
>"substansive" and "objective"? Ie, nouns/noun usages that specify
>a substance that doesn't come in any discrete units, eg, "water",
>"air" (atoms/molecules don't count here), things where you don't
>say "I had 23 waters" (hmm... ordering "a water" meaning "a glass of
>water" in a restaraunt would be a separate usage) versus nouns/noun
>usages that specify discrete items that can be identified and
>counted, things where you do say, "I see 3 cars"?
My English grammar book talks about "countables" and
"uncountables".
Antti-Juhani, whose mother tongue isn't English
--
Don't try to be a great man. Just be a man,
and let history make its own judgements.
- in Star Trek: First Contact
------------------------------
Date: 25 Feb 1997 12:30:17 +0100
From: =?ISO-8859-1?Q?=22Peter=A0Br=FClls=22?= <pb@ecce-terram.de>
Subject: Re: futur de perl et java-script
Message-Id: <5euid0$fb5@news.Informatik.Uni-Oldenburg.DE>
"Carol C. Kankelborg" <csc80@amdahl.com> writes:
> I agree with what Abigail is saying here. I, too, always thought the
> fr, de, nl, etc. groups were country-related, not language-related,
Soe of them are, some of them aren't. The de.* hierachy is
interantional and the language of choice of German, the Big Eight
hierachy are international and the language of choice is English. Is
that concept so hard to grasp?
> just as ba is for the (SF) Bay Area region. Sure, the majority
> language of the internet and this newsgroup is English, but as its
> use grows outside the US and Commonwealth, I would hope that there
> would be more non-English communication.
There is. In the approprate hierachjies or groups (soc.culture.*,
sci.language-* - one would be hard-pressed to ;outlaw+ non-English
posts there.
> If you don't understand the language of a post, just skip over it.
For me, postings in another language than German and English are of no
interest. I am not opposed to them, but I'd rather not see them in the
first place. However, in abscence of reliable means to make that
distinction automatically (i.e. a Header ;Language: german+ or
something to that effect, I have to process them by hand. This is only
possible when you deal with only a few groups AND because most people
choose English when they post in the Big Eight. If all users of the
de.* hierachy would start crossposting in German you would notice --
and even though de.* is small compared to the Big Eight, you'd notice
it -- lotsa worthless postings for all of you who don't understand
German.
> Surely the community of a newsgroup as large as c.l.p.m is large
> enough that there are some who are trilingual (Perl, English, some
> other language). I commend Nathan for dusting off his high school
> French and attempting to respond to Dominique. I tried to provide an
> English translation for my replies to Dominique as a courtesy to the
> non-French speakers in the group. I welcomed the chance to dust off
> my French as well. If, however, everyone who attempts to post in a
> non-English language gets run off with "Go away, we only speak
> English here," then is it any wonder you don't find more non-English
> posts?
No, and it's absolutely understandable. English is the language of
choice for the Big Eight.
> The Internet should make the world smaller, so we all can
> expand our horizons more easily.
They can always learn English or switch to the approprate hierachy.
Here's the text I send to people who crosspost English messages tp
de.rec.sf.startrek (a group prone to stupid crossposters.)
---
Please don't crosspost English-language messages to the
German-language groups. You probably just posted a followup without
checking the ``Newsgroups:'' line, repeating your precedessor's
mistake, however, making sure that your postings go to the correct
place is you responsibility.
Please understand that this is no nationalism.
The de.* groups are indeed international groups. As such, the group
you crossposted to is open to Germans, Swiss, Austrians, Australians,
Chinese, Americans, why, even Martians, provided they make an effort
to use the German /language/ AND limit themselves to discussions which
are on topic for the group.
This way people who don't know or care for English can take part in
Usenet without waddling through oodles of postings they cannot even
process.
Let me repeat, this is no nationalistic matter, but simply one of
language and traffic control. Governed by the same process that
dictates that Star Trek themes are discussed in rec.arts.startrek.*
and not rec.arts.sf.misc, comp.sys.apple or talk.orgins.
If you make sure that your postings go only to the groups which are
appropriate by topic and language, you help keeping the Usenet usable
for everybody, even those who don't share your interests or language.
Best regards
Peter
------------------------------
Date: Mon, 24 Feb 1997 23:53:45 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Stephen Frost <frostbyt@shell01.ozemail.com.au>
Subject: Re: Generating a randomly sorted list of integers
Message-Id: <33129A89.2B41@egames.com>
Stephen Frost wrote:
> I needed to write some code to produce a randomly sorted list of
> integers (between "1" and "n"). This I have done, but I am not
[snip]
> sub GenerateRandomList {
[snip]
> Would be very interested in alternative approaches ... but go easy
> on me won't you? I am, after all, merely a born-again COBOL
> programmer... 8^)
See if you can follow this:
# Generates a random list of numbers between "1" and "n"
sub GenerateRandomList {
my $n = shift; # use range 1..$n
my @nums = (1..$n); # list of numbers to randomly sort
my @list = ();
while ($n--) { # while more numbers
my $r = int(rand(@nums)); # pick from [0..$#nums]
push(@list, splice(@nums,$r,1)); # remove number, push out
}
return @list;
}
# test...
srand(time ^ ($$ + ($$<<15))); # seed rand
for (1..10) {
print join(':', GenerateRandomList(9)), "\n";
}
Outputs (this time):
7:3:5:2:6:9:1:8:4
6:3:1:4:2:9:8:5:7
3:2:7:6:5:8:1:9:4
2:8:4:5:9:1:3:7:6
1:9:5:3:7:8:6:2:4
1:9:2:6:3:4:8:5:7
8:3:4:6:7:5:1:9:2
1:4:5:6:7:2:8:3:9
5:7:2:3:9:8:6:4:1
8:4:5:1:7:9:3:2:6
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"Don't run away. We are your friends." O-
------------------------------
Date: 25 Feb 1997 11:55:27 GMT
From: frostbyt@shell01.ozemail.com.au (Stephen Frost)
Subject: Re: Generating a randomly sorted list of integers
Message-Id: <5eujvf$4of@reader1.reader.news.ozemail.net>
Tom Phoenix (rootbeer@teleport.com) wrote:
Steve Frost (steve.frost@frostbyte.com.au) wrote:
: > for ($x = 1; $x < ($high + 1); $x++) {
: No doubt you meant to write this. :-) Perl does a lot to make your life
: easier, no?
: for $x (1..$high) {
<embarassed silence!>
Ah well, you're right, I meant to write it, but I sure didn't mean
to make such a fool o' myself! ;-) That's what I get for loaning
my Llama and Camel books to a workmate. I got them back tonight
which is just as well. Hopefully I can avoid such silliness from
here on in...
: > but go easy on me won't you? I am, after all, merely a born-again COBOL
: > programmer...
: Okay, I'll stop picking on your code. :-) Here's a subroutine which can
: do what I think you're looking for. Be sure to call srand just once, near
: the start of your script. This routine can supply a random list of 10,000
: elements in about 2.1 seconds on my machine, but your mileage may vary.
: Hope this helps!
: sub random_list ($) {
: # given a number n, returns a randomly-ordered list
: # of integers from 1 to n. Probably not useful when
: # n becomes too large, but what are you gonna do?
: # NOTE: You must call srand, as needed.
: my @unused = (1..$_[0]);
: my @list;
: push @list, splice @unused, rand(@unused), 1 while @unused;
: @list;
: }
That's exactly the sort of thing i was hoping to find ... I also
received a similar solution from Devin Ben-Hur (thanks Devin!)
and some other ideas from Shawn Robinson (thanks!). I really do
appreciate all you guys taking the time to look at the code.
Here's what I've finally settled on. It's a real, almost live script
that allows me to randomise the placement of some images on a web
page (trivial huh?). Code follows. You can view the result at:
http://www.frostbyte.com.au/frostbyte/cgi-bin/ssi/frontpage.pl
>From the "learning Perl" perspective (and I have so much to learn)
the "trick" is in understanding that in the code:
push(@randlist, splice(@sortlist, rand(@sortlist), 1))
while @sortlist;
the @sortlist in rand(@sortlist) is being evaluated in a SCALAR
context, so it returns the number of elements in the LIST and not
the LIST itself. Nice! Thanks to "The Camel" (p20) for the
explanation of that.
Hope this helps some other newbie. Thanks again to all for their
replies. Here's the script I've written:
#!/usr/contrib/bin/perl5
#
# Generate HTML for 9 random images in a table (3 x 3)
# One of the images (#1) will be a link to another page
#
srand(time ^ ($$ + ($$<<15)));
$low = 1;
$high = 9;
@imglist = GenerateRandomList($low, $high);
print "Content-type: text/html\n\n";
print "<center>\n";
print '<img src="/public/images/banner.gif">' . "\n";
print "<table>\n";
for $x (1..9) {
if ($x == 1 || $x == 4 || $x == 7) {
print " <tr><td>";
} else {
print " <td>";
}
$number = pop @imglist;
if ($number == 1) {
print '<a href="http://www.frostbyte.com.au/index.html">';
}
print "<img src=\"/public/images/fridges/$number.gif\" border=0>";
if ($number == 1) {
print '</a>';
}
if ($x == 3 || $x == 6 || $x == 9) {
print "</td></tr>\n";
} else {
print "</td>\n";
}
}
print "</table>\n";
print "</center>\n";
exit;
sub GenerateRandomList {
#
# Generates randomly sorted list of consecutive
# integers between values "$low" and "$high"
#
my $low = $_[0];
my $high = $_[1];
my @sortlist = ($low..$high);
my @randlist = ();
push(@randlist, splice(@sortlist, rand(@sortlist), 1))
while @sortlist;
return @randlist;
}
*** Author's note: Yes, I know that the page produced by this
script does not contain <html></html>, <head></head>,
<title></title> or <body></body> pairs. I was in a hurry
to get the script itself debugged, so I'll be adding them
in later. HTML-nazis can thus leave me alone! ;-)
Steve
------------------------------
Date: Tue, 25 Feb 1997 00:56:36 -1000
From: colvin@aloha.net (Keith Warner Colvin)
Subject: help on debug MacPerl
Message-Id: <colvin-2502970056360001@hawaii-79.u.aloha.net>
Aloha from Hawai'i and Mahalo for your help......
>CGI script I am using for shopping carts:
#!/usr/local/bin/perl
$| = 1;
print "Content-type: text/html\n\n";
require "/html_web_store.setup";
require "$cgi_lib_pl";
require "$cgi_lib_sol";
require "$mail_lib_pl";
&ReadParse(*form_data);
opendir (USER_CARTS, "$cart_directory") || &open_error($cart_directory);
@carts = grep(/\.cart/,readdir(USER_CARTS));
closedir (USER_CARTS);
>What Perl Debug Stated:
main::(Hard Disk:CD ROM:Pagemill:hele.com(local root folder):cgibin:html_web_store.cgi:2):
2: $| = 1;
# Can't find string terminator "'" anywhere before EOF.
File '(eval 43)'; Line 2 # <IN> chunk 7.
File ':perl5db.pl'; Line 1360 # <IN> chunk 7
>What Mac Perl Stated:
Content-type: text/html
I am really sorry, but for some reason I was unable to open
<P>./User_carts<P> Would you please make sure that the filename is
correctly defined in define_variables.pl, actually exists, and has the
right permissions relative to the web browser. Thanks!# # Died.
File ':cgi-lib.sol'; Line 71 # <IN> chunk 9
File ':cgi-lib.sol'; Line 71
# main::open_error called
File 'Hard Disk:CD ROM:Pagemill:hele.com(local root folder):cgibin:html_web_store.cgi'; Line 12
Stack dump during die enabled outside of evals.
>What Perl Debug Stated:
p expr Print expression
# # Bare word found where operator expected, near "$DB::OUT expr"
File '(eval 52)'; Line 2
# eval '($@, $!, $,, $/, $\\, $^W) = @saved;package main; $^D = $^D | $DB::db_stop;
print $DB::OUT expr Print expression;
;' called
File ':perl5db.pl'; Line 908
# DB::eval called
File ':perl5db.pl'; Line 834
# DB::DB called
File 'Hard Disk:CD ROM:Pagemill:hele.com(local root folder):cgibin:html_web_store.cgi'; Line 2
# # (Missing operator before expr?)
# eval '($@, $!, $,, $/, $\\, $^W) = @saved;package main; $^D = $^D | $DB::db_stop;
print $DB::OUT expr Print expression;
;' called
File ':perl5db.pl'; Line 908
# DB::eval called
File ':perl5db.pl'; Line 834
# DB::DB called
File 'Hard Disk:CD ROM:Pagemill:hele.com(local root folder):cgibin:html_web_store.cgi'; Line 2
# Can't locate object method "expr" via package "Print".
File '(eval 52)'; Line 2 # <IN> chunk 4.
File ':perl5db.pl'; Line 1360 # <IN> chunk 4
>What advise do you have for those who know more?
------------------------------
Date: Tue, 25 Feb 1997 07:34:11 +0100
From: Meyer@algonet.se (Scott Meyer)
Subject: Re: Libwww, Simple.pm and env_proxy.al? @INC trouble.
Message-Id: <Meyer-ya02408000R2502970734110001@news.algonet.se>
Thank you for taking the time to answer my question.
Knowing in what direction to look for the solution takes
away a lot of frustration.
I'm still having problems with installing modules locally though.
I've been using the routine suggested at
http://www.york.ac.uk/~twh101/libwww/install.html :
Makefile.PL PREFIX=~
make
make test
make install
When I ran this routine from within the libwww-perl-5.07
directory, I got the message that some of the modules used by
the libwww-perl library were missing:
Can't locate IO/Socket.pm in @INC at Makefile.PL line 30.
Can't locate Net/FTP.pm in @INC at Makefile.PL line 49.
Can't locate MD5.pm in @INC at Makefile.PL line 70.
So I downloaded the IO module and ran the same routine from
within that directory to install that module locally as well.
But when I ran the libwwwperl make test again,
the IO module still couldn't be found:
robot/ua............Can't locate IO/Socket.pm in @INC at robot/ua.t line 3.
FAILED before any test output arrived
Test returned status 2 (wstat 512)
local/autoload......ok
local/get...........ok
local/http..........Can't locate IO/Socket.pm in @INC at local/http.t
line 3.
FAILED before any test output arrived
Test returned status 2 (wstat 512)
Failed 2/25 test scripts, 92.00% okay. 0/615 subtests failed, 100.00% okay.
make: *** [test] Error 29
And when using this line in my script:
use lib "/home/meyer/lib";
I still get the message
Can't locate auto/LWP/UserAgent/env_proxy.al in @INC at
/home/meyer/lib/LWP/Si
mple.pm line 158
Although the file clearly exists in:
/home/meyer/lib/perl/auto/LWP/UserAgent/env_proxy.al
Will it be necessary to edit Makefile.PL to make it find
the other locally installed modules?
Or should I copy the modules from their original directories to the lib dir?
Unfortunatly, my book on perl doesn't mention makefiles or module installation.
Any help appreciated,
Scott
(The perl at my server is "perl version 5.003 with EMBED")
Here are some excerps from the installation process:
/home/meyer/libwww-perl-5.07> make install
/usr/local/bin/perl -e 'use Config; chdir q{./blib/script}; foreach
(qw(GET HEAD
POST)) {' \
-e 'unlink "$_";' \
-e 'system("$Config{\"lns\"} lwp-request $_") && die; }'
Installing /home/meyer/lib/perl/./auto/LWP/IO/read.al
Installing /home/meyer/lib/perl/./auto/LWP/IO/write.al
/home/meyer/IO-1.15> make install
Installing /home/meyer/lib/./auto/IO/IO.so
Installing /home/meyer/lib/./auto/IO/IO.bs
Installing /home/meyer/lib/perl5/./IO/Pipe.pm
Installing /home/meyer/lib/perl5/./IO/File.pm
Installing /home/meyer/lib/perl5/./IO/Select.pm
Installing /home/meyer/lib/perl5/./IO/Socket.pm
------------------------------
Date: 25 Feb 1997 08:41:37 +0000
From: Gisle Aas <aas@bergen.sn.no>
Subject: Re: Libwww, Simple.pm and env_proxy.al? @INC trouble.
Message-Id: <h3eulnupq.fsf@bergen.sn.no>
Meyer@algonet.se (Scott Meyer) writes:
> But when I ran the libwwwperl make test again,
> the IO module still couldn't be found:
>
> robot/ua............Can't locate IO/Socket.pm in @INC at robot/ua.t line 3.
> FAILED before any test output arrived
> Test returned status 2 (wstat 512)
> local/autoload......ok
> local/get...........ok
> local/http..........Can't locate IO/Socket.pm in @INC at local/http.t
> line 3.
> FAILED before any test output arrived
> Test returned status 2 (wstat 512)
> Failed 2/25 test scripts, 92.00% okay. 0/615 subtests failed, 100.00% okay.
> make: *** [test] Error 29
You must make sure that the test script finds the IO::-modules you
installed. If you can't install them in the standard place, you can
try to set the PERL5LIB environment variable before running 'make
test'. You can also choose to just ignore the test failures.
> And when using this line in my script:
>
> use lib "/home/meyer/lib";
Try: use lib "/home/meyer/lib/perl";
> I still get the message
>
> Can't locate auto/LWP/UserAgent/env_proxy.al in @INC at
> /home/meyer/lib/LWP/Si
> mple.pm line 158
>
> Although the file clearly exists in:
>
> /home/meyer/lib/perl/auto/LWP/UserAgent/env_proxy.al
>
--
Gisle Aas <aas@sn.no>
------------------------------
Date: 25 Feb 1997 06:46:43 GMT
From: brdavis@orion.ac.hmc.edu (Brooks Davis)
Subject: Re: Module installation in $HOME and dependences
Message-Id: <5eu1sj$ptc$1@cinenews.claremont.edu>
[An e-mail copy was sent to kent@erlang.ericsson.se]
Kent Boortz (kent@erlang.ericsson.se) wrote:
:
: I don't have root access on my computer at work and don't want to
: bother the system administrator for every module or new version of a
: module I want to install. So I do local installations under my
: $HOME. I have created bin, lib, man and var directorys and it usually
: works well. If the module is independent that is.
:
: So why no Unix environment variable with additional paths to search?
:
: I searched the FAQ and perlrun man-page but couldn't find anything.
: The only solution I can think of is to install my own copy of Perl
: but i would prefer not to. Especially since I have lots of scripts
: that begin with "#!/usr/local/bin/perl".
>From the perl manpage:
PERLLIB A colon-separated list of directories in which
to look for Perl library files before looking in
the standard library and the current directory.
If PERL5LIB is defined, PERLLIB is not used.
This works for scripts executed though your shell. I was forced to resort
to the -Iblah mess for a CGI script though.
-- Brooks
--
Brooks Davis +------------------------------------------------+
brdavis@hmc.edu | "_Slackware_ [Linux] is the MacOS of UNIXes." |
Harvey Mudd College | -- Richard Garnish |
340 E. Foothill Blvd. | on alt.sysadmin.recovery |
Claremont, CA 91711 +------------------------------------------------+
------------------------------
Date: 25 Feb 1997 07:50:53 GMT
From: king@cogsci.ucsd.edu (Jonathan King)
Subject: Re: Multiple values to/from subroutines...
Message-Id: <5eu5kt$539@news1.ucsd.edu>
In article <Pine.LNX.3.95.970224161241.559A-100000@wauug.erols.com>
Joe Tseng <jtseng@wauug.erols.com> writes:
>
>I know that you can pass out a single value from a subroutine.
Uh, you mean return?
>But I
>would like to know if it's possible to generate multiple values from one
>subroutine and pass it to another? I guess you can disperse return
>statements within the 1st subroutine...
Uh, why would you think that would work? Check out "man perlfunc"
for what "return" actually does.
>(I looked in my turquoise Camel book and found no reference to this
>matter.
In the Blue Camel on page 207, we see two short paragraphs on
"return". The third sentence of the second paragraph is:
If the subroutine was invoked in a list context, the EXPR is
also evaluated in a list context and can return a list value.
So you can get a list of values out of a subroutine. Yee hah! What
about passing multiple values in? Well, we could pretend not to
notice that both perlfunc and the Blue Camel document about a
bazillion uses of functions taking LIST as an argument, and that the
rest of the Blue Camel and other man pages document about half a
bazillion examples of snarfing multiple arguments from @_. Instead,
we'll look do a "man perlsub" and read on the very first page:
The Perl model for function call and return values is
simple: all functions are passed as parameters one single
flat list of scalars, and all functions likewise return to
their caller one single flat list of scalars.
Shazam! Double play! And that input array is in @_...uust think of
all the arguments you could have if you wanted.
>Somehow I kinda like the pink Camel book better...)
You mean, it looks better on your bookshelf? That's where you seem
to keep these books, since even in Perl4 days you had @_ and the
ability to return a list of values.
>Joe Tseng
[munch]
>Friends don't let friends become Orioles fans! GO YANKEES!!!!!
Ah, a Yankees fan. I should have guessed.
jking
------------------------------
Date: 25 Feb 1997 07:21:15 GMT
From: d1temp@dtek.chalmers.se (Michael Tempsch)
To: "Nicholas J. Leon" <nicholas@binary9.net>
Subject: Re: Perl Munitions T-Shirt
Message-Id: <5eu3tb$993@nyheter.chalmers.se>
In article <Pine.LNX.3.95.970224152240.396A-100000@neko.binary9.net>,
"Nicholas J. Leon" <nicholas@binary9.net> writes:
>
>I hope this question is MISC enough for here. But could anyone point me
>in the direction of a vendor that sells the Perl Munitions T-shirt? I'm in
>the US, so export restrictions aren't a factor here.
Take a look at http://www.dcs.ex.ac.uk/~aba/shirt/shirt.html
Points to both US and non-US sources
/Michael
--
| Linux: Turn on...Tune in...Fork out... |
| Michael Tempsch, member of Ballistic Wizards, TIP#088, TDGP#20 |
| d1temp@dtek.chalmers.se | [d1temp@hotmail.com] | [d1temp@bigfoot.com] |
| Cell.Phone:+46 705487554 URL:http://www.dtek.chalmers.se/~d1temp |
------------------------------
Date: Tue, 25 Feb 1997 10:17:29 +0000
From: Iqbal Gandham <igandham@prestel.net>
Subject: perl probs with files
Message-Id: <3312BC39.6D94@prestel.net>
Hi
I have a file which contains two kinds of records.
e.g upload blah blah blah
and group eenie meenie etc etc
the thing is that I need to add another upload record to the file. I do
not just want to append it to the end of the file, but instead add it
after the last upload line. I then want to add another record to the
group line, agian I do not just want to create a new line with group in
it, just append it to the last record.
Basically I just want to be able to insert text into a file where I
want.
Also is is possible to delete one line from a file which matches a
pattern.
Thanks
Iqbal
igandham@prestel.net
------------------------------
Date: 25 Feb 1997 06:19:27 GMT
From: "iSAEW aNDREJ" <iae@exchange.spb.inkom.ru>
Subject: PERL script for HTTP transfer ?
Message-Id: <01bc22e3$6a9065e0$4c32e8c1@Drew.spb.inkom.ru>
Help to me! I would like to use MIRROR but it works only via native FTP,
and my access in INTERNET is possible only through HTTP PROXY (Squid )!
Where is possible get PERL SCRIPT for work with HTTP by the protocol or
better MIRROR for HTTP PROXY ?
Isaev A.
St. Peterburg
------------------------------
Date: Tue, 25 Feb 1997 12:07:08 GMT
From: "NT_server" <mb420@hi.ft.hse.nl>
Subject: PERL what is it ? what can it do ?
Message-Id: <01bc2315$b9403710$2222b18f@nt_server>
Can someone inform me whether it is possible to create a script using perl
to handle form mail messages. I would like to use the data that is entered
on a form to be mailed to me in a pre-defined format. Is it at all possible
to do this ? If not, then what is ?
thanks, Allard
awp@poboxes.com
------------------------------
Date: Tue, 25 Feb 1997 06:33:13 GMT
From: tarver@sky.net (Steve Tarver)
Subject: Re: Perl5/Tk for Win95/NT
Message-Id: <33137f55.2177430@news.sky.net>
I just downloaded the Win95/NT port of Perl by ActiveWare (from the
oakland ftp site I think). This is a microsoft funded port but it
looks pretty cool. The docs claim there are modules for the registry,
ole, spawning processes, etc. I only know that ENV contains the right
stuff, pipes work, and shelling other command line stuff works. I am
on page 100 of Programming Pearl, so take that with a grain of
whatever. I am pretty excited though - its like working on a real
operating system.
http://www.ActiveWare.com
john@jssm.demon.co.uk (john smith) wrote:
>On 27 Jan 1997 19:32:15 GMT, Erh.O.Wagner@t-online.de (Erhard O.
>Wagner) wrote:
>
>>Hi world!
>>Is there somewhere a Perl5/Tk package available for Win95/NT?
>>
>
>>(Erh.O.Wanger@t-online.de)
>>
>>Erhard
>
>
>Me too... I checked the faqs I could find and Perl5 for NT is
>advertised as on ftp://ftp.intergraph.com/pub/win32/perl but
>doesn't seem to be anything there!
>John
>
>--john smith.
>
------------------------------
Date: Tue, 25 Feb 1997 09:07:33 GMT
From: sajaa@sn.no (Jarle Aasland)
Subject: Q: How to delete several files in one operation (newbie)
Message-Id: <3312a7ba.3429831@news.eunet.no>
Here is what I have done so far:
I have a script that generate text-files from user input. Then it
reads all the text-files and put the content into dynamically
generated web-pages (with x-number of files on each page).
Then, I have a script that lists all the generated text-files (output
to another html-page). From here, it's possible to edit or delete each
individual text-file.
Problem: I can now delete each file by itself (by clicking it's
respective "Delete" link), but what I want to do is choose several
files, and then "Delete all marked files".
Any help will be most appreciated.
Jarle Aasland,
NORWAY
------------------------------
Date: Tue, 18 Feb 1997 13:56:32 -0500
From: libeson <libeson@pdb.pdb.bnl.gov>
Subject: Running a program under a specific group.
Message-Id: <3309FB60.2781@pdb.pdb.bnl.gov>
On a UNIX platform, how do I run a perl script under a particular
group from within the script? The script is part of a WEB service,
so it gets run in a WEB environment and does not have a shell.
--
libeson
------------------------------
Date: Tue, 25 Feb 1997 09:44:58 +0100
From: Jordi Vivaldi <vivaldi_jorge@info.upf.es>
Subject: sockets
Message-Id: <3312A68A.2D2C@info.upf.es>
Hi
We're trying to implement client and server perl programs using sockets.
The client should sent text to the server, which should be sent back after
processing.
Since we don't have any experience using sockets, we have taken the
examples below (Perl man pages). Unfortunately, we have found some
problems:
- Print in line 88 (print "hello there ...") does not work (Nothing
shows up in client's screen).
- We do not know how to modify the client in order to pass parameters to
the server.
- Client requests work like an on/off switch.
Note: we're using Perl 5.002.
Anybody can help us ? Thanks in advance,
Best,
Jorge Vivaldi
Toni Tuells
##########################################################################
## server.pl
#!/usr/bin/perl -Tw
require 5.002;
use strict;
use Socket;
use Carp;
my $waitedpid = 0;
BEGIN { $ENV{PATH} = '/usr/ucb:/bin' }
my $NAME = '/tmp/catsock';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
sub spawn; # forward declaration
sub logmsg { print "$0 $$: @_ at ", scalar localtime, "\n" }
sub ctime { scalar localtime(shift) }
sub REAPER {
$SIG{CHLD} = \&REAPER; # loathe sysV
$waitedpid = wait;
}
sub spawn {
my $coderef = shift;
unless (@_ == 0 && $coderef && ref($coderef) eq 'CODE') {
confess "usage: spawn CODEREF";
}
my $pid;
if (!defined($pid = fork)) {
logmsg "cannot fork: $!";
return;
} elsif ($pid) {
logmsg "begat $pid";
return; # i'm the parent
}
# else i'm the child -- go spawn
open(STDIN, "<&CLIENT") || die "can't dup client to stdin";
open(STDOUT, ">&CLIENT") || die "can't dup client to stdout";
#open(STDERR, ">&STDOUT") || die "can't dup stdout to stderr";
exit &$coderef();
}
socket(SERVER,PF_UNIX,SOCK_STREAM,0)|| die "socket: $!";
unlink($NAME);
bind(SERVER, $uaddr)|| die "bind: $!";
listen(SERVER,5)|| die "listen: $!";
logmsg "server started on $NAME";
my ($tt,$aux);
$SIG{CHLD} = \&REAPER;
for ( $waitedpid = 0;
accept(CLIENT,SERVER) || $waitedpid;
$waitedpid = 0, close CLIENT)
{
next if $waitedpid;
logmsg "connection on $NAME";
spawn sub {
print "Hello there, it's now ", scalar localtime, "\n";
#exec '/usr/games/fortune' or die "can't exec fortune: $!";
#while ($tt = <SERVER>) {print $tt;}
exec 'ls -l' or die "can't exec ls: $!";
};
}
##########################################################################
## client.pl
#!/usr/bin/perl -w
require 5.002;
use strict;
use Socket;
my ($rendezvous, $line);
my ($aux,$remote);
$remote = shift || 'localhost';
$rendezvous = shift || '/tmp/catsock';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "socket: $!";
connect(SOCK, sockaddr_un($rendezvous)) || die "connect: $!";
while ($line = <SOCK>) {
print $line;
}
close(SOCK);
exit;
##########################################################################
------------------------------
Date: 24 Feb 1997 10:30:12 GMT
From: tom@palver.nospam.eiscat.no (Tom Grydeland)
Subject: The fabulous pink camel (or red, if you prefer that), a review.
Message-Id: <TOM.97Feb24113012@palver.nospam.eiscat.no>
I am the happy posessor of a fabulous, although rather weatherbeaten
and torn volume, bearing the proud title _programming perl_, a picture
of a dromedary on the front cover and ragged, pink back. (well,
perhaps rather more like magenta when I stop to think about it).
Since its replacement arrived, I've not spent much time to study the
old and tried book, but this weekend, out of curiousity, I decided to
leaf through it again, just to see what I'd missed before.
To my great surprise, I discovered I'd never really read chapter 2!
(Practical programming) I had looked at it, of course, and noticed
the place where the camels wander in where they don't belong
(something for the quote collector out there), but I'd never sat down
and read the chapter from beginning to end (or was it from #! to exit?)
All the problems I'd have avoided! such as split ' ' vs.
split /\s+/, or the difference between <<"EOF" and <<'EOF'
And the cookbooks (chapters 5 (Common tasks with perl) and
6 (Real perl programs)) are still an excellent source for perl style
and idioms, IMHO.
Of course, it talks of an ancient perl, and that means some of its
tips and tricks are obsolete, deprecated or even unsupported in modern
perls, but a quick peek in manpages or the -w flag will correct
anachronisms (sp?) from ruining your code.
All in all, it's still worth keeping and even reading from time to
time. I for one still had plenty to learn (no surprise there!)
Just a quick question:
The eval trick used in the grep-like programs in chapter 6 to avoid
recompiling patterns on each pass; has it been made obsolete by the /o
regexp modifier?
--
//Tom Grydeland <Tom@nospam.eiscat.no> # delete 'nospam.' for valid address
------------------------------
Date: Tue, 25 Feb 1997 06:33:18 GMT
From: tarver@sky.net (Steve Tarver)
Subject: Re: Win32/NT problems with ARGVand .pl association
Message-Id: <33148189.2741662@news.sky.net>
I am running ActiveWare's port - the installer makes this for you. It
is pretty easy to do yourself - just associate the extension with perl
and make a default action that runs it. The problem is specifying
command line args for running an arbitrary script. I've made a couple
of batch files and put them on my desktop so I can drag and drop files
from the explorer onto them. the batch file looks like
<foo>.pl %1 %2
My ARGV is working well. At Oakland, I noted that there were two
versions of perl. I think one came on the NT 3.51 SDK and the other
came from http://www.ActiveWare.com. I am using the latter.
"Trond Ruud" <troruud@online.no> wrote:
>Hi Perl experts,
>Im an old C and Unix programmer who has just installed Perl5 under WinNT
>4.0
>on my Intel PC, and I am intrigued by the very close similarities between
>Perl
>and C. However I'm having some problems with running my Perl scripts.
>
>First, my connecting the .pl extension to perl exe only results in
>NT opening a DOS window for a fraction of a second on doubleclicking the
>pl
>script in an NT window.So I have to manually open a DOS window and
>run the script by explicitly starting Perl, i.e
>as: $perl script.pl, which destroys most of the fun!
>
>second, Perl doesn't detect my command line arguments. i.e.:argv is always
>empty. I suspect that this problem's connected to my way of explicitly
>running perl, (as described above.)
>Any advice will be highly appreciated!
>regards
>Trond Ruud troruud@online
------------------------------
Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Jan 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.
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 9
***********************************