[16746] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4158 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 28 21:10:35 2000

Date: Mon, 28 Aug 2000 18:10:22 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <967511422-v9-i4158@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 28 Aug 2000     Volume: 9 Number: 4158

Today's topics:
    Re: quickie obfuscation... (Craig Berry)
    Re: quickie obfuscation... <elephant@squirrelgroup.com>
    Re: quickie obfuscation... <elephant@squirrelgroup.com>
        Regex matching in a array of hashrefs <smerr612@mailandnews.com>
    Re: regular expressions and urls. <elijah@workspot.net>
        Reply- basic question <kevin@kevinackerman.com>
        rpm vs. compile on RH6.2? (Bakki Kudva)
    Re: Script to Copy Files <elephant@squirrelgroup.com>
    Re: Sorry, MSIE5 <elephant@squirrelgroup.com>
        The Hacker signature disciplin (Jakob Schmidt)
    Re: The Hacker signature disciplin <elijah@workspot.net>
    Re: The Hacker signature disciplin <lauren_smith13@hotmail.com>
    Re: The Hacker signature disciplin (Jakob Schmidt)
    Re: The Hacker signature disciplin (Randal L. Schwartz)
    Re: The Hacker signature disciplin <elephant@squirrelgroup.com>
    Re: turn characters into meta characters <lr@hpl.hp.com>
    Re: Unclosed HTML Tags <elephant@squirrelgroup.com>
    Re: would you recommend buying a book (David H. Adler)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 28 Aug 2000 22:43:05 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: quickie obfuscation...
Message-Id: <sqlqnpokt91109@corp.supernews.com>

Godzilla! (callgirl@la.znet.com) wrote:
: * applauds *
: 
: This is one of the best written articles I have
: read in a long time. Very clear, well organized,
: well planned, exceptionally easy to read and
: equally easy to understand.

Thanks for the kind words.  Been operating in teacher mode at work a lot
recently. :)

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Every force evolves a form."
   |              - Shriekback


------------------------------

Date: Tue, 29 Aug 2000 00:17:26 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: quickie obfuscation...
Message-Id: <MPG.14159e8b164a86f5989717@localhost>

Abigail <abigail@foad.org> wrote ..
>Marcel Grunauer (marcel@codewerk.com) wrote on MMDLIV September MCMXCIII
>in <URL:news:slrn8qlg28.efv.marcel@gandalf.local>:
>\\ On Mon, 28 Aug 2000 15:25:01 -0400, Aaron Spangler <aspangler@lucent.com> wr
>\\ 
>\\ >Why does
>\\ >           print 1 and 0;
>\\ >return 1?
>\\ >
>\\ >What is perl actually performing here?
>\\ 
>\\     $ perl -MO=Deparse,-p -e 'print 1 and 0'
>\\     (print(1) and '???');
>\\     -e syntax OK
>\\ 
>\\ This is what perl sees. Does that help? Note the placement of the
>\\ parentheses for print().
>
>
>Well, that is certainly confusing. 
>
>As far as I can tell, the result of "print 1 and 0" is false, but the
>result of "(print (1) and '???')" is true.
>
>Unless '???' suddenly became 0.

umm .. not sure if this explains it .. but the assignment operator binds 
tighter than 'and' .. so

  my $foo = print 1 and 0;

parses to

  ( my $foo = print 1 ) and 0;

so .. that parsing makes sense in an assignment situation .. and for 
some reason Perl does the same thing when evaluating the statement's 
value in a non-assignment situation

which explains the ( print(1) and '???' )

and also the difference in your sub test {} example elsewhere in the 
thread .. because there's no assignment assumed at the end of a sub .. 
only a return wrapper .. and

  return 1 and 0;

will evaluate the 'and' before passing the result to 'return'

  [ line longer than 80 chars truncated ]

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Tue, 29 Aug 2000 00:22:06 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: quickie obfuscation...
Message-Id: <MPG.14159fa0960d2486989718@localhost>

Craig Berry <cberry@cinenet.net> wrote ..
>Aaron Spangler (aspangler@lucent.com) wrote:
>: Why does
>:            print 1 and 0;
>: return 1?
>
>First, let's talk about your use of the word 'return'.  print() is a
>function, which has a return value.  It returns TRUE if successful,
>according to the doc, which could be almost any value but in practice
>turns out to be 1.  So, barring I/O disaster, print *always* returns 1, in
>the functional sense.
>
>You probably really mean "Why does 'print 1 and 0;' *print* 1?".  This can
>be answered by noting that the 'and' operator has very low precedence,
>which makes it bind quite loosely.  Specifically, it binds less tightly
>than function calls.  So Perl parses your example as:
>
>  (print 1) and 0;
>
>It dutifully prints 1, which coincidentally also returns the value 1, then
>ands this with 0, producing a false value, which is then tossed away
>unused.

the last paragraph is not true .. it would appear that the evaluation of 
the return value of the print statement is higher precedence than the 
'and' and so the value of

  print 1 and 0

is 1 .. and the 0 is thrown away .. deparses to either

  (print(1)) and '???'

or

  '???' if print 1

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Mon, 28 Aug 2000 22:40:58 GMT
From: Steven Merritt <smerr612@mailandnews.com>
Subject: Regex matching in a array of hashrefs
Message-Id: <8oeppn$bm9$1@nnrp1.deja.com>

I've got an array of hashrefs.  Most of the searches I do on it work
fine, but when I run the AND match(I'll specify what it is below) it
returns several records matching all the parameters specified, and then
all the rest of the records are matched as well regardless of the
parameters.  Even wierder, it works beautifully when I only select a
date range and one parameter, but when I give it more than one parameter
and tell it to search for records containing all the given parameters,
it gives me several correct matches and then a lot of incorrect matches.

Here is my parameter capturing scheme.

elsif ($Choice == 3){

    print "Please enter the date you wish to begin your search from,
YYYYMMDD format\n";
    $From_Date = <>;
    chomp $From_Date;

# Append a timestamp to the date to get a full listing of input time

    $From_Date .= ' 00:00:00';

    print "\nPlease enter the date you wish to end your search with,
YYYYMMDD format\n";
    $To_Date = <>;
    chomp $To_Date;

#  Same kind of deal, make sure it finds all the records for that day

    $To_Date .= ' 23:59:59';

    print "\nPlease enter the Status of records you wish to find,\n",
    "leave blank for no preference\n";
    $Search_Status = <>;
    chomp $Search_Status;

#  Here's where I think it's starting to go wrong.  I need to give it
#  a pattern I know will match everything in the case of them skipping
#  the entry field.  No determination of a valid/invalid match is to
#  be made if the parameter field is empty.

    $Search_Status ||= '.';

    print "\nPlease enter the Applid referenced on records you wish to
find,\n",
    "leave blank for no preference\n";
    $Search_Applid = <>;
    chomp $Search_Applid;
    $Search_Applid ||= '.';

    print "\nPlease enter the Environment referenced on records you wish
to find,\n",
    "leave blank for no preference\n";
    $Search_Environ = <>;
    chomp $Search_Environ;
    $Search_Environ ||= '.';

    print "\nPlease enter the SR referenced on records you wish to
find,\n",
    "leave blank for no preference\n";
    $Search_SR = <>;
    chomp $Search_SR;
    $Search_SR ||= '.';

    print "\nPlease enter the Operator referenced on records you wish to
find,\n",
    "leave blank for no preference\n";
    $Search_Oper = <>;
    chomp $Search_Oper;
    $Search_Oper ||= '.';

    print "\nPlease enter the Pegasys\/EER Ticket referenced on records
you wish to find,\n",
    "leave blank for no preference\n";
    $Search_Pegasys_EER = <>;
    chomp $Search_Pegasys_EER;
    $Search_Pegasys_EER ||= '.';

    print "\nPlease enter a keyword to search for in the record
descriptions you wish to find,\n",
    "leave blank for no preference\n";
    $Keyword = <>;
    chomp $Keyword;
    $Keyword ||= '.';

    $Any_All = 'ALL';
    }


And here is the relevant section of the matching algorithm.

#  They may have entered several search choices and want to find records
which match all of these things.

elsif ($Any_All eq 'ALL') {
   foreach $DataLine (@Recs){
      if (($From_Date le $DataLine->{Timestamp}) &&
          ($To_Date ge $DataLine->{Timestamp}) &&
          ($DataLine->{Status} =~ /$Search_Status/i) &&
          ($DataLine->{Applid} =~ /$Search_Applid/i) &&
          ($DataLine->{Environ} =~ /$Search_Environ/i) &&
          ($DataLine->{SR} =~ /$Search_SR/i) &&
          ($DataLine->{Oper} =~ /$Search_Oper/i) &&
          ($DataLine->{Pegasys_EER} =~ /$Search_Pegasys_EER/i) &&
          ($DataLine->{Desc} =~ /$Keyword/i)) {
          push @Matches, $DataLine;
          }
   }
}

This correctly matches quite a few records, but in the case when I want
to find operator name 'chris' and application 'oy' it matches this
record.

20000606 19:17:01  Chris
None
        SR field did not exist at time of this record's creation
	Application: w1
	Environment: T2
	Referencing Phone: 976-328-7448
	Referencing Party: Ed
	Pegasys/EER Ticket:
	app not responding.
	Bounced on vct5 and 6.
	working correctly now.


This is Chris, but this is not application oy.  In fact there is not an
'oy' pattern in the whole thing, so even if my parsing algorithm somehow
got out of sync and started matching the wrong values with the wrong
keys(which I have seen no evidence of in all my testing) it shouldn't
match this record.

I'm baffled.  Any suggestions?  As I said, it seems to match fine for a
single search ,it's just when I give it multiple parameters that it does
this.

Steven
--
King of Casual Play
The One and Only Defender of Cards That Blow

My newsreader limits sigs to four lines, but I cleverly bypassed this by


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 28 Aug 2000 22:14:08 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: regular expressions and urls.
Message-Id: <eli$0008281754@qz.little-neck.ny.us>

In comp.lang.perl.misc, Jeff Helman  <jhelman@wsb.com> wrote:
> johnvert@my-deja.com wrote:
> > 
> > Hi, I'm building a simple regexp that could identify URLs.  So far all I
> > could come up with is: m!^http://(.+?)[com net org gov mil]! which is
> > crappy because it depends on the amount of . url extensions I know of
> > (i.e. com, org, net), which is constantly changing. Is there a better
> > way?

Look at my posts in 'Stumped by Reg Exp Problem - help??' thread,
eg: <news:eli$0008251340@qz.little-neck.ny.us>, with the caveat
that I only attempted to match HTTP/HTTPS scheme URLs rather than
the whole of them, and that I assume a non-HTML context.

If you have an HTML-context, you are better off using an HTML
parser, eg HTML::Parser from your nearby CPAN mirror.

> Depending on formatting considerations, this should work.  Since URLs
> aren't supposed to contain whitespace (assuming that the formatting of a
> given page didn't break a long one), then this should work (assumes your
> entire file is in $FileText):
> 
> while ($FileText =~ m!(https?://\S+)!ig) {
> 	push (@URLS, $1);
> }

Consider that code applied to an html fragment:

In:	<a href="http://www.dmoz.org/">Dmoz is better than Yahoo!</a>
Out:	http://www.dmoz.org/">Dmoz

Is that a good match?

> One caveat I can think of (and I'm sure there are others) is that if you
> are extracting from paragraphs of normal information and the url is
> followed by a period indicating the end of a sentence, the above regex
> will match that.

Or a closing comma, or a closing quote, or a closing '>', or several
of those.

> > Also, I have a question about the (.+?) part.  I once asked how to match
> > the stuff between the " " of <a href="link">, and I was told to replace:
> > 
> >  \<a href=\".*\"\>
> > 
> > with:
> > 
> >  \<a href=\"(.+?)\">
> > 
> > But I can't figure out why.  

Both suck. 

The first matches:

        <a href="foo.html">FOO</a>   <a href="bar.cgi">BAR</a>
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The second screws up other HTML such as:

	<a href="qux/" class="classname">QUX</a>

by putting q!qux/" class="classname! into $1.

> Thus, your /<a href="(.+?)">/ regex is telling it that following the
> opening double-quote, match as few characters as possible before another
> double quote is found that is followed by a closing bracket.

Which is not what any reasonably person probably wants. They just want
the part in the doublequotes, see my QUX example. .+? and .*? are not
must be used only with great caution to avoid such problems.

> > perl -we '$s="mewbie%oerl%znother%iust";for(reverse
> > split(/%/,$s)){$s=(++substr($_,0,1)).substr($_,1)."
> > ";$s=~s/aa/a/;print$s}'

Heh.

Elijah
------
not at all bad for a self-described newbie


------------------------------

Date: Mon, 28 Aug 2000 23:05:34 GMT
From: "Kevin Ackerman" <kevin@kevinackerman.com>
Subject: Reply- basic question
Message-Id: <2fCq5.34017$dG.947478@typhoon.nyroc.rr.com>

I appreciate everyone's response to my basic question. Just for the sake of
closure, companies in the Albany NY area are looking for *PERL* programmers,
so I guess I'm already smarter then the companies looking for a programmer
in *PERL*. Sometimes it's just crazy that I stay in this area. I'm an
advanced Flash designer by trade, and, only one company was intelligent
enough to understand what I do ! I guess I should just try to get an
interview with one of these POS companies looking for a *PERL* programmer
just to *Enlighten* them about what *PERL* is and what *Perl* is. No wonder
I was so confused, I think it's the *Brainiacks* I have to work with in
upstate New York.

Does anyone know the difference between a person from Albany, New York and a
person from Manhattan, New York ?

Thanks again to everyone for clarifying this !! I certainly appreciate it !

Best Regards,
Kevin Ackerman
www.kevinackerman.com



"Kevin Ackerman" <kevin@kevinackerman.com> wrote in message
news:bZjq5.31324$dG.888419@typhoon.nyroc.rr.com...
> Hello,
>     I have one simple question, What is the difference between PERL and
CGI.
> My closest guess is that PERL is an interpreted language and CGI is the
> *thing* that makes PERL and a web browser work together. However, I am not
> satisfied that this is correct. Any help with the correct answer to my
> question would be greatly appreciated.
>
> Best Regards,
> Kevin Ackerman
>
>
>
>




------------------------------

Date: Mon, 28 Aug 2000 23:45:41 GMT
From: bakki@navaco.com (Bakki Kudva)
Subject: rpm vs. compile on RH6.2?
Message-Id: <8F9EC0C2Ebakkinavacocom@207.126.101.100>

I need some one to enlighten me on the intricacies of rpm vs. compile from 
source on RedHat Linux? I have several questions in this regard.

1. Since the perl-5.xx.rpm on RedHat Linux systems seem to install in non 
standard ways (/usr/lib vs. /usr/local) what is the effect of installing 
from .tar.gz sources?

2. Uninstalling the perl rpm breaks so many dependencies that it is scary 
to do so. On the othe hand if I install the traditional way will I end up 
with multiple, incompatible libraries?

3. RedHat seems to be always a bit lagging in  releasing the current stable 
version of perl as an rpm. I did find a 5.6.0 rpm at http://www.sjc.com/ 
but this wouldn't install because gnorpm complains that it is older than 
the installed version though the build dates in the rpm say otherwise.

4. I have experienced that if you try to build Apache, mod_perl etc with 
the rpm version of perl there are some times side effects which cause the 
make or make test to fail.

5. So the ultimate question then is, which is the preferred way of 
installing perl on RH? If the answer is to compile from .tar.gz, then what 
is the safe way to yank the rpm out and do a build?

I would really appreciate some help on this becuase I have not found 
anything on the subject at RH or other perl sites.

bakki

Bakk Kudva


------------------------------

Date: Mon, 28 Aug 2000 23:38:43 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Script to Copy Files
Message-Id: <MPG.141595749eb738a0989714@localhost>

anant_joshi@yahoo.com <anant_joshi@yahoo.com> wrote ..
>I need to copy several report files daily from different sources
>to my IIS server. Currently, operators initiate a job which copies
>the files and builds index pages.
>
>I want to automate the process and copy the report files.
>
>Has anyone developed a [perl] script for doing this?
>
>Are there any alternatives (other than developing BAT file) ?

Perl is not the best choice for this sort of scheduling .. WindowsNT has 
a clunky scheduling tool built in called AT .. or there are Win32 
versions of cron available for WindowsNT

you should ask in a forum that deals with WindowsNT or consult your 
Microsoft help file or customer support representative

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Mon, 28 Aug 2000 22:51:10 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Sorry, MSIE5
Message-Id: <MPG.14158a55defb1e17989712@localhost>

toni_cornelissen@my-deja.com <toni_cornelissen@my-deja.com> wrote ..
>I wrote,
>
>> When I use that script to include images in my web pages, the
>> images won't show if I use MS Internet Explorer 4. (I got the
>
>But I made a mistake in the version number. The images won't show
>in MSIE5.

if you post a new message - that has a new References header and so is 
not part of any existing thread - then I reall don't know how anyone is 
meant to know what the hell you're talking about

moreover - this sounds completely NOT like a Perl problem

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Tue, 29 Aug 2000 00:25:59 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: The Hacker signature disciplin
Message-Id: <1eg3nmp.17nqhqm1lkr7ggN@[192.168.88.117]>

Hi

I find myself wondering if there are some written or unwritten rules
about the "Just another Perl Hacker" sig that some posters use?

Of course I had to make a couple myself but I'm worried that I may be
breaking some rules (like for instance maybe you have to be a _real_
Perl Hacker) and making a fool of myself if I use them.

-- 
Jakob


------------------------------

Date: 28 Aug 2000 22:57:14 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: The Hacker signature disciplin
Message-Id: <eli$0008281836@qz.little-neck.ny.us>

In comp.lang.perl.misc, Jakob Schmidt <sumus@aut.dk> wrote:
> I find myself wondering if there are some written or unwritten rules
> about the "Just another Perl Hacker" sig that some posters use?

The general rules as I understand them are:

Works on more than just your version of perl (including other
platforms: Abigail's abuse of rand() violates that).

Works in a clever way: print unpack('u*',...) is not very clever.
This is suject to various peoples personal opinions.

I'm also a bit hesitant about the use of specifically undocumented
features, eg I find Abigail's use of %^H rather dubious.

> Of course I had to make a couple myself but I'm worried that I may be
> breaking some rules (like for instance maybe you have to be a _real_
> Perl Hacker) and making a fool of myself if I use them.

Well, if they work, that's a start, and not a foolish one at that.

Elijah
------
exec{$^X}('Just Another Perl HackerX',$0)unless($^X=~y=X=\cJ=);print$^X


------------------------------

Date: Mon, 28 Aug 2000 15:56:59 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: The Hacker signature disciplin
Message-Id: <8oeqjs$jed$1@brokaw.wa.com>


Jakob Schmidt <sumus@aut.dk> wrote in message
news:1eg3nmp.17nqhqm1lkr7ggN@[192.168.88.117]...
> Hi
>
> I find myself wondering if there are some written or unwritten rules
> about the "Just another Perl Hacker" sig that some posters use?
>
> Of course I had to make a couple myself but I'm worried that I may be
> breaking some rules (like for instance maybe you have to be a _real_
> Perl Hacker) and making a fool of myself if I use them.

As a non-hacking, rarely-posting poser, I haven't had any feelings of
remorse for posting my own JAPH.  Now I think I'd feel a little worse if I
had stolen it from someone else...

Lauren
--
print grep ord $_,map{y/a-zA-Z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c55k10e13wx0-13za1bc3-68'=~m#([^!\n]{3})#g#tr/-0-9//d;print





------------------------------

Date: Tue, 29 Aug 2000 01:39:57 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: The Hacker signature disciplin
Message-Id: <1eg3r4k.1fsl5ugzmpkxwN@[192.168.88.117]>

Eli the Bearded <elijah@workspot.net> wrote:

> Well, if they work, that's a start, and not a foolish one at that.

Cool. Thanks to Lauren too.

This one's of course more cosmetically clever than really clever - but
as sigs go I think it's OK.

-- 
Jakob

$if=sub{#for]if&$_ or &$
print$&if s].$]]s#y/\n//
}if$_=qq]$/rekcaH$"lreP$
"rehtona$"tsuJ];{[eval'&
$if,'x25]}#split,[2..$.]


------------------------------

Date: 28 Aug 2000 17:54:47 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: The Hacker signature disciplin
Message-Id: <m1em38hoo8.fsf@halfdome.holdit.com>

>>>>> "Jakob" == Jakob Schmidt <sumus@aut.dk> writes:

Jakob> Hi
Jakob> I find myself wondering if there are some written or unwritten rules
Jakob> about the "Just another Perl Hacker" sig that some posters use?

Jakob> Of course I had to make a couple myself but I'm worried that I may be
Jakob> breaking some rules (like for instance maybe you have to be a _real_
Jakob> Perl Hacker) and making a fool of myself if I use them.

As the originator of the tradition, I must say that those that do not
include the comma are not canon.  :)

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Tue, 29 Aug 2000 00:55:47 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: The Hacker signature disciplin
Message-Id: <MPG.1415a784da7f61e98971b@localhost>

Jakob Schmidt <sumus@aut.dk> wrote ..
>I find myself wondering if there are some written or unwritten rules
>about the "Just another Perl Hacker" sig that some posters use?
>
>Of course I had to make a couple myself but I'm worried that I may be
>breaking some rules (like for instance maybe you have to be a _real_
>Perl Hacker) and making a fool of myself if I use them.

I think the only rule that I'm aware of is that if you have to ask - 
then you shouldn't use it *8^)

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: Mon, 28 Aug 2000 14:56:15 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: turn characters into meta characters
Message-Id: <MPG.14147fdc84b6566298aceb@nntp.hpl.hp.com>

In article <8oeid3$2l4$1@nnrp1.deja.com> on Mon, 28 Aug 2000 20:34:44 
GMT, aaronp243@my-deja.com <aaronp243@my-deja.com> says...
> In article <MPG.141462c07154449c98ace9@nntp.hpl.hp.com>,
>   Larry Rosler <lr@hpl.hp.com> wrote:
> > In article <8oe5sa$ind$1@nnrp1.deja.com> on Mon, 28 Aug 2000 17:01:11
> > GMT, aaronp243@my-deja.com <aaronp243@my-deja.com> says...
> > > Hi, I have a programming question.  I have a string that contains
> > > "\t\t\t\t".  Those are not tabs, they would be matched like this:
> > > 	m/\\t/g
> > >
> > > but I want to turn them in to tabs.  However, I don't want to
> > > hardcode anything.  I want to turn all "\n"'s into newlines,
> > > any "\t"'s into tabs, etc.  Any help would be greatly appreciated.
> >
> > I posted a solution on August 24.
> >
> > http://x73.deja.com/[ST_rn=ps]/getdoc.xp?AN=662144757

 ...

> Actually, I solved the problem.  Here is my solution:

<SNIP -- reproduced below>

Well, as you wish.  But it depends on how much of this you have to do.  
A subroutine call plus 'eval STRING' is really, really slow compared to 
a hash lookup.


Benchmark: timing 16384 iterations of Eval, Hash...
      Eval: 18 wallclock secs (17.67 usr +  0.00 sys = 17.67 CPU) @ 
927.06/s (n=16384)
      Hash:  1 wallclock secs ( 1.11 usr +  0.00 sys =  1.11 CPU) @ 
14773.67/s (n=16384)


#!/usr/local/bin/perl -w
use Benchmark;

sub escape {
        my $char = shift;
        my $a = '$b = "' . $char . '";';
        my $escaped = eval $a;
        return $escaped;
}

$escapes = 'befnrt';
%escapes = map { $_, eval "qq(\\$_)" } split // => $escapes; 
$regex   = qr/\\([$escapes])/;

$string  = 'asdf\nsdfg\t\xwrt';

timethese( 1 << (shift || 0), {
    Eval  => '(my $x = $string) =~ s/(\\\\[a-z])/escape($1)/eg',
    Hash  => '(my $x = $string) =~ s/$regex/$escapes{$1}/g',
} );

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


------------------------------

Date: Tue, 29 Aug 2000 00:46:48 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Unclosed HTML Tags
Message-Id: <MPG.1415a56a73c77b5598971a@localhost>

Tazz <y2jagar@icqmail.com> wrote ..
>I have a news Perl scrpt im working on, a user fills out a form, submits
>it, and then it is later displayed with all the news items on one page,
>the problem is this: if someone forgets to close an HTML tag in their
>post (they use <b> but forget to add the </b> end tag) it makes the
>entire page bold.
>
>Beyond the obvious of adding "</B> </i> </A> </H1> </small>" etc to the
>end of each post, how can I deal with this problem? Is there a
>fixallhtml( ) function?

no .. there's not

as an aside - you'll probably get a better answer in a CGI specific 
newsgroup .. comp.infosystems.www.authoring.cgi would be your best bet

but my advice .. NEVER allow a user to input raw HTML .. it's MUCH 
easier to prevent them from inputting any HTML than it is to ensure that 
they don't break your page

create your own little syntax for some simple formatting tags

  h1[here's a heading]

  a[here's an anchor|http://www.anchor.com/]

that sort of thing .. and then make the substitutions yourself .. first 
step is to replace ALL '<'s and '>'s for &lt; and &gt; respectively 
(either with a substitution - or using HTML::entities or the like) .. 
then make your accepted formatting changes

for the above heading example you'd use this sort of thing

  s{(h\d)\[([^\]]+)]}{<$1>$2</$1>}g;

-- 
  jason -- elephant@squirrelgroup.com --


------------------------------

Date: 28 Aug 2000 23:35:09 GMT
From: dha@panix.com (David H. Adler)
Subject: Re: would you recommend buying a book
Message-Id: <slrn8qltpd.cv3.dha@panix2.panix.com>

On Sat, 26 Aug 2000 19:18:47 GMT, Tim Hammerquist <tim@degree.ath.cx>
wrote:

>The fact that it's trendy (Cargo cult, in your language) may just be (in
>this case) an indicator of it's effectiveness.

FYI, "Cargo cult" ne "trendy".  The former is indicative (mind you,
this is my reading of it an may not be utterly precise) of an attitude
resembling "This is the way I've seen it done, and, therefore, it must
be the correct way".

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Shut up, listen, and dance. - Madness


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4158
**************************************


home help back first fref pref prev next nref lref last post