[6684] in Perl-Users-Digest
Perl-Users Digest, Issue: 309 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 15 20:17:14 1997
Date: Tue, 15 Apr 97 17:00:21 -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 Tue, 15 Apr 1997 Volume: 8 Number: 309
Today's topics:
Re: "Dummies" book any good? <74331.3261@CompuServe.COM>
Re: [Q] How to capitilize beginning of words (Tad McClellan)
Re: A simple substitution (Tad McClellan)
Re: Can we create an executable of perl program <jong@mrc-lmb.cam.ac.uk>
FormMail sort problem w/realname,email <"Please Respond "@ This NG.>
Re: Get a week number from a file (Steffen Beyer)
how to use a system-installed Perl w/locally downloaded (Terrence M. Brannon)
Re: Kudos to Tom Christiansen and problems with OO (Tad McClellan)
Re: No GUI environment for Perl? <tchrist@mox.perl.com>
Re: on the absence of constant objects (Steffen Beyer)
Re: Passing How Do I Send Parseable values via the Comm (Tad McClellan)
Perl 4, Patch Level 10 <John.Adams@BentonvilleAR.ncr.com>
Perl parsing <jayne@msp.sc.ti.com>
Re: Perl parsing (A. Deckers)
Re: Perl parsing (A. Deckers)
Perl regular expressions - HTML TempStephenByrne@extonpo.bentley.com
Q: Uniq'ing a list (Andreas Steffan)
Re: question: How does one substitute into something ot (Tad McClellan)
sh trap vs. perl $SIG <ugolinia@mr.med.ge.com>
Re: Sorting files (Tad McClellan)
Re: Unix and ease of use (WAS: Who makes more ...) (Thomas)
Re: Why doesn't until(<FILE> =~ /^\D/) { work? (Tad McClellan)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Apr 1997 20:12:06 GMT
From: Terry Michaels <74331.3261@CompuServe.COM>
Subject: Re: "Dummies" book any good?
Message-Id: <5iu32m$jrv$1@mhafc.production.compuserve.com>
I found the first edition of Programming Perl too difficult
for a beginner in Perl. The David Till first edition of
Teach Yourself Perl in 21 Days was very good I thought, and its
explanation of the debugger was excellent. I think a beginner
should begin using the debugger as soon as possible.
------------------------------
Date: Tue, 15 Apr 1997 15:47:33 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: [Q] How to capitilize beginning of words
Message-Id: <5hp0j5.5ou.ln@localhost>
amas@lhr-sys.dhl.com wrote:
: I have looked in O'Reilly's Learning Perl book, but can't seem to
^^^^^^^^^^^^^^^^^^
That's good. But you can't wordsearch on a printed text.
There is a FREE series of Perl FAQs available. Get them.
grep -i 'capitalize' faq.* finds:
faq.4:=head2 How do I capitalize all the words on one line?
[ complete answer give in the FAQ ]
Of course, for this method to work, you need to be able to
spell capitalize ;-)
: find a solution to this problem. I have a string of words that are
: all in caps and I would like to convert it to lower case and then
: capitilize the beginning of each word. I know how to do the first
^^^^^^^^^^
: part:
: $myString =~ tr/A-Z/a-z/;
: Though I am not too sure how to do the second part. Also since
: it is for a web server, a solution that does not take too long to
^^^^^^^^^^^^^^^^^^^^^^
;-)
: execute would be appreciated, though I am ready to accept anything.
: Thanks
Uh huh.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 15 Apr 1997 06:42:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: A simple substitution
Message-Id: <eipvi5.7s.ln@localhost>
Jeff Yoak (jeff@yoak.com) wrote:
: What is a good way to change the first letter of each word in a string
^^^^^^^^^^^^
Didn't find this in the perl man pages? (me either ;-)
Search them for 'first character' instead, and all will be revealed...
: to uppercase? I found my self sufficiently confused with s/// and
: tr/// that I ended up with:
: @lower = (a..z);
: foreach $letter (@lower) {
: $upper = $letter;
: $upper =~ tr/a-z/A-Z/;
: $line =~ s/\b$letter/$upper/g;
: }
: Somehow, this just seems morally wrong. There must be a better way.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 15 Apr 1997 23:20:33 +0100
From: Jong <jong@mrc-lmb.cam.ac.uk>
To: pan.dhanwada@teldta.com
Subject: Re: Can we create an executable of perl program
Message-Id: <3353FF31.41C6@mrc-lmb.cam.ac.uk>
pan.dhanwada@teldta.com wrote:
>
> I am calling a perl program using a system command of c
>
> for example
>
> main()
> {
> system('x.pl');
> }
>
> Here the problem is as the perl program is called thousands of times the
> system is getting slowed down. The main reason for the slow down is as
> perl program is an interpreter not an executable.
>
> Is there any facility of creating an executable of a perl program.
>
> If anybody knows more about this please email me
>
> pan.dhanwada@teldta.com
>
> pandu
There is a module made by Malcolm Beatie which produces
compiled perl programs.
Jong
--
I support Perl, Linux ...
With OVER SIX MILLION USERS, up from only ten or so a very few years
ago, Linux has taken it's place as the world's #3 computer operating
system overall. And Linux is breathing down the neck of #2 for very good
reasons. If growth rate to date continues, Linux will be the #1 computer
operating system by late '98 or '99. Are YOU ready?
) Linux Newsletter
http://www.smli.com/people/john.ousterhout/scripting.html
------------------------------
Date: Tue, 15 Apr 1997 18:41:17 -0400
From: Peter Myers <"Please Respond "@ This NG.>
Subject: FormMail sort problem w/realname,email
Message-Id: <5j1069$4i9@mtinsc05.worldnet.att.net>
I am using FormMail V-1.5 written in Perl, on a UNIX host
server which implements the sendmail program. Can you help
me solve the following problem?
How do you sort the "realname" and "email" fields?
I added the "print_config" line to have these printed
in the body of the message, and I added these variables
to the "sort" order. No matter what I try, they still
show up at the top of the email message.
Is there a way to edit the form or script so these will
sort along with other sorted fields?
Thank you for your time, I'd appreciate any help!
Please respond to this newsgroup.
Peter M.
------------------------------
Date: 15 Apr 1997 21:27:40 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: Get a week number from a file
Message-Id: <5j0rsc$rfg$2@en1.engelschall.com>
Petr Prikryl <prikryl@dcse.fee.vutbr.cz> wrote:
> Nathan V. Patwardhan (nvp@shore.net) wrote:
> >John Jiang (jiangj@bnr.ca) wrote:
> >: How can I get a week number of the time when a file is
> >: created. The week number would be something like what we got from
> >: shell "date -u +%W". Thanks.
> >You can't get the creation date of a file, but you can get last-modified,
> >date, etc., which are explained in perlfunc.pod in the section dealing
> >with stat().
> ...and then you can convert using localtime(). You will obtain also the
> day in the week as 0..6 number and the day in the year. You have to calculate
> week number yourself (probably some package does this).
The module "Date::DateCalc" does it, for instance.
Can be downloaded from CPAN or http://www.engelschall.com/u/sb/download/
Hope this helps.
Yours,
--
|s |d &|m | Steffen Beyer <sb@sdm.de> (+49 89) 63812-244 fax -150
| | | | software design & management GmbH & Co. KG
| | | | Thomas-Dehler-Str. 27, 81737 Munich, Germany.
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
------------------------------
Date: 15 Apr 1997 15:43:25 -0700
From: brannon@bufo.usc.edu (Terrence M. Brannon)
Subject: how to use a system-installed Perl w/locally downloaded modules
Message-Id: <ysizbu7fvrec.fsf@bufo.usc.edu>
I am not superuser, yet I wish to use the system-installed Perl with
modules I get from CPAN and store in my lcal directory? Is there some
way to set this up?
This would be a good FAQ.
--
o============o Sending unsolicited commercial e-mail (UCE) to this address
Legal Notice is indication of your consent to pay me $120/hour for 1 hour
o============o minimum for professional proofreading & technical assessment.
terrence brannon * brannon@kappa.usc.edu * http://rana.usc.edu:8376/~brannon
------------------------------
Date: Tue, 15 Apr 1997 15:33:28 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Kudos to Tom Christiansen and problems with OO
Message-Id: <omo0j5.mlu.ln@localhost>
Terrence M. Brannon (brannon@bufo.usc.edu) wrote:
: nelson <nmljn@wombat.netsinc.com> writes:
: > BTW, are we talking jazz {piano,violin}, classical, country...?
: >
: > Any other jazz pianist Perl types out there besides myself?
: >
: The only Perl types are scalar, array, and hash. :-)
^^^^^^
My daughter is a scalar type of pianist.
She only knows the scales so far...
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 15 Apr 1997 13:45:30 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: No GUI environment for Perl?
Message-Id: <5j00pq$r3p$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
david <david@jemez.kellogg.nwu.edu> writes:
:For example: my machine at work (pentium 166, 32meg ram, WindowsNT
:Workstation v4) also has many apps open at once and is generally pretty
:responsive switching between them. But if I start Excel off on a huge
:re-calculation, minimize Excel, and then switch to something else, my
:machine is unusably slow. Same thing with a large perl script or database
:rebuild or whatever. When the same machine is running Linux (or any other
:x86 Unix, I would imagine), I can be compiling a kernel and running a
:large perl script and not notice any performance hit in my foreground
:jobs. _That_ is multi-tasking.
The conspiracy-minded have pointed this process-pessimization in NT as
intentional, forcing you to buy more wintel boxen to make up for it.
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
: I've tried (in vi) "g/[a-z]\n[a-z]/s//_/"...but that doesn't
: cut it. Any ideas? (I take it that it may be a two-pass sort of solution).
In the first pass, install perl. :-) Larry Wall <6849@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 15 Apr 1997 21:25:20 GMT
From: sb@en.muc.de (Steffen Beyer)
Subject: Re: on the absence of constant objects
Message-Id: <5j0ro0$rfg$1@en1.engelschall.com>
Stijn van Dongen <stijnvd@cwi.nl> wrote:
> Recently I wrote a perl library for sorting a Russian--Dutch
> dictionary. The dictionary has a couple of hundreds of thousands of lemma's,
> and as expected, different information has to be generated for various kinds
> of comparison (punctuation, field entry characteristics etc.). All in all it
> has become a program of slightly less than 3000 (generously spaced) lines of
> code, a large part of which is devoted to I/O, and a large part of which is
> caused by the fact that sorting has to be done in stages of two kinds (output
> is split up in segments, and sorting information is created in increasingly
> narrower domains).
> I took great care to do the sorting only on indices which represent the
> lemma's. One reason is efficiency, but the most important reason is safety.
> Now, it would have been a great relief had I been able to declare the array
> in which the lemma's are stored as a constant array. No matter how careful I
> construct the code, no matter my proficiency level as a programmer, it _would_
> have been nice. It may grieve perl's heart that its ability to shrink, grow
> and modify arrays is in this specific case is not so highly appreciated -- they
> were of course bravoed in other parts of the program.
> In the Ousterhout white paper thread, a copla things were said about
> scripting languages and system languages, including stuff about weak/strong
> typing, object oriented programming etc. What I found missing in perl,
> on this occasion, was the option of making an object _constant_.
> It is a diffent dimension than typing, and perhaps a dimension that is
> rather more important for larger applications. Any thoughts?
It's no problem to do that, in principle.
You just need to write a little XS module to "lock" and "unlock" Perl
objects so that they become write-protected.
Ah, let's see:
Let's name it "Object::Lock":
(So turn a plain Perl array into an object, create a reference of it and
"bless" that reference into some package, i.e,
$ref = \@plain_array;
bless($ref, "Any::Package");
or
$ref = \@plain_array;
bless($ref);
The latter blesses your object into your current package, probably "main".)
Pass that reference to the functions (!) of the following module:
"Lock.xs":
-------------------- cut here -------------------- cut here --------------------
/*
Copyright (c) 1997 by Steffen Beyer. All rights reserved.
This package is free software; you can redistribute it
and/or modify it under the same terms as Perl itself.
*/
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
typedef SV *Any_Perl_Ref;
typedef SV *Any_Perl_Obj;
#define IS_AN_OBJECT(ref,obj) \
( ref && \
SvROK(ref) && \
(obj = (Any_Perl_Obj)SvRV(ref)) && \
SvOBJECT(obj) && \
(SvTYPE(obj) == SVt_PVMG) )
MODULE = Object::Lock PACKAGE = Object::Lock
PROTOTYPES: DISABLE
void
Lock(reference)
Any_Perl_Ref reference
CODE:
{
Any_Perl_Obj object;
if ( IS_AN_OBJECT(reference,object) ) SvREADONLY_on(object);
else croak("Object::Lock::Lock(): not an object reference");
}
void
Unlock(reference)
Any_Perl_Ref reference
CODE:
{
Any_Perl_Obj object;
if ( IS_AN_OBJECT(reference,object) ) SvREADONLY_off(object);
else croak("Object::Lock::Unlock(): not an object reference");
}
-------------------- cut here -------------------- cut here --------------------
"typemap":
-------------------- cut here -------------------- cut here --------------------
################################################################
#
# Typemap for module "Object::Lock" version 1.0
#
# Copyright (c) 1997 by Steffen Beyer. All rights reserved.
# This package is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
#
# Last modified 15-Apr-1997
#
################################################################
TYPEMAP
Any_Perl_Ref T_SV
-------------------- cut here -------------------- cut here --------------------
"Lock.pm":
-------------------- cut here -------------------- cut here --------------------
# Copyright (c) 1997 by Steffen Beyer. All rights reserved.
# This package is free software; you can redistribute it
# and/or modify it under the same terms as Perl itself.
package Object::Lock;
use strict;
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION);
require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw();
@EXPORT_OK = qw(Lock Unlock);
$VERSION = '1.0';
bootstrap Object::Lock $VERSION;
1;
__END__
=head1 NAME
Object::Lock - write-protect Perl objects
Allows you to have constant objects in Perl
=head1 SYNOPSIS
=over 4
=item *
"C<Lock($object);>"
locks (write-protects) any Perl object
=item *
"C<Unlock($object);>"
unlocks (write-enables) any Perl object
=back
=head1 DESCRIPTION
"C<Lock($object)>" locks (write-protects) any Perl object,
"C<Unlock($object)>" unlocks (write-enables) any Perl object.
=head1 SEE ALSO
perl(1), perlsub(1), perlmod(1), perlref(1), perlobj(1),
perlbot(1), perltoot(1), perlxs(1), perlxstut(1), perlguts(1).
=head1 VERSION
This man page documents "Object::Lock" version 1.0.
=head1 AUTHOR
Steffen Beyer <sb@sdm.de>.
=head1 COPYRIGHT
Copyright (c) 1995, 1996, 1997 by Steffen Beyer. All rights reserved.
=head1 LICENSE
This package is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
-------------------- cut here -------------------- cut here --------------------
"Makefile.PL":
-------------------- cut here -------------------- cut here --------------------
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
'NAME' => 'Object::Lock',
'VERSION_FROM' => 'Lock.pm',
'LIBS' => [''], # e.g., '-lm'
'DEFINE' => '', # e.g., '-DHAVE_SOMETHING'
'INC' => '', # e.g., '-I/opt/pkg/perl5.003/dist'
'dist' => { COMPRESS=>"gzip -9", SUFFIX=>"gz" }
);
-------------------- cut here -------------------- cut here --------------------
Put all the files in a directory, say "perl Makefile.PL", "make" and
"make install" and then use "use Object::Lock qw(Lock Unlock);"
in your application!
Hope this helps!
Yours,
--
|s |d &|m | Steffen Beyer <sb@sdm.de> (+49 89) 63812-244 fax -150
| | | | software design & management GmbH & Co. KG
| | | | Thomas-Dehler-Str. 27, 81737 Munich, Germany.
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
------------------------------
Date: Tue, 15 Apr 1997 15:41:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Passing How Do I Send Parseable values via the Command Line
Message-Id: <85p0j5.6nu.ln@localhost>
John Call (johnc@interactive.ibm.com) wrote:
: >What does this have to do with Perl? Perl != CGI. Are you >aware that
: >there are newsgroups for CGI and HTML issues? I can't >>>
: >swear that your
: >question isn't Perl-related, but it sure smells like a CGI >question,
: >which quite frankly, are seldom well-received in these >>
: >parts.
: >--tom
: >--
: > Tom Christiansen tchrist@jhereg.perl.com
: > #define NULL 0 /* silly thing is, we don't >>
: >even use this */
: > --Larry Wall in perl.c from the v4.0 perl source >
: >code
: What's so funny to me is that by the time it took to write your message
: and waste bandwith you could have answered his question which in my
^^^^^^^^^^^^^^
: opinion is enough related to Perl to be relevant.
First Tom "wasted bandwidth" complaining about an off-topic posting.
(which was, itself, yet another potential waste of bandwidth)
Then *you* wasted bandwidth complaining about the complaining.
Now *I* am wasting bandwidth complaining about your complaining
about the complaining.
All because the first posting was OFF TOPIC for this newsgroup...
Do you think that off-topic postings are a Good Thing?
How so?
What's so funny is that they have all these different newsgroups
based on subject matter.
Why don't they just put all 200,000 daily Usenet posts into just
one newsgroup so the clueless folks will know where to look for them?
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 15 Apr 1997 21:14:31 GMT
From: John Adams <John.Adams@BentonvilleAR.ncr.com>
Subject: Perl 4, Patch Level 10
Message-Id: <3353EFB7.6155@BentonvilleAR.ncr.com>
I have to use it for a script on one particular server. Why? Just
because...because it's what's installed there. Is there any sort
of problem that a not-particularly deep script might encounter?
Thanks!
John Adams
John.Adams@BentonvilleAR.ncr.com
------------------------------
Date: Tue, 15 Apr 1997 17:33:41 -0500
From: Jayne Meiners <jayne@msp.sc.ti.com>
Subject: Perl parsing
Message-Id: <33540245.5632@msp.sc.ti.com>
If I am looking for one character out of a string.
It doesn't matter if it is in the beginning, middle,
or end.
All I want to know is if it exists, what is the parsing
sequence I need.
This is the form I would like to have it:
if (<that_x_character_exists>) {
print "<that_x_character_exists>";
}
Jayne Meiners
Jayne@ti.com
------------------------------
Date: 15 Apr 1997 23:29:44 GMT
From: mbzalgd@man.ac.uk (A. Deckers)
Subject: Re: Perl parsing
Message-Id: <slrn5l83r8.26i.mbzalgd@nessie.mcc.ac.uk>
In <33540245.5632@msp.sc.ti.com>,
Jayne Meiners <jayne@msp.sc.ti.com> wrote:
>If I am looking for one character out of a string.
>It doesn't matter if it is in the beginning, middle,
>or end.
>All I want to know is if it exists, what is the parsing
>sequence I need.
>
>This is the form I would like to have it:
>
>if (<that_x_character_exists>) {
>
> print "<that_x_character_exists>";
>
>
>}
I'm not sure I understand what you mean, but...
#!/usr/bin/perl -w
$char = 'c';
$word1 = 'abcdefgh';
$word2 = 'ijklmnop';
if ($word1 =~ /$char/) { print "yes\n"; }
if ($word2 =~ /$char/) { print "yes again\n"; }
__END__
Is that what you were looking for?
HTH,
--
Alain.Deckers@man.ac.uk <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl software: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: 15 Apr 1997 23:42:23 GMT
From: mbzalgd@man.ac.uk (A. Deckers)
Subject: Re: Perl parsing
Message-Id: <slrn5l84iv.26i.mbzalgd@nessie.mcc.ac.uk>
In <33540245.5632@msp.sc.ti.com>,
Jayne Meiners <jayne@msp.sc.ti.com> wrote:
>If I am looking for one character out of a string.
>It doesn't matter if it is in the beginning, middle,
>or end.
>All I want to know is if it exists, what is the parsing
>sequence I need.
>
>This is the form I would like to have it:
>
>if (<that_x_character_exists>) {
>
> print "<that_x_character_exists>";
>
>
>}
I'm not sure I understand what you mean, but...
#!/usr/bin/perl -w
$char = 'c';
$word1 = 'abcdefgh';
$word2 = 'ijklmnop';
if ($word1 =~ /$char/) { print "yes\n"; }
if ($word2 =~ /$char/) { print "yes again\n"; }
__END__
Is that what you were looking for?
HTH,
--
Alain.Deckers@man.ac.uk <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl software: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: Tue, 15 Apr 1997 17:01:37 -0600
From: TempStephenByrne@extonpo.bentley.com
Subject: Perl regular expressions - HTML
Message-Id: <861140815.15319@dejanews.com>
I am fairly new to Perl so forgive the simplicity of my question/example.
I am trying to format some HTML documents that we have so that they will
be consistent. Within the documents I am trying to fix the following.
We have 3 cases:
<dt><A HREF="/forum/index.html"><img src="/products/gif/greenb.gif"
alt="*" border=0>The FORUM</A>
<dt><A HREF="/forum/"><img src="/products/gif/greenb.gif" alt="*"
border=0>The FORUM</A>
<dt><A HREF="/forum">
Case #1 is OK.
Case #2 needs a "index.html" appended onto "/forum"
Case #3 needs a "/" and a "index.html"
Here's the Perl that I have currently: (this is about my 45th attempt ...
I have tried everything)
## This one is supposed to append the "/"
## It assumes that all hrefs have been capitalized
##### problem is it puts "/" on the end of each href
if (($_ =~ "HREF=\"") &&
($_ !~ "HREF=\"\/.+\/\">") &&
($_ !~ "http:") &&
($_ !~ "HREF=\"\/[\w\.\/]+\.\w{3,4}\">"))
{
s/HREF=\"\/(.+)\">/HREF=\"\/\1\/\">/;
}
## Then, I run this part which should append index.html where needed
if (($_ =~ "HREF=\"") &&
($_ !~ "HREF=.*\#.*\">") &&
($_ !~ "HREF=\"\/.+\.\w{3,4}\">"))
{
s/(HREF=\".+\/*.*)\"\>/\1index.html\"\>/;
}
I have also tried several mutations of this code, all of which come close
but no cigar.
Has anybody done this successfully? Or could somebody please provide
some assistance for what I have provided above?
Thanks in advance!!!
-Steve
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 16 Apr 1997 00:24:25 +0200
From: deas@rrz.uni-hamburg.de (Andreas Steffan)
Subject: Q: Uniq'ing a list
Message-Id: <5j0v6p$3qj@mortimer.deas.org>
Hi,
Would someone please be so kind and tell me how to uniq a list
in perl without using the UNIX 'uniq' command ?
--
TNX, Andreas
PS: Please also reply via email.
+-----------------------------------------------------------------+
| Andreas Steffan email: deas@rrz.uni-hamburg.de|
| Hamburg, Germany |
+-----------------------------------------------------------------+
finger p25a003@server2.rrz.uni-hamburg.de for PGP-public-key.
------------------------------
Date: Tue, 15 Apr 1997 15:55:59 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: question: How does one substitute into something other $_?
Message-Id: <v0q0j5.opu.ln@localhost>
Terrence M. Brannon (brannon@bufo.usc.edu) wrote:
: Every example I have seen in \\(learning\\|programming\\) perl uses $_
: for the substiution examples. Hence I have no idea how to do
^^^^^^^^^^^
: substitution in other variables.
Uh. If you are having some problem with s///, why not look up s///
in the free documentation that is *included with the perl distribution*?
from perlop man page:
-----------------------------------
=item s/PATTERN/REPLACEMENT/egimosx
Searches a string for a pattern, and if found, replaces that pattern
with the replacement text and returns the number of substitutions
made. Otherwise it returns false (0).
If no string is specified via the C<=~> or C<!~> operator, the C<$_>
variable is searched and modified. (The string specified with C<=~> must
be a scalar variable, an array element, a hash element, or an assignment
to one of those, i.e. an lvalue.)
-----------------------------------
See that part there where they are talking about that =~ thingy?
$othervar =~ s/matchme/replacement/;
# ^^
We're not here to read the man pages for you.
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Tue, 15 Apr 1997 16:49:23 -0500
From: "Alex P. Ugolini, Jr." <ugolinia@mr.med.ge.com>
Subject: sh trap vs. perl $SIG
Message-Id: <3353F7E3.41C6@mr.med.ge.com>
Background: perl newbie on perl 4.
I usually start my sh scripts with:
#!/bin/sh
progname=`basename $0`
tmpfn=/tmp/$progname.$$
exitcode=1
trap '
rm -rf $tmpfn.*
trap 0
exit $exitcode
' 0 1 2 3 15
This gets me tmp files that:
1. are always in a writable directory (/tmp),
2. always have a unique filename (because they include $$),
3. do not clutter up the file system (because they are in /tmp), and
4. are always removed with the script terminates for any reason
(except kill -9).
In particular, the tmp files are removed if the script is hit by
a signal (except signal 9 which cannot be trapped) or if the script
simply hits an exit statement, or just hits end-of-file on the
script.
(I came up with the "0 1 2 3 15" list many years ago and I believe
that a simple zero works just as well for my purposes here.)
My question is- can anyone tell me if this functionality can be
easily reproduced in perl 4?
I suspect that it cannot be because perl 4 does not support a special
END subroutine (as does perl 5), so there is no way to catch all
exits.
Also- since this trap removes tmpfiles on practically *any* signal
(e.g., kill -7 ... will trip the trap), I would have to explicitly set
all possible $SIG values to call my subroutine, and to do that I would
need to dynamically generate a list of all useful $SIG indicies.
So- any suggestions?
Thank you-
--
Alex Ugolini
ugolinia@mr.med.ge.com
------------------------------
Date: Tue, 15 Apr 1997 16:04:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Sorting files
Message-Id: <2gq0j5.opu.ln@localhost>
Paulo Bellem (coop5b30@nortel.ca) wrote:
: Hello
: I am having a problem with sorting files.
: I have a bunch of data files i.e.
: 10.2.97
: 11.3.97
: 2.6.97
: etc. in a directory
: Now I have a script which checks these files for certain phrases and
: then do the following in order to get only the information that I need.
: $cmd = "find $fn*.dat -print |xargs grep '$fstring' 2>&1 |";
: After I use open(DATA,$cmd)
: and start to read in line by line from DATA. How can I sort this
: inorder to
: get the info from 2.6.97 before 10.2.97 and 11.2.97.
: If anyone can help me I would appreciate it.
A really slow way (UNTESTED):
sub by_date {
my($monA, $dayA, $yearA) = split /\./, $a;
my($monB, $dayB, $yearB) = split /\./, $b;
$yearA <=> $yearB || $monA <=> $monB || $dayA <=> $dayB;
}
@sorted = sort by_date @unsorted;
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: 15 Apr 1997 15:31:05 -0700
From: nouser@nohost.nodomain (Thomas)
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <tz8u3l7syty.fsf@aimnet.com>
In article <01bc491a$6a263f00$87ee6fce@timpent.a-sis.com> "Tim Behrendsen" <tim@a-sis.com> writes:
And it's also extremely fragile. One corrupted byte and the
rest of the file is trash. With a reasonable tool like pkzip,
you can often access files even if part of it is corrupt, and
sometimes even rebuild the directory structure.
[...]
Don't get me wrong; I use the tar-gzip combination quite often,
but it's inferior as a tool compared to archive tools, particularly
in combination with something like WinZip.
Take a look at "afio". It compresses files individually, but uses
the standard cpio and gzip formats.
Or how about self-extracting archives?
You can distribute executables as self-extracting archives because
they are already platform specific (but you would do better to just
make them run as a single file), but for most other archival uses,
they are a bad idea because they are platform and OS version specific.
Thomas.
------------------------------
Date: Tue, 15 Apr 1997 16:00:21 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Why doesn't until(<FILE> =~ /^\D/) { work?
Message-Id: <59q0j5.opu.ln@localhost>
H. Todd Chapman (htchapma@vela.acs.oakland.edu) wrote:
: I wanted to use the following:
: until(<FILE> =~ /^\D/) {
: ($node, $x, $y, $z) = split;
: if (exists $nodes_hash{$node}) {
: $nodes_hash{$node} = join ' ', $x, $y, $z;
: }
: }
: but htat didn't work, so I tried:
: until(<FILE> =~ /^\D/) {
: ($node, $x, $y, $z) = split;
: if (exists $nodes_hash{$node}) {
: $nodes_hash{$node} = join ' ', $x, $y, $z;
: }
: }
: which also failed so I tried:
: while(<FILE>) {
: if (/^\D/) {last;}
: ($node, $x, $y, $z) = split;
: if (exists $nodes_hash{$node}) {
: $nodes_hash{$node} = join ' ', $x, $y, $z;
: }
: }
: Which works, as I expected. Why do the other two methods not woek?
Because you threw away the input line ;-)
You have come to rely too much on the magic in perl.
Your first two forms don't save the input line anywhere.
The last form does. But it ONLY does it if the <...> is the ONLY
thing in the conditional.
Try something like the below instead:
until( ($_ = <FILE>) =~ /^\D/) {
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
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 309
*************************************