[18877] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1045 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 2 18:10:43 2001

Date: Sat, 2 Jun 2001 15:10:13 -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: <991519813-v10-i1045@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 2 Jun 2001     Volume: 10 Number: 1045

Today's topics:
    Re: Newbie trends over time (John R Ramsden)
    Re: Newbie trends over time <sjhoward@blackhole.nyx.net>
    Re: Newbie trends over time <godzilla@stomp.stomp.tokyo>
    Re: Perl request (Teffy)
    Re: regex question. $25 for answer. (Dave Hoover)
    Re: regex question. $25 for answer. (Marc Fest)
    Re: regex question. $25 for answer. <krahnj@acm.org>
    Re: regular expressions to convert link <godzilla@stomp.stomp.tokyo>
    Re: regular expressions to convert link <godzilla@stomp.stomp.tokyo>
        Seven years of highly defective posters Was: The Flakey <RAY_electronic_design@t-online.de>
    Re: taint + netstat = error nobull@mail.com
    Re: taint + netstat = error <joe+usenet@sunstarsys.com>
    Re: To compress and uncompress text files ? <goldbb2@earthlink.net>
    Re: Too late for "-T" option at comment_form.cgi line 1 <davsoming@lineone.net>
    Re: Why this substitution doesn't work? <peter@nospam.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 02 Jun 2001 19:21:00 GMT
From: jr@redmink.demon.co.uk (John R Ramsden)
Subject: Re: Newbie trends over time
Message-Id: <3b192f62.90172287@news.demon.co.uk>

John Callender <jbc@west.net> wrote:
>
>  [...]
>
> Maybe I'm just catching the group on a bad week, but it seems
> pretty clear that the problem with newbies blundering in and
> posting off-topic (typically Web/CGI related) questions has
> gotten worse.
>
>  [...]

You mention forming this impression after revisiting c.l.p.m after
a year's absence, which suggests you may be a Perl veteran.

I think that may be a clue to the problem: People who have "grown up"
with Perl, even in part but certainly if their experience goes back
years, sometimes forget just how large and all-embracing it has now
become, especially if one includes all the modules.

Also the fact that Perl, being so flexible, is used to drive so many
other packages and subsystems means developers encountering problems
in such applications sometimes find it hard to know on which side of
the Perl/package boundary the problem lies. That certainly seems to
be the case for a lot of the CGI questions.

It's hard to think of an answer to the problem of off-topic questions.
One day we'll probably see the appearance of AI "helpers", at which
newbies can fire questions and sample code and hopefully get useful
feedback. But until then (and probably long after ;-( I guess newbies
will still be with us.

In other "techie" groups I frequent, such as sci.math, which are also
plagued by the same old newby questions, both trivial and hard, the
veterans tend to ignore these questions and leave to readers of more
recent standing the chore of replying.

So for those understandably becoming grouchy at seeing the same old
Perl questions cropping up time and time again perhaps a partial
solution is just to skip those posts and leave them for bright-eyed
bushy-tailed new recruits to field and thereby benefit everyone:

 - veterans with lower blood pressure and more time to address
   the tougher questions.

 - "expert newbies" with more opportunity to practice their
   Perl problem analysis skills

 - "clueless newbies" with their questions, however pathetic,
   answered!


Cheers

---------------------------------------------------------------------------
John R Ramsden (jr@redmink.demon.co.uk)
---------------------------------------------------------------------------
The new is in the old concealed, the old is in the new revealed.
   St Augustine.
---------------------------------------------------------------------------


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

Date: Sat, 02 Jun 2001 13:04:25 -0700
From: Scott Howard <sjhoward@blackhole.nyx.net>
Subject: Re: Newbie trends over time
Message-Id: <9fbgs9022o1@enews1.newsguy.com>

'Expert groups' are nice in theory, but in practice, that'd be the very 
first place newbies with poorly considered questions would go. 

For an example or seventy, check out any NG along the lines of 
*unix*gurus or *unix*wizards*. argh! :-)

I think it is far more realistic to simply tolerate stupidty or stop 
reading the NG. Changing the names of a few newsgroups isn't going to 
change human nature.

-- 
Remove "blackhole." for a valid Reply-To: address


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

Date: Sat, 02 Jun 2001 14:50:24 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Newbie trends over time
Message-Id: <3B195FA0.F2529573@stomp.stomp.tokyo>

John R Ramsden wrote:
 
> John Callender <jbc@west.net> wrote:

(snipped)

> So for those understandably becoming grouchy at seeing the same old
> Perl questions cropping up time and time again perhaps a partial
> solution is just to skip those posts and leave them for bright-eyed
> bushy-tailed new recruits to field and thereby benefit everyone:


Yours is a very nice, well written article. Your words and thoughts
are both sound and logical. I cannot argue your principles nor your
basic philosophy. It would be nice if reality was as you present.

However, your article, although a good article, is like so many
others posted about inherent problems here, it is a whitewash.

There is no problem with regulars being grouchy. There is a problem
with regulars being sociopathic jerks.

A review of the history of this group reflects regulars engaging
in abhorrent behavior including personal insults, vulgarity, threats,
stalking, harassment, crime and racial slurs. These activities do not
qualify for being a simple case of "grouchy." Those activities do reflect
sociopathic behavior by people here, some of us would consider to be people
who are both emotionally and mentally unhealthy.


Godzilla!


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

Date: 2 Jun 2001 10:50:50 -0700
From: WGSGNUAYHTTE@spammotel.com (Teffy)
Subject: Re: Perl request
Message-Id: <49920a43.0106020950.6607bef6@posting.google.com>

Yes, the review process consists of viewing the jpegs with the image
viewer, EXIF Viewer, and deleting some from within that Windows app.
Teffy

Bart Lateur <bart.lateur@skynet.be> wrote in message news:<72kdht42u5hmaq78en2hvktu4i1s81m8o8@4ax.com>...
> Abigail wrote:
> 
> >Well, since there is already a "review" program deleting files in KEEPERS,
> >it should be much easier to modify the review program and deleting the
> >files from ORIGINAL.
> 
> I think these are deleted manually with the help of an image file
> viewer. That's how I understand the problem at hand. Otherwise, you'd be
> right: just delete the files in KEEPERS and in ORIGINAL in one go.


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

Date: 2 Jun 2001 09:18:37 -0700
From: redsquirreldesign@yahoo.com (Dave Hoover)
Subject: Re: regex question. $25 for answer.
Message-Id: <812589bb.0106020818.338be683@posting.google.com>

> 
> /(^|\D)\d($|\D)/
> 
> Is that what you want?
> 

I believe he wants to grab the sigle digit, not the stuff around it...

 /^|\D(\d)$|\D/

--Dave


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

Date: 2 Jun 2001 14:27:15 -0700
From: wx34@yahoo.com (Marc Fest)
Subject: Re: regex question. $25 for answer.
Message-Id: <56876115.0106021327.19e64031@posting.google.com>

The $25 go to Ciaran, since he was first and his solution works for
me. Thanks for helping - to everybody. I really appreciate you all
taking the time.

Best,

Marc.


redsquirreldesign@yahoo.com (Dave Hoover) wrote in message news:<812589bb.0106020818.338be683@posting.google.com>...
> > 
> > /(^|\D)\d($|\D)/
> > 
> > Is that what you want?
> > 
> 
> I believe he wants to grab the sigle digit, not the stuff around it...
> 
>  /^|\D(\d)$|\D/
> 
> --Dave


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

Date: Sat, 02 Jun 2001 21:35:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: regex question. $25 for answer.
Message-Id: <3B195C30.FB7C945F@acm.org>

Dave Hoover wrote:
> 
> >
> > /(^|\D)\d($|\D)/
> >
> > Is that what you want?
> >
> 
> I believe he wants to grab the sigle digit, not the stuff around it...
> 
>  /^|\D(\d)$|\D/

So you want to match ^ or \D(\d)$ or \D ? This doesn't work because the
first option (^) will always match and none of the other options will be
tried.

You probably meant /(^|\D)(\d)($|\D)/



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 02 Jun 2001 08:39:20 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regular expressions to convert link
Message-Id: <3B1908A8.E3B50C98@stomp.stomp.tokyo>


  ** Fault Suckernews if this posts twice **


Raphael Pirker wrote:

(snippage)

> I need to make a link which originally looks like this in the variable
 
> <a target="_blank" href="http://www.nr1webresource.com/forums/index.php"
> onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
> onMouseOver="swapImage('forums','forums_on'); show('l_forum');">
 
> into something like this:
 
> <a target="_blank"
> href="javascript:external('http://www.nr1webresource.com/forums/index.php')"
> onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
> onMouseOver="swapImage('forums','forums_on'); show('l_forum');">

 
Be careful not to use an expression, "...something like this:" for
your articles. If I chose to be ornery, I could provide an incorrect
answer and state, "There you go. This is something like what you want."

Programming is an exacting science. Use equally exacting terminology.


Below my signature you will find two methods to accomplish this.
One method is significantly more efficient than the other. Can
you guess which is more efficient?

My first method uses a regex:

$string =~ s/(href=")(.*)(")/$1javascript:external('$2')$3/;

This regex can be written in a number of different ways. This
is the method I chose to use. In essence, this regex means:

substitute:

 href=" anything up to and including the next quote mark with this...

There is a note of caution. If the quote mark after index.php
was located elsewhere, this regex would mess up, especially
if you use a g switch for global. Should you encounter needs
like this, use an anchor. In this case of a g switch, a question
mark ? would be appropriate anchor to use.

Read about and research use of anchors for regex methods.

I will also encourage you to look at use of substring instead
of use of a regex when possible. 


Godzilla!
--

#!perl

print "Content-type: text/plain\n\n";

$string = qq(
<a target="_blank" href="http://www.nr1webresource.com/forums/index.php"
onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
onMouseOver="swapImage('forums','forums_on'); show('l_forum');">);

$string =~ s/(href=")(.*?)(")/$1javascript:external('$2')$3/;

print "Regex:\n\n$string\n\n\n";


$string = qq(
<a target="_blank" href="http://www.nr1webresource.com/forums/index.php"
onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
onMouseOver="swapImage('forums','forums_on'); show('l_forum');">);

$start = index ($string, "href=\"");
substr ($string, $start, 6, "http=\"javascript:external('");
substr ($string, index ($string, "\"", $start + 6), 1, "')\"");

print "Substring:\n\n$string";

exit;

PRINTED RESULTS:
 (careful about word wrap)
________________

Regex:


<a target="_blank"
href="javascript:external('http://www.nr1webresource.com/forums/index.php')"
onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
onMouseOver="swapImage('forums','forums_on'); show('l_forum');">


Substring:


<a target="_blank"
http="javascript:external('http://www.nr1webresource.com/forums/index.php')"
onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
onMouseOver="swapImage('forums','forums_on'); show('l_forum');">


BENCHMARK COMPARISON:
_____________________


#!perl

print "Content-type: text/plain\n\n";

use Benchmark;

print "Run One:\n\n";
&Time;

print "\n\nRun Two:\n\n";
&Time;

print "\n\nRun Three:\n\n";
&Time;


sub Time
 {
  timethese (100000,
  {
  'name1' =>
   sub {
   $string = qq(
   <a target="_blank" href="http://www.nr1webresource.com/forums/index.php"
   onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
   onMouseOver="swapImage('forums','forums_on'); show('l_forum');">);
   $string =~ s/(href=")(.*)(")/$1javascript:external('$2')$3/;},

  'name2' =>
   sub {
   $string = qq(
   <a target="_blank" href="http://www.nr1webresource.com/forums/index.php"
   onMouseOut="swapImgRestore('forums','forums_off'); hide('l_forum');"
   onMouseOver="swapImage('forums','forums_on'); show('l_forum');">);
   $start = index ($string, "href=\"");
   substr ($string, $start, 6, "http=\"javascript:external('");
   substr ($string, index ($string, "\"", $start + 6), 1, "')\"");},
  } );
 }

exit;

PRINTED RESULTS:
________________

Run One:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  2 wallclock secs ( 3.07 usr +  0.00 sys =  3.07 CPU) @ 32573.29/s
 name2:  2 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 96153.85/s


Run Two:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  3 wallclock secs ( 3.08 usr +  0.00 sys =  3.08 CPU) @ 32467.53/s
 name2:  0 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 96153.85/s


Run Three:

Benchmark: timing 100000 iterations of name1, name2...
 name1:  3 wallclock secs ( 3.02 usr +  0.00 sys =  3.02 CPU) @ 33112.58/s
 name2:  1 wallclock secs ( 1.04 usr +  0.00 sys =  1.04 CPU) @ 96153.85/s


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

Date: Sat, 02 Jun 2001 08:54:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: regular expressions to convert link
Message-Id: <3B190C38.D1CC8EA5@stomp.stomp.tokyo>

Godzilla! wrote:

> Raphael Pirker wrote:
 
(snippage)


I have a minor error in my article. You will notice my
test script includes a ? for an anchor. This should not
be there. I forgot to remove it after I finished playing
around with different regex formats and string formats.


Article body is ok:
 
> $string =~ s/(href=")(.*)(")/$1javascript:external('$2')$3/;
 

Test script is not ok:

> $string =~ s/(href=")(.*?)(")/$1javascript:external('$2')$3/;


Benchmark is ok:

>    $string =~ s/(href=")(.*)(")/$1javascript:external('$2')$3/;},


Godzilla!


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

Date: Sat, 2 Jun 2001 18:08:14 +0100
From: "Raymund Hofmann" <RAY_electronic_design@t-online.de>
Subject: Seven years of highly defective posters Was: The FlakeyMind/Bryce Jacobs FAQ (v0.1)
Message-Id: <9fb32r$6re$03$1@news.t-online.com>

I have a friend that seems to have very similar mental defects as for
example the CLPM
poster calling itself "Godzilla!". Unfortunately he now (as he became older
exceeding the age of 40 years) the rest of his body is not able anymore to
compensate his defective mind.
As i see it only time > 10-60 years can cure these kind of mental problems
in a natural and proven way.
The same may be true for the poster calling itself "Godzilla!" (and many
others).
And if one defective poster has been cured naturally, i am sure new ones
show up (i guess it will be much faster than this).

A Scott Adams fan













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

Date: 02 Jun 2001 15:52:50 +0100
From: nobull@mail.com
Subject: Re: taint + netstat = error
Message-Id: <u9ofs7djct.fsf@wcl-l.bham.ac.uk>

Ryan Tate <ryantate@OCF.Berkeley.EDU> writes:

> i'm trying to figure out why i'm getting an 'Insecure dependency in
> ``' error when calling netstat within backticks while running in taint
> mode. i'm not interpolating any variables inside the backticks, and i
> get the error even when i call the program without any options. also,
> perl doesn't mind when i call ps inside backticks.

Actually it appears you've found a bug but are barking up the
wrong tree.  Here's a simpler test case:

$ENV{PATH}='/usr/bin:/bin';
`true`,`true`; # Change comma to semicolon it works

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 02 Jun 2001 11:54:56 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: taint + netstat = error
Message-Id: <m3wv6ulvvz.fsf@mumonkan.sunstarsys.com>

nobull@mail.com writes:

> Actually it appears you've found a bug but are barking up the
> wrong tree.  Here's a simpler test case:
> 
> $ENV{PATH}='/usr/bin:/bin';
> `true`,`true`; # Change comma to semicolon it works

Bug confirmed on linux w/ 5.00503 and 5.6.1:

  % perl5.00503 -wTe 'undef %ENV; `true`;`true`'
  % perl5.00503 -wTe 'undef %ENV; `true`,`true`'
  Insecure dependency in `` while running with -T switch at -e line 1.
  % perl5.6.1 -wTe 'undef %ENV; `true`;`true`'
  % perl5.6.1 -wTe 'undef %ENV; `true`,`true`'
  Insecure dependency in `` while running with -T switch at -e line 1.

-- 
Joe Schaefer   "A foolish consistency is the hobgoblin of little minds, adored
                      by little statesmen and philosophers and divines."
                                               -- Ralph Waldo Emerson



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

Date: Sat, 02 Jun 2001 15:03:28 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: To compress and uncompress text files ?
Message-Id: <3B193880.98C64483@earthlink.net>

nosabi wrote:
> 
> Hi Bart,
> Thank You for all the Great Info.
> 
> > In what way? Are all ads being skimmed , filtered, and the
> > appropriate ones displayed? Or are you just displaying one ad at a
> > time?
> 
> The perl script just displays each ad into html tables.
> With the newest displayed at the top of the page.
> Nothing Fancy I guess. I'm an old time trs-80 enthusiast
> that use to love writting text adventure games, using lots of arrays.
> 
> > But I wonder if this is the solution to your problem. Which is...?
> > Are you worried about disk space, or about speed issues? THis might
> > save disk space, but it won't be faster. Er... un(g)zipping is quite
> > fast, actually. Gzipping takes longer. So, since a simple "append"
> > will no longer do, adding one ad to your archive will take a
> > significant time.
> >
> > >Or what should I be looking at to upgrade it to the Next Level ?
> 
> Not untill you pointed out to me the time lag problem. I did want to
> compress.  I was thinking more like..."If I could reduce the size of
> the file it might load faster"

If you reduce the size of the file sent over the web, it certainly might
load faster.  To do this, you would presumably compress the file, use
the http header "content-encoding: x-gzip", send the compressed data,
and allow the browser to decompress.

> Because I am already running into a time lag problem. I don't think
> its my web hosting provider.

Presumably, "time lag problem" means that the time it takes to send the
file is the problem, as opposed to the time it takes to generate the
html.

> Everything else, smaller files, load quick.

The time that it takes for a small file to be sent is usually dominated
by the time it takes to connect, not the time it takes to transfer.

> Anybody know what bench-mark or term for judging if my hosting
> provider is my problem ?

There are a whole slew of factors which determine the time it takes for
a file to load.  There's the time it takes to connect (which in turn, is
the time it takes the connect request to get from the browser to the
server, the time it takes the server to see it and respond, and the time
it takes for the response to get back), then the time it takes for the
server to "get" and "send" the file (simple, if it's a plain file, more
complicated if it's a cgi)... assuming it's a cgi, one might ask if it
creates all it's data, then sends it, or if it sends the data as it's
made...  Then there's the time between when the cgi on the server sends
it, and when the browser actually recieves it...

Then there's the fact that you're using html tables.  When the browser
shows stuff that's in tables, it often has to read the *entire* table
into memory, before it can even begin to show the table.  This can be
sometimes prevented by using COL or COLGROUP elements within the table
(after the <TABLE> itself, and before the first <TR> or <TH>).  If the
table cannot be incrementally rendered (ie, shown as the data arrives),
this may make the page appear very slow.  An example of a large page
which uses tables without COL or COLGROUP is the perlop page on
www.perldoc.com.  The majority of the information is in one huge table,
which cannot be displayed until it is entirely loaded, since the browser
doesn't know until the end how many columns there are.

> But Bart, what is the MySQL doing that is different from the old text
> array?

Using MySQL or some other database can speed up accesses to a single ad,
by not requiring you to load the whole list of ads into memory.  It can
also help you in terms of how quickly an ad can be added or modified.

Since you are listing all the ads, every time, using a database will not
speed you up in terms of display, and since you are never changing the
ads once they are in the file, that functionality is not needed either.

If you could post your code to the group, perhaps we could point out
things which could be done faster.

-- 
The longer a man is wrong, the surer he is that he's right.


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

Date: Sat, 2 Jun 2001 19:56:48 +0100
From: "David Soming" <davsoming@lineone.net>
Subject: Re: Too late for "-T" option at comment_form.cgi line 1.
Message-Id: <thidbsibble316@corp.supernews.co.uk>

>
> you've already seen Tad's reply, so I'll just add this:
>
> from the command line you can do syntax checking of a perl script that
> has the T switch internally on the shebang line like this:
>
> %> perl -cT script-to-test.pl
>
Thanks for that it found a typo for me!
--
David Soming
'Just a head-banger- doing what I do best'





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

Date: Sat, 2 Jun 2001 17:30:35 +0100
From: Peter Brian Clements <peter@nospam.co.uk>
Subject: Re: Why this substitution doesn't work?
Message-Id: <MPG.15832506ff85fc719896e7@news.demon.co.uk>

In article <gq%R6.54234$ko.794328@news1.frmt1.sfba.home.com>, 
fei@unbounded.com says...
> thanks!
> run the experiment you give me only print several empty line, but no sytax
> error.
> 
> after several try, this did the work,
> ( exactly I want is to remove the whole line  if $ARGV[0]  in beginning of
> the line. )
> I was thinking too complicate:)
> 
> while(<IN>){
> 
> if(s/^$ARGV[0] .*//){
>  chomp;   #remove the whole line
>  }
>  print;

Try:

 while (<IN>)
 {
   print unless m/^$ARGV[0]/;
 }

-- 
Peter Clements
Email: PeterShylockDemonCoUk


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1045
***************************************


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