[7195] in Perl-Users-Digest
Perl-Users Digest, Issue: 820 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 7 02:07:14 1997
Date: Wed, 6 Aug 97 23:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 6 Aug 1997 Volume: 8 Number: 820
Today's topics:
Re: ... file updates & flock <merlyn@stonehenge.com>
Re: [Q] Converter between ELM filter-rules file to proc (Martin Ramsch)
Re: bug passing alists as sub arguments (Mike Stok)
Re: Case Statement.. (Mike Stok)
Code Breaks <eric@hilding.com>
Re: FAQ Location <seay@absyss.fr>
GD with win32 perl: parse error! <yt62@dial.pipex.com>
Head of CGI Department <rbhattac@jetson.uh.edu>
How do I save a hash in a file? (Eric Penn)
Re: How to get file names from a directory (Mats Larsson)
How to make Perl Regular expressions "Rightmost is gree <Patrice.Boissonneault@nrc.ca>
I'm a beginner - help! <tony@qsvideo.com>
Idiotic Perl Problem, can anyone help.... <Julian@productivity-group.co.uk>
Re: info from dead child-process in SIGN{'CHLD'} <merlyn@stonehenge.com>
Re: pattern match/replace (Craig Berry)
Re: pattern match/replace <ajohnson@gpu.srv.ualberta.ca>
Perl to EXE <serginho@alpha.hydra.com.br>
Re: Possible in Perl? Do it, I'll Pay ya! <oboyle@.cs.purdue.edu>
Re: Q: creating http post requests <rootbeer@teleport.com>
Re: Question about FAQ operation <rootbeer@teleport.com>
Re: Range operator question (Andrew M. Langmead)
Re: Too Many Files for Foreach Loop? <rootbeer@teleport.com>
Re: why doesn't `echo ~username` return a homedir? <rootbeer@teleport.com>
Re: why doesn't `echo ~username` return a homedir? (I R A Aggie)
Re: XS and variable length ret values (Andreas Schmidt)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 06 Aug 1997 20:58:49 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: bill@medtechnet.com (Bill Hliwa)
Subject: Re: ... file updates & flock
Message-Id: <8cen86prt2.fsf@gadget.cscaper.com>
>>>>> "Bill" == Bill Hliwa <bill@medtechnet.com> writes:
Bill> What is the proper way to uniquely update a file from perl? For example, if I
Bill> have a program like this (in pseudo-code):
Bill> open some.file for input
Bill> flock(some.file,2)
Bill> stuff = contents of some.file
Bill> flock(some.file,8)
Bill> close some.file
Bill> update stuff
Bill> open some.file for output
Bill> flock(some.file,2)
Bill> some.file = stuff
Bill> flock(some.file,8)
Bill> close some.file
Ouch. This hurts even to read it.
(1) never use flock(HANDLE,8)
(2) never lose the flock while you "own" the critical resource
(3) never close the handle if you need to keep the flock
Bill> How do you keep file access locked between closing a file in
Bill> input mode and opening again in output mode?
By not closing it. :-)
Here's the general plan:
open HANDLE, "+<somefile" or die;
flock HANDLE, 2;
@indata = <HANDLE>;
## do something to @indata
seek HANDLE, 0, 0;
truncate HANDLE, 0;
print HANDLE @indata;
close HANDLE;
That's it. And for examples of this, see my Web Techniques columns
at http://www.stonehenge.com/merlyn/WebTechniques/.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 390 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 6 Aug 97 09:47:24 GMT
From: ramsch@forwiss.uni-passau.de (Martin Ramsch)
Subject: Re: [Q] Converter between ELM filter-rules file to procmailrc file?
Message-Id: <slrn5ugi1a.6p0.ramsch@melian.forwiss.uni-passau.de>
On 5 Aug 1997 21:36:45 -0400, Dick Adams <rdadams@access5.digex.net> wrote
in an Usenet article:
>I have to agree with Elijah that procmail is not a user friendly
>utility.
In the procmail mailing list (BTW, recommended very much if you like
to use procmail a lot) recently someone mentioned a "proclint" utility
to do some easy checks of the .procmailrc syntax. I didn't check it
out myself, yet, but it could be of help.
>It was my impression that the original poster was hoping
>to find a utility program that would automate the conversion. The
>responses appear to be "you have to read the detail and figure it
>out for yourself." That's what I was afraid of!!
Me, too! I dislike these arrogant unhelpful answers a lot that just
say RTFM, but really saying: stupid, think yourself.
Unfortunately I don't have the time currently to write such a tool,
but it shouldn't be too difficult (I'd try it in perl ...).
If someone is going to code it:
One doesn't have to deal with the different syntactic forms allowed
in the filter-rules file, if you just take the output of "filter -r"
as this is normalized. (And as a side-effect this catches any errors
in filter-rules which otherwise might confuse the converter :-).
Well, now that I think about it I just could give it a try, too :-)
(And tree hours later *sigh*)
A most probably incomplete first version is at:
http://www.forwiss.uni-passau.de/~ramsch/Software/elmfilter2procmail.txt
(to view the source)
http://www.forwiss.uni-passau.de/~ramsch/Software/elmfilter2procmail.perl
(to download)
I'd love to get some feedback on it to be able to improve the script.
Everybody with some knowledge of both Elm Filter and Procmail, please
would you try this script and have a look whether or not the output
Procmail recipes reasonably resemble the original filter rules?
Regards,
Martin
--
Martin Ramsch <m.ramsch@ieee.org> <URL: http://home.pages.de/~ramsch/ >
------------------------------
Date: 6 Aug 1997 12:58:47 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: bug passing alists as sub arguments
Message-Id: <5s9se7$f88@news-central.tiac.net>
In article <33E74461.64BF@popmail.med.nyu.edu>,
William Biesty <biestw01@popmail.med.nyu.edu> wrote:
>I'm getting the following error message
>
> Odd number of elements in hash list at iceflow.pl line nnn
>
>in Perl 5.004 on a DEC Alpha UNIX (Digital UNIX V4.0B (Rev. 564);) when
>I
>pass an associative array as the middle argument to a subroutine.
>
> sub bob {
> local ($x, %y, $z) = @_;
> # some code here
> bob $x-1, %y, $z;
> }
>
> %aa=(...);
> bob 3, %aa, 0;
>
>When I move the list to the end of the arguments, I don't
>get the error. This code worked fine in version 4.0.1.7
>patch level 35 on ULTRIX V4.2A (Rev. 47).
That's because perl flattens the list out, and the %y in the assignment
will attempt to consume all of the rest of @_ (which is %aa, 0 - this does
have an odd number of elements as %aa has an even number by definition.)
One way to fix it is to have the hash as the last element in the list e.g.
sub bob {
local ($x, $z, %y,) = @_;
...
}
or to pass in the hash as a reference e.g.
sub bob {
local ($x $yRef, $z) = @_;
# access elements as $yRef->{$key} etc (see perlref man page)
...
}
bob 1, \%aa, 0;
as the reference is a scalar value which takes up a single slot in the
argument list.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 6 Aug 1997 13:17:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Case Statement..
Message-Id: <5s9thk$g5j@news-central.tiac.net>
In article <19970805235801.TAA15218@ladder02.news.aol.com>,
CT2963 <ct2963@aol.com> wrote:
>Question...
>
>Is there any type of case statement in Perl??? I cant seems to find any
>references to one or any code that uses one.
>
>If there is could somebody provide me with the syntax..
This is a frequently asked question (FAQ) which is answered in:
http://www.perl.com/CPAN/doc/manual/html/pod/perlfaq7/How_do_I_create_a_switch_or_case.html
which starts out like this:
How do I create a switch or case statement?
This is explained in more depth in the the perlsyn manpage. Briefly,
there's no official case statement, because of the variety of tests
possible in Perl (numeric comparison, string comparison, glob
comparison, regex matching, overloaded comparisons, ...). Larry
couldn't decide how best to do this, so he left it out, even though
it's been on the wish list since perl1.
Here's a simple example of a switch based on pattern matching. We'll
do a multi-way conditional based on the type of reference stored in
$whatchamacallit:
SWITCH:
for (ref $whatchamacallit) {
/^$/ && die "not a reference";
/SCALAR/ && do {
print_scalar($$ref);
last SWITCH;
};
/ARRAY/ && do {
print_array(@$ref);
last SWITCH;
};
/HASH/ && do {
print_hash(%$ref);
last SWITCH;
};
/CODE/ && do {
warn "can't print function ref";
last SWITCH;
};
# DEFAULT
warn "User defined type skipped";
}
The perlsyn manual page (and most good references on perl) should cover
this in more detail - The second edition of Programming Perl has "Bare
Blocks and Case Structures" in The Gory Details chapter (chapter 2)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Wed, 06 Aug 1997 15:44:07 -0700
From: Eric Hilding <eric@hilding.com>
Subject: Code Breaks
Message-Id: <33E8FE37.57BF@hilding.com>
>I'm sure I'm 'escaping' things right, but in trying to process
>this form data the darn thing breaks. perl -wc checks out okay
>for the whole script.
>#print MAIL " Work Tel: $FORM{'e7'), \"/\", $FORM{'e8'}, >\"ext\", $FORM{'e9'}\n";
>#print MAIL " Home Tel: $FORM{'e10'}, \"/\", $FORM{'e11'},\n";
Ummh, thing I perl -wc 'd with the darn ###'s still in. Just
realized I have a ")" after 'e7' instead of a "}".
Please excuse the post.
Eric
------------------------------
Date: Wed, 06 Aug 1997 12:40:16 +0200
From: Doug Seay <seay@absyss.fr>
To: "Paul D. Farber II" <farber@voicenet.com>
Subject: Re: FAQ Location
Message-Id: <33E85490.21A9CA92@absyss.fr>
[posted and mailed]
Paul D. Farber II wrote:
>
> Im looking for a URL for the current PERL FAQ for LINUX.
Try http://www.perl.com/perl/index.html then select "Perl FAQ" and you
will be directed to the FAQ on a CPAN mirror close to you. This is all
general stuff, I don't think there is too much that is Linux specific.
Perl works on Unix, Linux acts like Unix, it is as simple as that.
Assuming you have a well installed version of Perl, you have lots of
stuff at your finger tips. Try "man perlfaq" because there is a good
chance the files are already installed on your computer.
- doug
------------------------------
Date: Wed, 06 Aug 1997 15:24:34 -0700
From: IS-DEV <yt62@dial.pipex.com>
Subject: GD with win32 perl: parse error!
Message-Id: <33E8F9A2.D9B@dial.pipex.com>
Hello all,
I am running perl 5.003_07 build 307 on a windows nt4 machine.
I obtained GD-Tools which contains the GD package for windows,
as compiled and tweaked by Dave Roth. However placing "use GD;"
at the top of any script causes the perl script to fail with:-
Error: pase exception
any ideas???
Thanks inadvance ...fergus...
------------------------------
Date: Wed, 06 Aug 1997 08:59:29 -0500
From: Rishi Bhattacharya <rbhattac@jetson.uh.edu>
Subject: Head of CGI Department
Message-Id: <33E88341.5C0F@jetson.uh.edu>
Hello,
I am currently starting a new project and am looking for someone to head
the CGI department of my site. The project is www.webresource.net. It is
a site intended for webmasters of all genre's, from novice to advanced.
Please feel free to check out the layout at :
http://www.webresource.net/
My current team consists of experienced proffessionals, ranging from IBM
software developers to NASA engineers. We are already getting numerous
requests for advertising space, even before the site is complete. The
ideal applicant will have two very important traits : 1) A plethora of
experience in designing and writing java. 2) A reasonable amount of time
per week to devote to the project. (The amount of time is more clearly
defined below in the commonly asked questions). Please look over the
following commonly asked questions :
> What will I have to do?
You will be the complete head of the CGI section. What that section
will consist of is completely up to you. You can either spend time and
showcase the best scripts on the web, or you can concentrate on writing
articles (Like the ones on the front page) that show how to create
useful java scripts (or both). Again, at the risk of sounding redundant,
it is all up to you. That is one thing the current team members like --
they have the final say on everything. One thing will be required of
you, and that is that you write articles highlighting some aspect of cgi
design, implementation, etc.
> Who are the other team members?
There are currently five people working on the team. The head of the
Java department is an software engineer for IBM. The head of the vrml
section is a hardware engineer for Digital Equipment Corporation (DEC).
I myself am doing the activex section (I am a engineer for NASA). The
head of the graphics section is a graphic design specialist for the past
ten years. Finally, a internet consultant in Dallas is doing the HTML
and JavaScript sections.
> How will I be compensated for my work?
The team members and I are all working on a profit motive. That means
that we know that the site maybe a bust, and we also know that we could
get to the point where we have multiple $10000/month advertisers. I will
say this though, that whatever revenues are made, they will split right
down the middle. Everyone will get their equal share. How do you know
this? Well, if their was someway to prove to you that I am an honest
person, then I would. Until then, I guess you'll have to trust me. Maybe
this will help. I started this project not for monetary reasons, but for
valuable "experience" on my resume.
> Will I have to pay for anything ?
No. I will cover all hosting fees and other costs.
> How much work do I have to put in?
All team members currently have full time jobs. We will understand if
you can't work more than 10-15 hours/week.
If you meet the above qualifications and are interested (serious offers
only please) feel free to contact me at rbhattac@bayou.uh.edu. Please
email, for I will not be back to check this newsgroup for replies. Thank
you for your time.
Rishi Bhattacharya
rbhattac@bayou.uh.edu
------------------------------
Date: Thu, 07 Aug 1997 04:50:33 GMT
From: stupid@wco.com (Eric Penn)
Subject: How do I save a hash in a file?
Message-Id: <33e9513c.8440100@news.wco.com>
Right then. I'll admit that I'm new to the whole concept of hashes. I like
the way they work, but I'm totally stumped on how to save a hash into a
file.
First the application: I'm storing multiple records of a simple database
for a web-accesable challenge ladder. Each record contains the player name,
contact information, current record of wins and losses, and some other
miscelaneous information.
Up to this point, I've been storing all of my data in an array (list). To
save, I print the list to a FILEHANDLE. To read, I open the file and dump
it back into a list. Easy, but it forces me into knowing what data is where
in the list. I can't add new fields without converting every record to the
new format and invariably there is some problem.
Looking at hashes, I see a data structure that is perfect for my
application. Since the data is accessed by key, I can add new fields
without making any changes to the older records. But I have no way to store
these data structures.
I can create a hash. I can manipulate a hash. I can even print out a hash.
But short of converting the hash into a list and saving that to a data file
(which seems ugly to me) there seems to be no way to save a hash to a file
for later retrieval.
Am I missing somthing, or is this just The Way Things Are (tm)?
--
Eric Penn STUPID's three rules to life:
stupid@wco.com Stick with what you're good at,
http://www.wco.com/~stupid/ Learn from your mistakes, and
"stoo" When in doubt, act stupid!
------------------------------
Date: 7 Aug 1997 05:33:46 GMT
From: matlar@rsv.se (Mats Larsson)
Subject: Re: How to get file names from a directory
Message-Id: <5sbmnq$qi0$1@u30039.rsv.svskt.se>
In article <5roh91$jvi@ds2.acs.ucalgary.ca>, Euan Forrester <deforres@acs.ucalgary.ca> says:
>
>I need to write a Perl script to remove old files from a specific
>directory. I can find the time since the file was last accessed just fine,
>but I don't know how to find out what file names exist in the directory,
>so I can check them. Can anyone help me? Thanks in advance!
>
I don't know if I've missed something but why not just use opendir
and readdir ?
Something like this :
opendir (DIR, "."); #searching current directory
@allfiles = grep !/^\.\.$|^\.$/, readdir (DIR);
foreach $file (@allfiles) {
($atime) = (stat("$file")) [8];
# do whatever you like with this file
}
Regards Mats
Email: matlar@rsv.se
------------------------------
Date: Wed, 06 Aug 1997 15:42:55 -0400
From: Patrice Boissonneault <Patrice.Boissonneault@nrc.ca>
Subject: How to make Perl Regular expressions "Rightmost is greediest"?
Message-Id: <33E8D3BE.A662B42@nrc.ca>
In Regular expressions with Perl, when there are two mutipliers in a
single expresseon, the greedy rule is augmented with "leftmost is
greediest". For example:
$_ = "a xxx c xxxxxxxx c xxx d";
/a.*c.*d/;
In this case, the first ".*" in the regular expression matches all off
the caracters up to the second c, even though matching only the
caracters up to the first c would still allow the entire regular
expression to match.
How to tell Perl to match the caracters up to the first c. "Rigthmost
is greediest".
Please, help me.
Thanks
Patrice Boissonneault
-----------------------------
Patrice.Boissonneault@nrc.ca
------------------------------
Date: Wed, 06 Aug 1997 00:40:33 -0600
From: tony <tony@qsvideo.com>
Subject: I'm a beginner - help!
Message-Id: <33E81C60.20A83B48@qsvideo.com>
I'm trying to install the libwww, penguin and some other modules to my
ISP. I have perl5 installed on my own computer (running win '95). Do I
need it?
When I type 'perl makefile.pl' everything is just fine. When I type
'make' I get a a bad command error. Where am I going wrong? How do I
get these modules to install to my ISP?
Also, what are these patches the readme file keeps referring to? How do
I use them: perl5.004_01.pat, gd-1_14.pat, etc.?
Answers anybody?
Thanks!
------------------------------
Date: Thu, 07 Aug 1997 01:59:52 GMT
From: "Julian Rose" <Julian@productivity-group.co.uk>
Subject: Idiotic Perl Problem, can anyone help....
Message-Id: <01bca2d5$5c36a4b0$41402080@deepspace9>
Hi,
I have a perl script that's currently using the Unix ls command, I need to
rewrite the section that does so in order to run it on a server that allows
no unix commands.
I believe I will have to use a readdir command, but I have no idea how to
start, can anyone help, either an idiots guide to readdir, or, to earn
eternal gratuity, rewrite the section to work for me :)) (I live in hope)
The relevent defined variables for the script are:
$basedir:
Directory where the search page and graphic files are located.
$baseurl:
URL where search page and graphic files are located.
@files:
Location and type of files to search.
The section in question is as follows:
----snip----
sub get_files {
chdir($basedir);
foreach $file (@files) {
$ls = `ls $file`;
print "$ls";
@ls = split(/\s+/,$ls);
foreach $temp_file (@ls) {
if (-d $file) {
$filename = "$file$temp_file";
if (-T $filename) {
push(@FILES,$filename);
}
}
elsif (-T $temp_file) {
push(@FILES,$temp_file);
}
}
}
}
----snip----
Currently, the print is in there so I can watch the output, the current
output from the print "$ls" line is:
----snip----
jobs/1068-ip.html
jobs/2625-ip.html
jobs/2741-ip.html
jobs/2854-ip.html
jobs/2922-ip.html
jobs/blank.html
Content-type: text/html
----snip----
Any help would be most appreciated, I can be reached direct on
Julian@prodgrp.demon.co.uk (quickest way).
Cheers
Julian Rose
------------------------------
Date: 06 Aug 1997 21:07:49 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Hercules Huggins <hhuggins@hercules.engr.sgi.com>
Subject: Re: info from dead child-process in SIGN{'CHLD'}
Message-Id: <8c4t92pre2.fsf@gadget.cscaper.com>
[hint: comp.lang.perl doesn't exist.]
>>>>> "Hercules" == Hercules Huggins <hhuggins@hercules.engr.sgi.com> writes:
Hercules> The only thing I know of is
Hercules> $SIG{CHLD} = sub { wait };
And this suffers from both (1) doing too much in the signal handler
(hint: it might have to malloc, and that's not interrupt-safe), and
(2) missing waiting for some children (hint: the SIGC[H]LD pipe is
only one bit deep, so what happens if three kids all become ready at
once?).
The only safe signal is an ignored signal:
$SIG{CLD} = "IGNORE";
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 390 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 7 Aug 1997 01:01:05 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: pattern match/replace
Message-Id: <5sb6oh$og5$2@marina.cinenet.net>
Dan Brian (dan@clockwork.net) wrote:
: Can someone solve this one? I need this substitution to occur, and it must
: occur in one line of code (I know this can be inefficient). Several lines
: could also be doable.
:
: Assuming this is my line of text:
:
: < blah blah KEYWORD blah blah KEYWORD blah blah blah > KEYWORD < blah
: KEYWORD blah blah >
:
: I then need a search/replace string that will remove KEYWORD from strings
: where it occurs withing the < > brackets. Note that the word can occur
: numerous times withing the brackets, and that there can be several bracket
: sets on the text line. I need the above string to translate to:
:
: < blah blah blah blah blah blah blah > KEYWORD < blah blah blah >
:
: Can someone offer me a clean solution?
I've only lightly tested this, and it leaves excess whitespace in the
string, but how about:
$string = '<blah blah KEYWORD blah KEYWORD blah blah> KEYWORD <blah KEYWORD>';
print "Before: $string\n";
1 while $string =~ s/(<[^>]*?)KEYWORD([^<]*?>)/$1$2/g;
print "After: $string\n";
Output is:
Before: <blah blah KEYWORD blah KEYWORD blah blah> KEYWORD <blah KEYWORD>
After: <blah blah blah blah blah> KEYWORD <blah >
Note that the [^<]* term is my half-hearted attempt to avoid nested <>
sets; if that's really an issue, you'll need a true parser to tackle it.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Wed, 06 Aug 1997 21:03:25 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
To: dmi@questrel.questrel.com
Subject: Re: pattern match/replace
Message-Id: <33E92CED.20F37CE4@gpu.srv.ualberta.ca>
Dean Inada wrote:
>
> In article <33E8FE86.575BFEB5@gpu.srv.ualberta.ca> you write:
[snip]
> >! Can someone offer me a clean solution?
> >
> >clean? well, maybe after some laundering:
> >
> >s!(<[^>]*>)!($a=$1)=~s#KEYWORD##g;$a!eg;
> >
> >perhaps a simpler construct might be:
> >
> >1 while s/(<[^>]*?)KEYWORD/$1/g;
> >
> Yet another way:
>
> s/((\A|>)[^<]*)|\bKEYWORD\b/$1/g;
gives 'uninitialized' warnings under -w using 5.004,
which can be overcome by using capturing parentheses
in the alternations and using $+
s#(?:(>[^<]*)|\s?KEYWORD(\s?))#$+#g;
and this way should eat up the extra spaces left over
in the previous methods as well.
regards
andrew
------------------------------
Date: 6 Aug 1997 12:04:33 GMT
From: "Sergio Stateri Jr" <serginho@alpha.hydra.com.br>
Subject: Perl to EXE
Message-Id: <01bca261$4b83fd80$ca75e7c8@AFXTD_202.Autofax>
Hi ! Is tehre any way to transforma Perl program in a EXE runnable under
Win32 ??
Thanks in advance !
--
----------------------------------------------------------
Sergio Stateri Jr
Sco Paulo (SP) - Brazil
e-mail: serginho@mail.serve.com
----------------------------------------------------------
------------------------------
Date: 5 Aug 1997 20:41:16 GMT
From: Todd O'Boyle <oboyle@.cs.purdue.edu>
To: malp@ilesa.com
Subject: Re: Possible in Perl? Do it, I'll Pay ya!
Message-Id: <5s835c$a7g@ector.cs.purdue.edu>
[ courtesy copy cc'ed to malp@ilesa.com and posted ]
Mal Paine <malp@ilesa.com> contributed:
> Is it possible to write a perl script that establishes a raw connection to
> a host (not http:// or ftp:// or any other protocol), on port 1787, sends
> one line(the contents of a query string), gets the results, and writes them
> to the web page? If that is possible, and you can help me out, I'll pay. I
Off the top of my head, I can give you this:
--
## Very untested, but quite basic.
####
require 5.002;
## Better make sure you either have 5.004 or the IO modules.
use IO::Socket;
$nh = new IO::Socket::INET (
PeerAddr => 'lore.cs.purdue.edu:1787',
Proto => 'tcp',
Timeout => 10
);
$nh->print($query_string);
$nh->flush();
$nh->sysread($get_back, 32768); ## Maybe make # of bytes larger?
print "Got back: " . $get_back . "\n";
--
I don't want your money, go buy yourself a book on computer ethics.
-Todd
--
Todd O'Boyle - Programmer, Perl Hacker, BMX/MTB Rider, etc. -
URL: <a href="http://www.cs.purdue.edu/homes/oboyle/"> My Homepage! </a>
PGP: finger oboyle@.cs.purdue.edu -- EMAIL: oboyle@.purdue.edu
Note: Remove the "." (dot) after the @ sign to reach the destination
------------------------------
Date: Wed, 6 Aug 1997 07:09:17 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Riocreux <peter.riocreux@cs.man.ac.uk>
Subject: Re: Q: creating http post requests
Message-Id: <Pine.GSO.3.96.970806070823.29767F-100000@kelly.teleport.com>
On 5 Aug 1997, Peter Riocreux wrote:
> I need the libwww bundle, but I am still relatively new to this perl
> lark, so has anyone any pointers as to which modules (if any) I should
> look at first.
None, before you check out the libwww bundle! :-)
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 6 Aug 1997 08:02:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Lavender <brian@brie.com>
Subject: Re: Question about FAQ operation
Message-Id: <Pine.GSO.3.96.970806075150.29767Q-100000@kelly.teleport.com>
On Wed, 6 Aug 1997, Brian Lavender wrote:
> When I go to the FAQ index page located at http://www.perl.com/perl/faq/
> and I select the link for the FAQ as one large html document I land at
> the page at
>
> ftp://ftp.duke.edu/pub/perl/doc/FAQs/FAQ/PerlFAQ.html
Yes; tchrist has his machine set up to redirect you to a CPAN site
(potentially) near you.
> when you look at the html source of the one large html document, you see
> that each question has an anchor link which I believe is intended to
> place you on the question and the answer below. On my browser it does
> not.
Sounds like a bug. :-) (In the HTML of the FAQ, that is.)
> If I save the faq on my system and I remove the base tag in the head
> portion and I view it locally everything is great.
That's probably the best way, for now. And since the FAQ comes with 5.004,
you probably have a copy of it that way as well, right? :-)
> I once wrote Tom a nasty note because I thought I was getting jerked
> around because when I wanted to read the question and the answer I
> landed somewhere else. Of course he mailed me a nasty note back.
Of course. :-)
> Can you take a look at this?
Not I. It _is_ his machine, after all. When you own the perl.com domain,
you can have broken links there if you want to. :-) But I know that he
wants to have a great site, and he wants the FAQ's links to work. It's
probably on his "To Do" list already. But send a nice polite request to
the FAQ maintenance address and you may be pleasantly surprised. In
six to eight weeks. :-)
Good luck!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 6 Aug 1997 13:37:35 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Range operator question
Message-Id: <EEHv6n.7Dr@world.std.com>
Heinrich.Mislik@univie.ac.at (Heinrich Mislik) writes:
>Hello,
>I have a problem understanding the range operator. I want a range operator
>always starting with true and ending on some condition. Here is some
>demonstrationcode (tested with perl, version 5.004_01):
># ???? (Prints 12345678910)
>foreach(1 .. 10) {
> print if $x .. $_ == 4;
>}
Ok, so $x is always true. This means that the range operator will
always start. What happens is that once the range finishes with
"$_ == 4", it will return true again when $_ is 5.
Take a look at what the range returns:
#!/usr/bin/perl -w
# gotta love that "-w" switch.
for(1 .. 10) {
my $rangeresult = $x .. $_ == 4;
print "range returned: rangeresult\n";
print "I should print $_\n" if $rangeresult;
}
If you only wan to print until 4, maybe you should look at something else.
for(1..10) {
print;
last if $_ == 4;
}
for(1..10) {
print unless $done;
$done++ if $_ == 4;
}
>print "\n------------\n";
># ???? (Prints nothing)
>foreach(1 .. 10) {
> print if "a" .. $_ == 4;
>}
for this one, if you ran with the "-w" switch, you would see what perl
didn't like. It is trying to evaluate the constant value "a" as a
numeric value. Probably a bug in perl.
--
Andrew Langmead
------------------------------
Date: Wed, 6 Aug 1997 08:33:41 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Paul Denman <pdenman@ims.ltd.uk>
Subject: Re: Too Many Files for Foreach Loop?
Message-Id: <Pine.GSO.3.96.970806082912.29767X-100000@kelly.teleport.com>
On Wed, 6 Aug 1997, Paul Denman wrote:
> foreach $file_in (< *.dat>) {
> This has worked when there have only been a handful of files, but it
> is producing nothing with such a large number of files.
The globbing is currently done by csh, which does have a limit on the
number of files it can return. (If your perl binary was compiled to use
tcsh, there's no such limit.)
I recommend using readdir instead, since that's an easy fix which doesn't
suffer from this limit. Also, it doesn't have to start a new process and
wait for it to finish, so it should be faster.
opendir DIR, '.' or die "Can't opendir '.': $!";
while (defined($file_in = readdir DIR)) {
next unless $file_in =~ /\.dat$/;
#
# whatever processing you need
#
}
closedir DIR;
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 6 Aug 1997 06:55:18 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter De Gersem <Peter.DeGersem@esat.kuleuven.ac.be>
Subject: Re: why doesn't `echo ~username` return a homedir?
Message-Id: <Pine.GSO.3.96.970806065243.29767C-100000@kelly.teleport.com>
On Wed, 6 Aug 1997, Peter De Gersem wrote about how this...
> print `echo ~username`;
...didn't work, and said:
> The (less elegant?) solution I use now is
>
> print getpwnam('username'))[7], "\n";
Others have explained why the first one didn't work. Although the second
may seem less elegant, but it should be faster and more reliable than
starting another process, so that's what I'd use. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 06 Aug 1997 09:08:39 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: why doesn't `echo ~username` return a homedir?
Message-Id: <fl_aggie-ya02408000R0608970908390001@news.fsu.edu>
In article <33E8365E.300A@esat.kuleuven.ac.be>, Peter De Gersem
<Peter.DeGersem@esat.kuleuven.ac.be> wrote:
+ The (less elegant?) solution I use now is
+ print getpwnam('username'))[7], "\n";
IMHO, that would be the more elegant solution: you don't have to spawn off
another process (a shell of some sort) to get the answer you want.
James
--
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>
------------------------------
Date: 6 Aug 1997 13:06:26 GMT
From: schmidt@misun13.iai.fzk.de (Andreas Schmidt)
Subject: Re: XS and variable length ret values
Message-Id: <5s9ssi$lgi$1@nz12.rz.uni-karlsruhe.de>
In article <33E77410.15FB@merck.com>, "James J. Heck" <jheck@merck.com> writes:
|> I am trying to figure out how to write an XS procedure that takes one
|> value but returns a list of values. This list would be variable in
|> length. In otherwords I have a C function that will walk a linked list
|> and everytime it gets to a certain point in the list it will push this
|> value on the perl return stack and continue on until it gets to the end
|> of the Linked list.
|> Any help would be greatly appreciated.
|>
hello james
take a look in the perlxs, perlxstut and perlembed manpages. especially in the
perlxs manpage there is an example how you can return a list of values from an
xs-function. see the section where the 'PPCODE:' keyword is explained.
========================================================================
andreas schmidt email: schmidt@iai.fzk.de
institut fuer angewandte informatik (iai) phone: +49 7247 82 5714
forschungszentrum karlsruhe gmbh
- technik und umwelt -
postfach 3640 76021 karlsruhe (germany)
------------------------------
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 820
*************************************