[10884] in Perl-Users-Digest
Perl-Users Digest, Issue: 4485 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 23 08:07:21 1998
Date: Wed, 23 Dec 98 05:00:39 -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 Wed, 23 Dec 1998 Volume: 8 Number: 4485
Today's topics:
Re: Big-Endian to Little-Endian (Micha3 Rutka)
Re: Big-Endian to Little-Endian <gmj@netaxis.com>
Re: help with system() or `` (Tim Cutts)
HELP...what am I doing wrong? <bellears@deakin.edu.au>
How can I get the Mime Content-type of a file <Edouard.Ouin@tinet.ie>
Re: How can I get the Mime Content-type of a file <rra@stanford.edu>
Re: How can I get the Mime Content-type of a file <Edouard.Ouin@tinet.ie>
lib version doesn't match executable version (Bryce Pursley)
Newbie question on multiple Content-types <XamoXrphous@tecXhnolXogist.com>
Re: Newbie question on multiple Content-types <XamoXrphous@tecXhnolXogist.com>
NEWBIE: $_ <hvn@icon.co.za>
Re: numbers in base 36 <jhi@alpha.hut.fi>
Re: Please help me reading .csv textfiles <Paul.Makepeace@POBox.com>
Re: problem with $/ (Bart Lateur)
Re: problem with $/ <aqumsieh@matrox.com>
Re: Real Newbie--please help (Bart Lateur)
Re: Regex question - removing HTML tags.... (Gilly)
Re: regular expression alternation <sehughes@mistral.co.uk>
Re: Retrospective on comp.lang.perl.moderated? (Larry Rosler)
Re: Retrospective on comp.lang.perl.moderated? (Excession)
Re: Retrospective on comp.lang.perl.moderated? (Excession)
Re: Retrospective on comp.lang.perl.moderated? <rra@stanford.edu>
Re: sizeof() function? (Bart Lateur)
Re: Store HASHES into an Array??? dave@mag-sol.com
Re: Turning Variables into CAPS? <kait@vacheron.ch>
Re: Turning Variables into CAPS? <Paul.Makepeace@POBox.com>
Re: What's wrong with this code? razs@amdocs.com
Re: Win Port - AWK to Perl conversion <jlcrosby@fwi.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Dec 1998 12:13:14 +0100
From: rutka@lucent.com (Micha3 Rutka)
To: tlynch@cisco.com
Subject: Re: Big-Endian to Little-Endian
Message-Id: <wsmiuf3un5h.fsf@hzsac328.nl.lucent.com>
Tom Lynch <tlynch@cisco.com> writes:
> Greetings:
>
> I have a 32 bit Hex number which is
> Big-endian and I need to convert to
> Little-endian (i.e. 0001dc68 to 163b800).
Hym?-). How did you get your little-endian result?
> I seem to be having problems with pack:
>
> $little = (pack ('V*', unpack ('N*', $ARGV[0])));
> print ("$little\n");
You probably wanted this:
$little = (unpack ('V', pack ('N', hex($ARGV[0]))));
printf ("%x\n",$little);
But ..., it will give you 68dc0100 as result, not 163b800. Maybe, what you
want is also swap bit-order (i.e. MSB <-> LSB, etc). The code below
will do almost what you want:
$little = (unpack ('V', pack('b*',(unpack('B*',(pack('N', hex($ARGV[0]))))))));
printf ("%x\n",$little);
Uff. Lot of conversions here ;-). You can try to optimize it
somehow. If you do it, please send me a code.
I said, 'almost' because the result is now 163b8000 and not 163b800,
as you wanted.
> When I run the program I get:
>
> 100086cd
>
> which is converting on 16 bit boundries. Any
> ideas how to fix this. Thanks in advance for
> any help!
Because what you did was:
- you took two numbers representations, 0001 and dc68, and unpacked
them.
- then you packed them in reverse byte order, getting 1000 and 86cd.
The boundary is actually 32-bit, not 16.
Regards,
Michal
--
Dr. Ir. Michal Rutka Lucent Technologies - Huizen, The Netherlands
Senior System Engineer mailto:rutka@lucent.com
------------------------------
Date: Wed, 23 Dec 1998 11:33:07 +0000
From: "Geir Magnusson Jr." <gmj@netaxis.com>
Subject: Re: Big-Endian to Little-Endian
Message-Id: <3680D4F2.BB406CE6@netaxis.com>
VG9tIEx5bmNoIHdyb3RlOg0KDQo+IEdyZWV0aW5nczoNCj4NCj4gICAgICAgICBJIGhhdmUg
YSAzMiBiaXQgSGV4IG51bWJlciB3aGljaCBpcw0KPiAgICAgICAgIEJpZy1lbmRpYW4gYW5k
IEkgbmVlZCB0byBjb252ZXJ0IHRvDQo+ICAgICAgICAgTGl0dGxlLWVuZGlhbiAoaS5lLiAw
MDAxZGM2OCB0byAxNjNiODAwKS4NCj4gICAgICAgICBJIHNlZW0gdG8gYmUgaGF2aW5nIHBy
b2JsZW1zIHdpdGggcGFjazoNCj4NCg0KSXQncyBlYXJseSBpbiB0aGUgbW9ybmluZywgYW5k
IHRoZSBFYXJsIEdyZXkgaGFzbid0IGtpY2tlZCBpbi4gIFdoeSBpcw0KMHgwMDAxZGM2OCAg
MHgwMTYzYjgwMCB3aGVuIHlvdSBmbGlwIEVuZGlhbi1pc20/ICBXb3VsZG4ndCBpdCBiZQ0K
MHg2OGRjMDEwMD8NCg0KV2h5IGRvZXMgaXQgc2VlbSB0aGUgbnliYmxlcyBnZXQgbXVuZ2Vk
Pw0KSGVyZSBpcyB3aGF0IEkgZGlkLi4uDQoNCiMvdXNyL2Jpbi9wZXJsDQp1c2Ugc3RyaWN0
Ow0KDQpteSgkbnVtKSA9IDB4MDAwMWRiNjg7DQpteSgkb3RoZXIpID0gdW5wYWNrKCJWIiwg
cGFjaygiTiIsJG51bSkpOw0KcHJpbnRmKCIweCUwOFggLT4gMHglMDhYXG4iLCAkbnVtLCAk
b3RoZXIpOw0KDQpnZWlyDQoNCi0tDQpHZWlyIE1hZ251c3NvbiBKci4NCmdtakBuZXRheGlz
LmNvbQ0KUGVybCdzIGdhcmJhZ2UgY29sbGVjdG9yIGFiaG9ycyBhIG5ha2VkIGNpcmN1bGFy
aXR5LiAtdGMNCkNoYXNlIHRoZSBkcmVhbSwgbm90IHRoZSBjb21wZXRpdGlvbi4NCg0KDQo=
------------------------------
Date: 23 Dec 1998 09:47:15 +0000 (GMT)
From: timc@chiark.greenend.org.uk (Tim Cutts)
Subject: Re: help with system() or ``
Message-Id: <7Fl*i8cOn@news.chiark.greenend.org.uk>
I have solved this problem (in my case I was running long DNA sequence
analysis programs from a CGI script). Here's what I did:
Once you have validated the form input, fork. Now, you have numerous
things you want to cope with:
1) You want to stop the browser timing out.
2) You want to be able to kill the long running process and roll back
if the user hits the STOP button.
Your forked processes have distinct purposes; one of them will run the
SQL stuff. In order to get the data to the browser nicely, I found it
was best to run the command as follows:
open (SQL, "somesql |")...
and then use select() and sysread() to get data from the command
without blocking, and pass it on to the web browser. It should be the
child process that does this.
Now, in the parent process you need to do a few things. Set up a
SIGPIPE handler, to clean up if the user presses the stop button (such
as killing the child process, removing its entry from any load
management system, etc etc)
Finally, have this process print status messages every few seconds, so
that (a) the user doesn't think the machine's forgotten about them,
and (b) to deliberately trigger the SIGPIPE if the browser goes away,
for whatever reason.
As someone else said, you also need to have $|=1 at the beginning of
your script.
Of course, this mechanism is rather UNIX specific. If you're doing
this on NT, pass.
Tim.
PS. I am willing to mail my code to anyone who really needs it. UK
academic community users can see it in action at:
http://www.bio.cam.ac.uk/cgi-bin/blast2/blast2.pl
------------------------------
Date: Wed, 23 Dec 1998 19:04:52 +1100
From: Mick <bellears@deakin.edu.au>
Subject: HELP...what am I doing wrong?
Message-Id: <3680A424.B4CA3A00@deakin.edu.au>
Hi,
I've got a file upload page working correctly.
Ok....I've checked the users directory, and the file there trying to
upload already exists, so I'm trying to do this.....
(In Perl)
print "<FORM METHOD=POSTACTION=\"choose-assignment.pl?ADD\"
enctype=\"multipart/form-data\">";
print "<P><Center>Click ";
print "<INPUT TYPE=SUBMIT VALUE=NEWUPDATE> ";
print "to upload file.</CENTER></FORM>";
print "</CENTER>";
print "<FORM METHOD=POST
ACTION=\"choose-assignment.pl?NOADD\" enctype=\"multipart/form-data\">";
print "<P><Center>Click ";
print "<INPUT TYPE=SUBMIT VALUE=NOUPDATE> ";
print "to cancel file upload.</CENTER></FORM>";
print "</CENTER>";
Now I've put -
if ($queryString eq "NOADD" )
{
print STDERR "#################NOT ADDING $thefilename\n";
exit(1);
}
and
if ($queryString eq "ADD" )
{
print STDERR "#################ADDING $thefilename\n";
exit(1);
}
Which seem to work, but they do not cause the program to exit - the
file dialogue pops back up?
What am I doing wrong?????
Thanks in advance,
Mick
------------------------------
Date: Wed, 23 Dec 1998 10:17:29 +0000
From: Edouard Ouin <Edouard.Ouin@tinet.ie>
Subject: How can I get the Mime Content-type of a file
Message-Id: <3680C339.3BDF135A@tinet.ie>
Hi,
How can I get the Mime Content-type of a file that is store on my hard
drive.
I want to get a Mime content-type that is defined in the mime.type
defined in Apache web server configuration.
PS: sorry for my bad english.
Thank's for your time
--
---------------------------------------------------------
Edouard Ouin
Telecom Internet Tel: (353) 1 701 0182
Unit B, East Point Business Park Fax: (353) 1 701 1086
Fairview http://www.tinet.ie
Dublin 3 Edouard.Ouin@tinet.ie
Ireland Mobile : 087 289 0934
------------------------------
Date: 23 Dec 1998 02:36:47 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: How can I get the Mime Content-type of a file
Message-Id: <yl90fzuou8.fsf@windlord.stanford.edu>
Edouard Ouin <Edouard.Ouin@tinet.ie> writes:
> How can I get the Mime Content-type of a file that is store on my hard
> drive. I want to get a Mime content-type that is defined in the
> mime.type defined in Apache web server configuration.
The way that the web server does this is that it looks at the file
extension and then looks it up in a database of mappings from file
extension to MIME type. If you want to get the same information, you'll
probably have to do the same thing.
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Wed, 23 Dec 1998 11:53:06 +0000
From: Edouard Ouin <Edouard.Ouin@tinet.ie>
To: Russ Allbery <rra@stanford.edu>
Subject: Re: How can I get the Mime Content-type of a file
Message-Id: <3680D9A2.A7FD6E5B@tinet.ie>
--------------9250434FC8E9DFC9066166B9
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi,
Thank's for responding, but apple Macintosh file and sometimes Win95 files
doesn't have an extension....
so have you got an other idea, please...I'll appreciate
Thank's for your time
Russ Allbery wrote:
> Edouard Ouin <Edouard.Ouin@tinet.ie> writes:
>
> > How can I get the Mime Content-type of a file that is store on my hard
> > drive. I want to get a Mime content-type that is defined in the
> > mime.type defined in Apache web server configuration.
>
> The way that the web server does this is that it looks at the file
> extension and then looks it up in a database of mappings from file
> extension to MIME type. If you want to get the same information, you'll
> probably have to do the same thing.
>
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
> 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
--
---------------------------------------------------------
Edouard Ouin
Telecom Internet Tel: (353) 1 701 0182
Unit B, East Point Business Park Fax: (353) 1 701 1086
Fairview http://www.tinet.ie
Dublin 3 Edouard.Ouin@tinet.ie
Ireland Mobile : 087 289 0934
--------------9250434FC8E9DFC9066166B9
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi,
<p>Thank's for responding, but apple Macintosh file and sometimes Win95
files doesn't have an extension....
<br>so have you got an other idea, please...I'll appreciate
<p>Thank's for your time
<p>Russ Allbery wrote:
<blockquote TYPE=CITE>Edouard Ouin <Edouard.Ouin@tinet.ie> writes:
<p>> How can I get the Mime Content-type of a file that is store on my
hard
<br>> drive. I want to get a Mime content-type that is defined in
the
<br>> mime.type defined in Apache web server configuration.
<p>The way that the web server does this is that it looks at the file
<br>extension and then looks it up in a database of mappings from file
<br>extension to MIME type. If you want to get the same information,
you'll
<br>probably have to do the same thing.
<p>--
<br>#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
<br>$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{
> 0gFzD gD,
<br> 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.),
01,pnn,y{
<br>rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print</blockquote>
<pre>--
---------------------------------------------------------
Edouard Ouin
Telecom Internet Tel: (353) 1 701 0182
Unit B, East Point Business Park Fax: (353) 1 701 1086
Fairview <A HREF="http://www.tinet.ie">http://www.tinet.ie</A>
Dublin 3 Edouard.Ouin@tinet.ie
Ireland Mobile : 087 289 0934</pre>
</html>
--------------9250434FC8E9DFC9066166B9--
------------------------------
Date: Wed, 23 Dec 1998 12:35:34 GMT
From: hbpursle@duke-energy.com (Bryce Pursley)
Subject: lib version doesn't match executable version
Message-Id: <3684e1d9.2914058073@news.infoave.net>
On NT4.0
Couldn't get makefile to work at all so I installed "latest?" version
of perl. Now when I run makefile I get an error message that says:
Perl lib version (5.00402) doesn't match executable version (5.00307)
at C:\PERL\lib/Config.pm line 7.
perl -v returns:
This is perl, version 5.004_02
Where is makefile finding the old executable? All the registry
entries and the path statement point to C:\perl\bin which is where I
installed this last version.
------------------------------
Date: Thu, 24 Dec 1998 00:49:46 +1300
From: "Applak!" <XamoXrphous@tecXhnolXogist.com>
Subject: Newbie question on multiple Content-types
Message-Id: <914414350.726517@newsch.es.co.nz>
I've written a script (my 1st). It randomly picks a url and a image from 2
arrays I have (in the script), then is supposed to return the link and
image... Then when the user clicks on the image, they should be taken to
the site the URL links to...
I really want to do this without having to use SSI's...
Ta...
#! /usr/bin/perl
### Configuration Section ###
@banners = ('/images/1.gif', '/images/2.gif');
@urls = ('http://www.url1.co.nz', 'http://www.url2.co.nz');
### End Config ###
srand;
$random_number = int(rand(@banners));
&SendURL($urls[$random_number]);
&SendImg($banners[$random_number]);
&CloseURL;
exit;
# Sends an image... Code pilfered from Pid.cgi -=> Drag 'n' Drop CGI
sub SendImg
{
local($img) = @_;
$img_file = join('/', $ENV{'DOCUMENT_ROOT'}, $img);
$itype = (split('.', $img))[1];
if (open(IMAGE, "<".$img_file)) {
$no_bytes = (stat ($img_file)) [7];
print "Content-type: image/$itype\n";
print "Pragma: no-cache\n";
print "Content-length: $no_bytes\n\n";
print <IMAGE>;
close(IMAGE);
}
else {
print "Content-type: text/plain\n\n";
print "Couldn't open image file $img_file\n";
exit;
}
}
sub SendURL
{
local($url) = @_;
print "Content-type: text/html\n\n";
print "<a href=\"$url\">\n";
}
sub CloseURL
{
print "Content-type: text/html\n";
print "</a>";
}
--
To reply remove all X's from the e-mail address.
------------------------------
Date: Thu, 24 Dec 1998 01:33:08 +1300
From: "Applak!" <XamoXrphous@tecXhnolXogist.com>
Subject: Re: Newbie question on multiple Content-types
Message-Id: <914416947.874751@newsch.es.co.nz>
Whoops, forgot to mention that it doesn't work... :-)
Anyone know why??? And I really need to get around using SSI...
Applak! wrote in message <914414350.726517@newsch.es.co.nz>...
>I've written a script (my 1st). It randomly picks a url and a image from 2
>arrays I have (in the script), then is supposed to return the link and
>image... Then when the user clicks on the image, they should be taken to
>the site the URL links to...
>
>I really want to do this without having to use SSI's...
>
>Ta...
>
>#! /usr/bin/perl
>### Configuration Section ###
>@banners = ('/images/1.gif', '/images/2.gif');
>@urls = ('http://www.url1.co.nz', 'http://www.url2.co.nz');
>### End Config ###
>srand;
>$random_number = int(rand(@banners));
>&SendURL($urls[$random_number]);
>&SendImg($banners[$random_number]);
>&CloseURL;
>exit;
>
># Sends an image... Code pilfered from Pid.cgi -=> Drag 'n' Drop CGI
>sub SendImg
>{
> local($img) = @_;
> $img_file = join('/', $ENV{'DOCUMENT_ROOT'}, $img);
> $itype = (split('.', $img))[1];
> if (open(IMAGE, "<".$img_file)) {
> $no_bytes = (stat ($img_file)) [7];
> print "Content-type: image/$itype\n";
> print "Pragma: no-cache\n";
> print "Content-length: $no_bytes\n\n";
> print <IMAGE>;
> close(IMAGE);
> }
> else {
> print "Content-type: text/plain\n\n";
> print "Couldn't open image file $img_file\n";
> exit;
> }
>}
>
>sub SendURL
>{
> local($url) = @_;
> print "Content-type: text/html\n\n";
> print "<a href=\"$url\">\n";
>}
>
>sub CloseURL
>{
> print "Content-type: text/html\n";
> print "</a>";
>}
>
>
>
>--
>To reply remove all X's from the e-mail address.
>
>
------------------------------
Date: Wed, 23 Dec 1998 11:55:32 +0200
From: "Helen van Niekerk" <hvn@icon.co.za>
Subject: NEWBIE: $_
Message-Id: <75qegl$11n$1@hermes.is.co.za>
Hi
I am using a perl script to upload a file to our Web server and then to mail
the file to the subscribers of our mailing list.
I read 10 email addresses into eml and then call the following bit of code:
( where filename is the name of the uploaded file.
open(EML, "|fastmail -f DCD -F editor\@dso.pwv.gov.za -s Newsletter - $eml
");
while(<$filename>)
{
print EML $_;
}
close(EML);
And it works fine for the first 10. The next 10 people get an empty email
as we now have our file pointer at the bottom of the file. Correct?
How do I reset the file pointer without explicitly opening and closing this
file. ( Have tried that one - and nobody got anything! )
Any help will be appreciated...
Helen van Niekerk
------------------------------
Date: 23 Dec 1998 10:44:05 +0200
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: numbers in base 36
Message-Id: <oeek8zjz1re.fsf@alpha.hut.fi>
abigail@fnx.com (Abigail) writes:
> ++ > $ echo "obase = 789; 123 ^ 456" | bc
> ++
> ++ Cheating! My original question wanted the answer in Java. Somebody
> ++ said "Java" and "in any base"...
>
>
> I guess you can use some kind of pipe object in Java and communicate
> with bc.
>
> But that wouldn't be a one liner any more. And I love one liners.
That's no news. :-)
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Wed, 23 Dec 1998 11:54:36 -0000
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: Please help me reading .csv textfiles
Message-Id: <75qo48$22g$1@statler.server.colt.net>
Bill Moseley wrote in message <368040b9$0$204@nntp1.ba.best.com>...
>In article <367EF5B3.1E0ED1CC@abim.net>, cva@abim.net says...
>>I am trying to read .csv (comma-seperated) files, which have been
>>exported from MS Excel or Access, for example.
>
>Did you try the example in perlfaq4:
>
>"How can I split a [character] delimited string except when
>inside [character]? (Comma-separated files)"
Also I have:
sub encode {
join ',', map {
s-\\-\\\\-g; s-\n-\\n-g; s-\t-\\t-g;
/,/ ? do{s/"/""/g; qq{"$_"}} : $_
} (my @tmp = @_);
}
(which won't quote unless it has to)
sub decode {
my $s = shift;
my @fields;
while ($s ne '' and
$s =~ s-^"((?:[^"]|"")*)"(?:,|$)-- ||
$s =~ s-^(.*?)(?:,|$)--) {
($_ = $1) =~ s/""/"/g;
s-\\n-\n-g; s-\\t-\t-g; s-\\\\-\\-g;
push @fields, $_;
}
@fields;
}
Which does some basic newline/tab encoding. Use of 'and' and '||' and ne ''
is important and deliberate. If anyone spots any problems or how the
perlfaq4 one is better/worse, please let me know.
Cheers, Paul.
--
Paul Makepeace, Independent Thinkers Ltd (UK)
0171 377 8668 / 0973 800436
"People are all monkeys, and I am Captain Banana"
-- Vincent Gallo
------------------------------
Date: Wed, 23 Dec 1998 10:54:36 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: problem with $/
Message-Id: <3689c900.9260135@news.skynet.be>
Alex Farber wrote:
>I have a file, which consists of many blocks,
>separated by "-----------------\n". And there's
>a multi-lined comment at the end of some blocks:
>
>-----------------
>blah blah blah
>blah2 blah2
>Comment: yadda yadda
> yadda yadda
>-----------------
>
>Now how do I extract these comments (yadda)? I try:
>
>
>$INPUT_RECORD_SEPARATOR = "-----------------\n"
>...
>while (<READ>)
>{
> if (m'\nComment:\s+(.+)${INPUT_RECORD_SEPARATOR}'is)
Hmmm... Maybe you should try to get rid of the $INPUT_RECORD_SEPARATOR
by a simple chomp().
It would be safer anyway. Suppose somebody changed the separarator to
something containing metacharacters, ex. "***\n". Your code will break,
no doubt about that. If you get it to work in the first place. :-)
Bart.
------------------------------
Date: Wed, 23 Dec 1998 00:47:28 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: problem with $/
Message-Id: <x3yu2ynpfyo.fsf@tigre.matrox.com>
lr@hpl.hp.com (Larry Rosler) writes:
> From `perldoc perlop`:
>
> With the 'm' you can use any pair of non-alphanumeric,
> non-whitespace characters as delimiters (if single
> quotes are used, no interpretation is done on the
> replacement string...
I don't have that in my copy of perlop. What version of Perl did that
come from?
Ala
------------------------------
Date: Wed, 23 Dec 1998 10:54:32 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Real Newbie--please help
Message-Id: <3687c66a.8597465@news.skynet.be>
Anna Shparberg wrote:
>What annoys me is having to
>store and run them in perl5\bin, otherwise they won't run at all. My
>path in the autoexec.bat file is set like this:
>path %path%;C:\Perl5\perl5\bin;
>
>How do I run Perl from another directory?! Please don't laugh at me!
Since PATH includes the path to perl.exe, you don't have to specify
that.
So, if you try run
perl myscript.pl *.txt
with the current directory set to where the script is, it will run, and
@ARGV will contain a list of all .TXT files in this directory.
So the magic is in setting the current directory before trying to run
the script. (Sometimes it's known as "working directory".)
Alternatively, you can specify the full path to the script (not to
perl.exe). But *.txt will still return a list of all .TXT files in the
current directory, wherever that is.
HTH,
Bart.
------------------------------
Date: Wed, 23 Dec 1998 12:52:10 GMT
From: mingtian@hanmail.net (Gilly)
Subject: Re: Regex question - removing HTML tags....
Message-Id: <3680e767.1347834@usenet.kornet21.net>
:To show how the above utterly fails what would it do to the following?
:
:--sample.html---
:<!-- Start of Page -->
:<script>Some script stuff</script>
:<P>Lots and lots of HTML goes here....</P>
:...
:<!-- End of Page -->
:--sample.html---
s/<!--.*?-->//gs;
s{<script.*?>.*?</script>}{}gsi;
s{<style.*>.*?</style>}{}gsi;
s{</?[A-Z]+?(?:\s+.*?(?:\s*=\s*(?:(["']).*?\1|.*?)))*\s*>}{}gsi;
@}`,--- ">#F([%Tg%e)` #me %M%o(`
ICQ: 15668514
------------------------------
Date: Wed, 23 Dec 1998 10:31:08 +0000
From: Stuart Hughes <sehughes@mistral.co.uk>
Subject: Re: regular expression alternation
Message-Id: <3680C66C.E9953550@mistral.co.uk>
Tad McClellan wrote:
> That wheel has already been invented, I'd just use that. See below.
Thanks, but I wanted to do it with a regular expression. The real point
of the posting is that I didn't realize that the alternate clause would
produce its output in $3. I find this odd, because the sort of thing I'
trying to do is say:
($a,$b) = /(.*)\(.*)/ or ($a, $b) = /(.*)/;
I thought using alternation, would try the first alternative, and if
that failed, try the second, and that would return the default in $1.
Any ideas how it should be done using regular expression maching ????
>
> : The following works for file.ext and file.more.ext,
> : but it doesn't match file. I thought the alternation clause would catch
> : it but it doesn't and so I'm confused ?? any ideas
>
> It does catch it. But it puts it in $3, which you do not access...
>
> : ($name, $ext) = /(?:^(.*)\.(.*))|(^.*)/;
>
Thanks for your help
Stuart Hughes
------------------------------
Date: Wed, 23 Dec 1998 00:29:02 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <MPG.10ea49a913f94da2989970@nntp.hpl.hp.com>
In article <MPG.10e2d95848e744bd989963@nntp.hpl.hp.com> on Thu, 17 Dec
1998 09:03:56 -0800, Larry Rosler <lr@hpl.hp.com> says...
> With year-end-assessment time rapidly approaching, would anyone care to
> comment on how comp.lang.perl.moderated has performed over its life of
> six months or so, relative to the hopes and expectations of its
> proponents?
>
> A cost-benefit analysis at this time might be enlightening.
Having raised this question, I guess I have to ultimately ante up my own
$0.02 worth.
I have been little affected by ...moderated. I read it and ...misc (and
...announce and ...modules) assiduously, without filters, via a wide-
band connection that I don't pay for. So I don't have the volume-of-
information problems that others report.
I am very glad that the people who have the most breadth and depth of
Perl wisdom (including TomC, Randal, MJD, TomP, bdf, Abigail, and others
who I hope won't be offended by my forgetting to name them explicitly)
have continued to guide ...misc by correcting our most egregious
mistakes. My most serious concern had been that they would abandon it,
so I would have fewer people to learn from.
I am mystified by whether to post to ...misc or ...moderated or both,
which has simply added the potential for more mistakes.
So for me, ...moderated has been more-or-less a NOP, while the comments
in response to my inquiry have been mostly supportive of it, despite its
still not having quite 'found its legs'. Laissez les bons temps rouler!
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 23 Dec 1998 10:03:20 GMT
From: daccles@bad.spam.no.spam.pcug.org.au (Excession)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <3681bd20.24289808@news.ozemail.com.au>
mgjv@comdyn.com.au (Martien Verbruggen) wrote:
>(Excession) writes:
>You shouldn't have bothered.
Thankyou for your kind and caring words. There is such a lot of people who
simply don't bother, I guess that it is the de facto NORM; don't rock the boat,
etc.
>Gosh... You're a nice person, aren't you? If you make claims like
>that, I'd like you to provide the numbers proving it. I have not seen
>much change in the way clp.misc works since clp.mod came into
>existence.
The brays and whinnies coming from c.l.p.misc BEFORE the advent of
c.l.p.moderated, were peppered with the claims from various people, that the
.misc group was a waste of space, and come the revolution, they would take
their marbles and frequent a less noisy area.
I have zero problem with people wanting to enjoy a reduced noise environment,
but I have a great deal of bile to get rid of when those people CONTRIBUTE to
the noise, not to add useful information, but only to sneer and chide and
berate those people asking for clues.
The c.l.p.misc newsgroup is still full of people asking questions about Perl,
but the number of USEFUL answers appearing in the group has risen
significantly, since the tub-bashing purists and zealots laid off, and left the
group alone. Yes, a lot of the questions could be answered by appropriate
study of the Perl documentation, but that doesn't mean that the person(s)
asking are stupid, just that they aren't aware of the resources available to
them.
>> a flash, if these purists and fascists of the Perl community would
>> actually practice the 'Be nice' approach to Perl queries.
>Being nice, in the way that you are being nice in your criticisms?
>Hmm.
The querent requested a response, and I answered, in the negative, and gave my
reasons for doing so. I'm not going to apologise for standing my ground.
Obsequiousness is for wimps. :-)
Dac
---
David Andrew Clayton # Please remove NO_SPAM when
dac@NOSPAM.pcug.org.au # sending email replies.
I post therefore I am. #
------------------------------
Date: Wed, 23 Dec 1998 10:33:49 GMT
From: daccles@bad.spam.no.spam.pcug.org.au (Excession)
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <3682bff8.25017623@news.ozemail.com.au>
rjk@linguist.dartmouth.edu (Ronald J Kimball) wrote:
>Excession <daccles@bad.spam.no.spam.pcug.org.au> wrote:
>> When the EFNET #perl channel denizens were confronted (on a few occasions)
>> with the 'hmm, well why didn't the .misc newsgroup die as expected', their
>> response was remarkable silence.
>Maybe you expected .misc to die, but no one else did.
Rubbish. A heap of people claimed that they were going to leave the .misc
group and concentrate all of their activity in the .moderated group, and as a
direct result of this migration, nobody would use .misc anymore. Dejanews
holds the evidence.
http://x14.dejanews.com/getdoc.xp?AN=361647329&CONTEXT=914407727.2087321642&hitnum=10
http://x12.dejanews.com/getdoc.xp?AN=376981955&CONTEXT=914408564.159514820&hitnum=32
http://x12.dejanews.com/getdoc.xp?AN=345742514&CONTEXT=914408564.159514820&hitnum=23
http://x12.dejanews.com/getdoc.xp?AN=380136958&CONTEXT=914408564.159514820&hitnum=16
:-)
>From IRC (name replaced to protect the guilty)
<xxxx> it is not opinion, but fact. clpmisc sucks.
<xxxx> very few people who know anything have read clpmisc for years.
<xxxx> i can count on both hands the number of experts who have regularly read
clpmisc over the past year. and they only read a very small percentage
of the posts.
<xxxx> we should have a moratorium on clueful responses in clpmisc
<xxxx> who is Bunore?
<xxxx> a wanker on clp.misc, news.groups, et al.
<xxxx> I got flamed in CLPM for calling the camel-2 a "blue" camel.
<xxxx> i'm surprised anyone reads .misc anymore
<xxxx> clpmisc sucks donkey dick. it is begin replaced.
>Given that your question contained an incorrect assumption
That isn't a given, it is *your* presumption that my recollection of the
opinions posted by people in .misc, is flawed.
>how did you expect people to answer it?
I don't expect anyone to answer my RESPONSE to someone elses question. I
voiced my opinion, deal with it.
>Actually, maybe your question was met with silence because people were
>ignoring you. Not surprising, if your behavior on #perl is anything
>like your behavior in that post. ;-)
Heh, #perl is truly a den of inequity.
Dac
---
David Andrew Clayton # Please remove NO_SPAM when
dac@NOSPAM.pcug.org.au # sending email replies.
I post therefore I am. #
------------------------------
Date: 23 Dec 1998 02:35:01 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Retrospective on comp.lang.perl.moderated?
Message-Id: <ylbtkvuox6.fsf@windlord.stanford.edu>
Excession <daccles@bad.spam.no.spam.pcug.org.au> writes:
> I have zero problem with people wanting to enjoy a reduced noise
> environment, but I have a great deal of bile to get rid of when those
> people CONTRIBUTE to the noise, not to add useful information, but only
> to sneer and chide and berate those people asking for clues.
Isn't it nice that the amount of this has dropped?
> The c.l.p.misc newsgroup is still full of people asking questions about
> Perl, but the number of USEFUL answers appearing in the group has risen
> significantly, since the tub-bashing purists and zealots laid off, and
> left the group alone. Yes, a lot of the questions could be answered by
> appropriate study of the Perl documentation, but that doesn't mean that
> the person(s) asking are stupid, just that they aren't aware of the
> resources available to them.
Sounds like the creation of the moderated group did something useful,
then. I'm glad, and not overly surprised. Lots of yelling about meta
issues generally indicates some strain and disagreement over fundamental
structure, and creating someplace new with a different structure often
makes it go away. This tends to be true whether or not those complaining
actually *use* the new structure, strangely enough, but to me the results
are what count.
And now we have a .moderated group that, even if there is no other
distinguishing factor, at least has a considerably lower traffic load,
which is precisely what some people want.
So it seems to me that everyone wins. I like it when that happens. :)
--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
------------------------------
Date: Wed, 23 Dec 1998 10:54:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: sizeof() function?
Message-Id: <3688c7f6.8994133@news.skynet.be>
Andrew M. Langmead wrote:
>There is a
>length() function, which is like C's strlen()
Not really. Perl strings may contain null bytes.
Bart.
------------------------------
Date: Wed, 23 Dec 1998 09:00:39 GMT
From: dave@mag-sol.com
Subject: Re: Store HASHES into an Array???
Message-Id: <75qbfn$1h2$1@nnrp1.dejanews.com>
In article <3680db1c.2319305@news.inka.de>,
papick.taboada@gmx.net wrote:
> Hi!
>
> I would like to have the following:
>
> %myHash = ( 1 => 'asf' , 2 => 'asr' , 3 => '325g' );
>
> myarray = [
> "myname",
> "mypassword",
> %myhash,
> $someotherstuff
> ],
>
> push( mysuperaray , [myarray] );
>
> years later....
>
> @myarray = @{ $mysuperaray[ 543 ] };
>
> $myname = $myarray[0]; # that works fine
> $mypassword = $myarray[1]; # that works fine
>
> $myhash = %$myarray[1]; # that does not work!
You need to:
1/ Post this in the appropriate newsgroup (comp.lang.perl.misc - crossposted
and followups set).
2/ Reread perldoc perlref, perldoc perllol and perldoc perldsc.
3/ Store a refernce to your hash in the array.
4/ Access the hash in the array using dereferencing syntax.
hth,
Dave...
--
Dave Cross
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 23 Dec 1998 09:43:53 +0100
From: "Kai" <kait@vacheron.ch>
Subject: Re: Turning Variables into CAPS?
Message-Id: <75qai8$ui$1@sibyl.sunrise.ch>
>
> Why do you want to transliterate '[' to '[' and ']' to ']'? :-)
>
Those caracters are not transliterated, they serve as delimiters for the
ranges a-z and A-Z.
>
> '\U' and 'uc()' respect the current locale, if any. The following is
> quoted from `perldoc perllocale`:
>
Thanks for that good news, but <sigh> it does not work on my NT4 with the
swiss locale. I'll try at home on my linux machine where I usually do perl.
See you, Kai.
------------------------------
Date: Wed, 23 Dec 1998 12:33:27 -0000
From: "Paul Makepeace" <Paul.Makepeace@POBox.com>
Subject: Re: Turning Variables into CAPS?
Message-Id: <75qo48$22g$2@statler.server.colt.net>
Tk Soh wrote in message <3680277E.99F2D8FE@email.sps.mot.com>...
>[posted to clpm and copy emailed]
>
>Ken Hirsch wrote:
>>
>> Well, you could:
>>
>> s/\b(\w)/uc $1/eg;
>>
>> But The Question Is "Do You Want To Do This"?
>
>$_ = "i don't know";
>s/\b(\w)/uc $1/eg;
>print;
>
>gives:
>I Don'T Know
use locale; # if you want
$_ = "i don't know" ; s/\b(?<!')(\w)/\u$1/g; print
I Don't Know
Paul.
--
Paul Makepeace, Independent Thinkers Ltd (UK)
0171 377 8668 / 0973 800436
"People are all monkeys, and I am Captain Banana"
-- Vincent Gallo
------------------------------
Date: Wed, 23 Dec 1998 07:38:01 GMT
From: razs@amdocs.com
Subject: Re: What's wrong with this code?
Message-Id: <36809d56.430243817@soint1>
On Tue, 22 Dec 1998 20:57:59 -0000, "WL" <will@localads.net> wrote:
try "\r\n\r\n" instead of "\n\n".
>Hi,
>
>The following code worked fine, when I ran it under Telnet using "perl
>stf.cgi":
>_______________________________________________
>require 'configs.cfg'; # System configuration file
>
> require 'subs.pl'; # System required sub-routines
>
> $SendEmail = "yes";
> $EmailAddress = "will\@localads.net";
> $Locie = "Localads.net";
>
> if ($SendEmail eq "yes") {
> # Open The Mail program, send notice of new AD submittal to Webmaster
> open(MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
> print MAIL "To: $EmailAddress\n";
> print MAIL "From: $Locie\n";
> print MAIL "Subject: Test Message\n\n";
>
> }
> close (MAIL);
>_______________________________________________
>Then, I added this bit of code afer the print MAIL Subject line:
>
>print MAIL "$in{'City'}";
>
>This takes the text City variable from the web page - but it didn't, or
>rather it returned a server error :(( I use the post statement, - could
>this have been the problem?
>
>I'd be very grateful for any help, to will@localads.net
>
>Many thanks indeed,
>
>Will
>
------------------------------
Date: Wed, 23 Dec 1998 07:53:50 -0500
From: Jeff Crosby <jlcrosby@fwi.com>
Subject: Re: Win Port - AWK to Perl conversion
Message-Id: <3680E7DE.4301799@fwi.com>
"Allan M. Due" wrote:
> Well, you might try:
> Start =>Find=>Files or Folders=>a2p*.*
>
> This finds my copy of ActiveStates a2p.exe in the bin subdirectory of my perl
> installation. perl.exe is there too. I suppose I just write a small Perl
> script to find it but Windoze has to be good for something.
>
> AmD
Did that before posting. There is no a2p anything. There must be
something wrong with my install.
The file I downloaded and installed is PW32I316.EXE.
--
-Jeff
jlcrosby@fwi.com
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4485
**************************************