[12034] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5634 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 11 23:07:12 1999

Date: Tue, 11 May 99 20:00:25 -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, 11 May 1999     Volume: 8 Number: 5634

Today's topics:
        [Fwd: my hands are tied] <gbartels@xli.com>
    Re: CONTRACT PERL PROGRAMMER (Tad McClellan)
    Re: CONTRACT PERL PROGRAMMER (Ronald J Kimball)
    Re: Generate matching strings from regex ? (Ronald J Kimball)
    Re: HASH AND ARRAY (Tad McClellan)
        How do I get a hash slice as a hash in a Perlish way? <a794636757612661@mailcity.com>
    Re: How do I get a hash slice as a hash in a Perlish wa (Larry Rosler)
    Re: Link -> auto generated page <devans@radius-retail.kom>
    Re: Need a little looping help (Randal L. Schwartz)
    Re: Need a little looping help (Ronald J Kimball)
        New at this, Perl/Cgi How to get the end of a sript to  <william_holmes@nospamrocketmail.com.nospam>
    Re: pattern matching - confused.... (Larry Rosler)
        Perl equivalent of charCodeAt & fromCharCode in JavaScr ham@nospam.com
    Re: Perl equivalent of charCodeAt & fromCharCode in Jav <walton@frontiernet.net>
    Re: Perl Processes and Deamons. (Tad McClellan)
    Re: Reading directories, entering directories, chaning  <dimitrio@sympatico.ca>
        reloads <globus@infonet.ee>
    Re: Seizing the Bull by the Horns (Larry Rosler)
    Re: Seizing the Bull by the Horns <tchrist@mox.perl.com>
    Re: SQL Escape routine <devans@radius-retail.kom>
    Re: SQL Escape routine (Alastair)
    Re: sub return undef @array ? (Larry Rosler)
        The Parable of the Broken Capsule <tchrist@mox.perl.com>
    Re: The Parable of the Broken Capsule (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 11 May 1999 21:15:52 +0100
From: Greg Bartels <gbartels@xli.com>
Subject: [Fwd: my hands are tied]
Message-Id: <780A83616B05D31196800020484025000D4013@SEUBPEBAS54>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_000_01BE9C0B.6B0BA090
Content-Type: text/plain;
	charset="iso-8859-1"

Greg Bartels wrote:

> this works:
> my $first; tie $first, 'stoplight', \$first, 4;
>
> sub TIESCALAR  # in   stoplight.pm looks like this
> {
> my ($class,$ref,$value) =@_;
> my $r_hash = {
>   'ref' => $ref,
>   'value'=>$value };
> return bless $r_hash, $class;
> }
>
> The problem is that
> my $first; tie $first, 'stoplight', \$first, 4;
> is about as ugly as you can get.
>
> is there anyway to write a subroutine that I could
> say something like:
> my $first = magic_routine(4);
> and it figures out the rest?
> i.e. $first is a scalar tied to 'stoplight' package, initialized to 4,
> and
> a reference to the scalar is stored in the object.
> something like:
>
> sub magic_routine
> {
>  my($initial_value) = @_:
>  my $scalar;
>  tie $scalar, 'stoplight', \$signal, $initial_value;
>  my $r_hash = {
>    'ref' => \$signal,
>    'value' => $value };
>  return bless $r_hash, 'stoplight';
> }
>
> in yet other words, how can I write my own 'tie' routine?
>
> my_tie( my $first, 4);
>
> how does tie do its magic?
>
> gbartels@xli.com


------_=_NextPart_000_01BE9C0B.6B0BA090
Content-Type: message/rfc822

Newsgroups: comp.lang.perl.moderated
From: Greg Bartels <gbartels@xli.com>
Subject: my hands are tied
Message-ID: <373884E1.A8385FFE@xli.com>
Sender: Greg Bartels <gbartels@xli.com>
Date: Tue, 11 May 1999 20:28:33 +0100
MIME-Version: 1.0
Lines: 16
X-Newsreader: Microsoft (R) Exchange Internet News Service Version 5.5.2448.0
Content-Type: text/plain

this works:
my $first; tie $first, 'stoplight', \$first, 4;

sub TIESCALAR  # in   stoplight.pm looks like this
{
my ($class,$ref,$value) =@_;
my $r_hash = {
  'ref' => $ref,
  'value'=>$value };
return bless $r_hash, $class;
}

The problem is that
my $first; tie $first, 'stoplight', \$first, 4;
is about as ugly as you can get.

is there anyway to write a subroutine that I could
say something like:
my $first = magic_routine(4);
and it figures out the rest?
i.e. $first is a scalar tied to 'stoplight' package, initialized to 4,
and
a reference to the scalar is stored in the object.
something like:

sub magic_routine
{
 my($initial_value) = @_:
 my $scalar;
 tie $scalar, 'stoplight', \$signal, $initial_value;
 my $r_hash = {
   'ref' => \$signal,
   'value' => $value };
 return bless $r_hash, 'stoplight';
}

in yet other words, how can I write my own 'tie' routine?

my_tie( my $first, 4);

how does tie do its magic?

gbartels@xli.com





------_=_NextPart_000_01BE9C0B.6B0BA090--



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

Date: Tue, 11 May 1999 15:09:10 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: CONTRACT PERL PROGRAMMER
Message-Id: <m8v9h7.tmf.ln@magna.metronet.com>

TRG Software : Tim Greer (webmaster@chatbase.com) wrote:

: >    * self-motivated with a positive attitude

: Damn! I'm out. (I need constant encouragement from my peers).


   Take the rest of the day off.

   Tell 'em I said you could.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 11 May 1999 22:52:40 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: CONTRACT PERL PROGRAMMER
Message-Id: <1drnug2.1ghspx01xe2sosN@[207.60.170.146]>

Adam Fishman <adam@fci.net> wrote:

> CONTRACT PERL PROGRAMMER
> 
> A Commercial Internet Commerce Service Provider providing Internet
> E-Commerce Websites for companies around the country is accepting
> applications for the position of CONTRACT PERL PROGRAMMER. Applicants must
> be self-motivated, talented and have at least 3 years experience in
> computer programming.
> 
> Programming experience in C/Unix, CGI scripting, SHELL, AWK, SED and PERL.
> Duties will include documentation, programming, and debugging. Flexible
> hours. Part-Time. 
> 
> Please send a resume and samples of programming work to:
> 
> FCI.NET 
> 1462 W. 8th Ave. 
> Eugene, OR 97402
> FAX: 541-345-1257
> OR 
> EMAIL jobs@fci.net
> 

TIP for Applicants: In Accordance with FCI.NET's Preferred Style,
RESUMES should contain as many unnecessary Capital Letters as POSSIBLE.

-- 
 _ / '  _      /       - AKA -
( /)//)//)(//)/(   Ronald J Kimball      RJK@Linguist.Dartmouth.EDU
    /                                Http://WWW.TIAC.NET/users/chipmunk/
        "It's Funny 'Cause it's True ... and Vice Versa."


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

Date: Tue, 11 May 1999 22:52:41 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Generate matching strings from regex ?
Message-Id: <1drnuu7.jvbgdw85hq80N@[207.60.170.146]>

Bart Lateur <bart.lateur@skynet.be> wrote:

> Ronald J Kimball wrote:
> 
> >Bart Lateur <bart.lateur@skynet.be> wrote:
> >
> >> As a first side remark: you cannot do everything using regexes alone.
> >> Nested submatches don't translate into regexes. You probably would need
> >> a parser for that. Example of nested submatches:
> >> 
> >>   /(a(b*)c)/
> >
> >I must be missing something...  That *is* a regular expression.  So what
> >do you mean when you say that nested submatches don't translate into
> >regexes???
> 
> Of course it's a regex. My aim is to build an engine that can
> translate any regex, like this one, into a more readable format.
> 
> The syntax of capturing parentheses is defined recursively. Nesting can
> go to any depth. Hence, you need a parser.

OH!  You meant "You cannot use a regular expression to _parse_ a regular
expression containing nested submatches."  I thought you meant "You
cannot use a regular expression to _perform_ nested submatches."

You should express yourself more clearly.  *grin*

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
         "It's funny because it's true ... and vice versa."


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

Date: Tue, 11 May 1999 16:14:23 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HASH AND ARRAY
Message-Id: <v23ah7.tmf.ln@magna.metronet.com>

bababozorg@aol.com wrote:

: Subject: HASH AND ARRAY
   
   Shouting at us does not increase the chances of us
   giving you an answer. It actually decreases the chances.


: i have a array like this:
: @array = ("aaa","bbb","ccc");
: i would like to add each element of this array az a key into a hash.


   Use a hash slice.

      @hash{@array} = ('') x @array;  # keys from @array, values are empty


: AND ALSO DOES ANY ONE KNOWS HOW TO SORT a HASH?

   Shouting at us does not increase the chances of us
   giving you an answer. It actually decreases the chances.


   Anybody who has read the Perl FAQ knows how to do that.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Tue, 11 May 1999 17:54:04 -0700 (PDT)
From: Dwayne Retsky <a794636757612661@mailcity.com>
Subject: How do I get a hash slice as a hash in a Perlish way?
Message-Id: <0926470444e9f02311ea459dd976a74403c90d2e4a@mailcity.com>

I have a hash

	%gundark = ('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);

Now, I'm only interested in what vowels are associated with, so I want
a hash that contain all the key-value pairs that %gundark has where
the key is a vowel.  My friend still wants the whole %gundark though,
so I do

	%nerfherder = ('a' => $gundark{'a'}, 'e' => $gundark{'e'});

Is there a better way to do this?  In general I want to get a subset of
a hash, with only the keys I'm interested in.  Clearly I can iterate over
the keys I'm interested in and put them in my new hash, but I'm hoping
for a simple expression to do it.  Kind of like a hash slice, only making
another hash, instead of an array.

-- 
Dwayne Retsky
Mail sent to the address on this posting is rarely, if ever, read.
Please respond to the proper newsgroup.


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

Date: Tue, 11 May 1999 18:25:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I get a hash slice as a hash in a Perlish way?
Message-Id: <MPG.11a2786a1d74b73c989a35@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <0926470444e9f02311ea459dd976a74403c90d2e4a@mailcity.com> on 
Tue, 11 May 1999 17:54:04 -0700 (PDT), Dwayne Retsky 
<a794636757612661@mailcity.com> says...
> I have a hash
> 
> 	%gundark = ('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);
> 
> Now, I'm only interested in what vowels are associated with, so I want
> a hash that contain all the key-value pairs that %gundark has where
> the key is a vowel.  My friend still wants the whole %gundark though,
> so I do
> 
> 	%nerfherder = ('a' => $gundark{'a'}, 'e' => $gundark{'e'});
> 
> Is there a better way to do this?  In general I want to get a subset of
> a hash, with only the keys I'm interested in.  Clearly I can iterate over
> the keys I'm interested in and put them in my new hash, but I'm hoping
> for a simple expression to do it.  Kind of like a hash slice, only making
> another hash, instead of an array.

A hash slice makes an array makes another hash via a hash slice.

      my @vowels = qw( a e i o u );
      my %nerfherder;
      @nerfherder{@vowels} = @gundark{@vowels};
      print map "$_: $nerfherder{$_}\n" => sort keys %nerfherder;

What's with the variable names?  What other foreign culture haven't I 
tapped into?

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


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

Date: Tue, 11 May 1999 09:13:05 +0100
From: "Dave Evans" <devans@radius-retail.kom>
Subject: Re: Link -> auto generated page
Message-Id: <7h8rs6$32ts4@news.gomontana.com>

That's nice.  Now, what was your question?

Andreas wrote in message <7h8jhp$eb3$1@nnrp1.deja.com>...
>Hi,
>I4d like the visitors at my homepage to click on a link - which then
>generates a page automatic with an image. Sort of thumbnail, without the
>nails, just links. The page that is generated should the contain an
>image that is related to the link. See what I mean?
>Thanks,
>Andreas
>




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

Date: 11 May 1999 19:18:46 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Need a little looping help
Message-Id: <m1so93jaih.fsf@halfdome.holdit.com>

>>>>> "todd" == todd b smith <todd_b_smith@my-dejanews.com> writes:

todd> So if anyone wants to help, I'm asking "What's wrong with
todd> this?", not "How should I be writing this?"

Well, first, "what's wrong with this" is you shouldn't be using
20 nested for loops.

But if you insist, the biggest problem is that you need to eval
an entire compilation unit in one stretch.  If you start a for
loop, you need to end that same for loop.

Here's a nested for-loop, 5 levels, with an eval:

    my @vars = map "\$$_", (zz01..zz05);
    my $code = qq(print "@vars\\n";\n);
    for (reverse @vars) {
      $code = qq(for $_ (1..2) \{\n).indent($code).qq(\}\n);
    }
    print $code;
    eval $code;
    sub indent { join "", map "  $_\n", split /\n/, $_[0] }

Change zz05 to zz20, and it'll still work; you'll just have to wait
longer.

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 11 May 1999 22:52:44 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Need a little looping help
Message-Id: <1drnvdb.1epbav7ri1kr3N@[207.60.170.146]>

<todd_b_smith@my-dejanews.com> wrote:

> So if anyone wants to help, I'm asking "What's wrong with this?", not
> "How should I be writing this?"

Okay, here's "what's wrong with this":  You can't compile and run just
part of a Perl script!

Still don't get it?  What do you suppose Perl will do with the following?

#!perl
for $a (1 .. 5) {
  for $b (1 .. 5) {
    for $c (1 .. 5) {
__END__


-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
      perl -e'for(sort keys%main::){print if $$_ eq 1}
            ' -s  -- -' Just' -' another ' -'Perl ' -'hacker 
' http://www.tiac.net/users/chipmunk/ [rjk@linguist.dartmouth.edu]


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

Date: Tue, 11 May 1999 17:42:10 -0700
From: william <william_holmes@nospamrocketmail.com.nospam>
Subject: New at this, Perl/Cgi How to get the end of a sript to load a page?
Message-Id: <3738CE62.D29EA9CE@nospamrocketmail.com.nospam>

Hi,

I have a fairly simple project, a glossary page.
I have written a script when accessed from a static form page
adds an entry to the glossary page.

At the end of my script I have the ,

print "Content-type: text/html\n";
print "<html><head><title>success page</title></head><body>
print "<A HREF= \"http://mysite/myglossary.html\">click here</a>\n";.
print "</body></html>\n";

This works fine, the user hits submit on the form and
gets the success page and can click on the link
back to the glossary page.

What would I add to the bottom of my script so I didn't
have this success page but was redirected to the
glossary page?  Replacing the code above.

Thanks for any help, or pointers to good information.

William.




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

Date: Tue, 11 May 1999 17:02:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: pattern matching - confused....
Message-Id: <MPG.11a264fbda933863989a31@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3738A673.52F1@datamail.co.nz> on Wed, 12 May 1999 09:51:47 
+1200, Arran Price <arranp@datamail.co.nz> says...
 ...
> #uncomment these 2 lines to see when I hardcode the chars
> #$CHAR_FROM="|";
> #$CHAR_TO="!";
> 
> #comment out the next 4 lines when using the hardcoded
> print"\nEnter from char : ";
> chomp($CHAR_FROM=<STDIN>);
> print"\nEnter to char : ";
> chomp($CHAR_TO=<STDIN>);
 ...
>    if ($_=~/$CHAR_FROM/g)
>    {
>       s/$CHAR_FROM/$CHAR_TO/g;
>       ++$MC;
>    }

Use quotemeta() or \Q to suppress metacharacter interpretation of 
variables that you interpolate into a regex.

Because the substitution operator returns true or false, you are doing 
an unnecessary test (with unnecessary defaults).

When you interpolate into a regex and the value is constant for the 
duration of the program, use the /o modifier for efficiency.

So, one line for the price of five:

      ++$MC if s/\Q$CHAR_FROM/$CHAR_TO/go;

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


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

Date: Tue, 11 May 1999 19:53:54 -0400
From: ham@nospam.com
Subject: Perl equivalent of charCodeAt & fromCharCode in JavaScript
Message-Id: <3738C312.43D07440@nospam.com>

Hi,

I'm using the following JavaScript function on some form input.  How
would I do this in Perl.  Thanks for any help.

function getChecksum(input)

{
        var checksum = 0;
        for( var i = 0; i < clkstr.length; i++ ) {
                checksum += clkstr.charCodeAt(i);
        }
        return String.fromCharCode((checksum % 26) + 97);
}



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

Date: Tue, 11 May 1999 22:43:33 -0400
From: Bob Walton <walton@frontiernet.net>
To: ham@nospam.com
Subject: Re: Perl equivalent of charCodeAt & fromCharCode in JavaScript
Message-Id: <3738EAD5.473219A0@frontiernet.net>

Check out the "ord" and "chr" functions of perl.

ham@nospam.com wrote:

> Hi,
>
> I'm using the following JavaScript function on some form input.  How
> would I do this in Perl.  Thanks for any help.
>
> function getChecksum(input)
>
> {
>         var checksum = 0;
>         for( var i = 0; i < clkstr.length; i++ ) {
>                 checksum += clkstr.charCodeAt(i);
>         }
>         return String.fromCharCode((checksum % 26) + 97);
> }



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

Date: Tue, 11 May 1999 16:48:20 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl Processes and Deamons.
Message-Id: <k25ah7.rof.ln@magna.metronet.com>

Ming (fungs@logica.com) wrote:
: Can anyone give me some pointers for writing Perl Deamons and Spawning child
: processes in Perl.


   Perl FAQ, part 8:

      "How do I fork a daemon process?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Wed, 12 May 1999 00:41:13 GMT
From: Dimitri Ostapenko <dimitrio@sympatico.ca>
Subject: Re: Reading directories, entering directories, chaning file  permissions...
Message-Id: <3738961E.7DF89B4B@sympatico.ca>

Asbjorn Gjemmestad wrote:

> I am trying to create a script taht will do the following:
>
> - Get a list of the directories in a given folder.
> - Enter each of these directories, and chmod all files to 777 in each and
> every directory.
>
> I figure that the best way of doing this is through a telnet interface,
> since you've got your own permissions instead of Perl's permissions like
> through a html page. (don't you???)
>
> Here's what I've come up with, but it doesn't seem to do the trick. Any help
> whatsoever is greatly apprecciated.
>
> thnx
>
> Asbjorn
>
> ########## The script : ###########
> # :'s and .'s are used as progress indocators
> #one : is printed for each directory, and one . is printed for each file.
>
> #!/usr/local/bin/perl -w
>
> $dir = "/usr/sites/blitzkrieg.org/blitzkrieg/members";
>
> use Benchmark;
>    $t0 = new Benchmark;
>
> chdir ($dir) || die "Can't change directory!";
>
> opendir(DIR, ".") || die "Can't open directory";
> @files = readdir(DIR) || die "Can't read directory ";
> closedir(DIR);
>
> print "Processing : <br>";
> @errors = "";
> $processed = 0;
> $dirs = 0;
> $fnum = @files;
> print "Files: $fnum";
>
> foreach $file (@files) {
>  chomp ($file);
>  print ":";
>  opendir(D, $dir/$file) || die "Can't read directory 3";
>  @members = readdir(D);
>  closedir(D);
>  $dirs++;
>  foreach $member (@members) {
>   chomp($member);
>   chmod(0777, "$dir/$file/$member") || push(@errors, "$file/$member");
>   print ".";
>   $processed++;
>  }
> }
>
> if ($errors[0]) {
> print "The following files returned errors:";
>  foreach $error (@errors) {
>   print "$error\n";
>  }
> }
> print "\n $processed files in $dirs directories processed! ";
>
> $t1 = new Benchmark;
> $td = timediff($t1, $t0);
>
> print "Execution time:",timestr($td),"\n";
>
> exit;

Don't try to reinvent the wheel - use File::Find. See example @ www.perlnow.com

Dimitri




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

Date: Wed, 12 May 1999 05:44:23 +0300
From: Gleb Ekker <globus@infonet.ee>
Subject: reloads
Message-Id: <3738EB07.BF6944E3@infonet.ee>

Hi,

can anybody help my about how perl script may know was the page (which
calls this script) reloaded (refreshed) before it?
I have written script for my site simple statistics and used Envirable
Variables for this purpose, but there is no information about was the
page reloaded or not.

Thanks,  Gleb,  globus@infonet.ee



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

Date: Tue, 11 May 1999 17:54:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Seizing the Bull by the Horns
Message-Id: <MPG.11a2712a9f06421a989a33@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3738aefc@cs.colorado.edu> on 11 May 1999 16:28:12 -0700, Tom 
Christiansen <tchrist@mox.perl.com> says...
> You know, it's very disappointing to see so many followups
> to the prose, but nary a single one to the code. :-(

What would you like us to focus on?

1.  A 1998 date on code that doesn't use '-w' or 'use strict;' and uses 
'local' instead of 'my'?  My, my...

2.  Some option processing, without a module?

3.  Nonstandard filename processing, instead of input from <> and output 
to STDOUT, as in other filters?

4.  Attempts to fix HTML one line at a time, when tags may readily be 
multi-line?

5.  C-style character-at-a-time processing?

6.  Use of s/x/y/g; all over, instead of tr/abcd/efgh/; ?

7.  Use of '-' as an alternate regex delimiter, which is hazardous to 
your sanity?

8.  Lots of attention to line wrapping, which is hardly necessary for 
munged HTML, but no use of Text::Wrap?

9.  Lots of little bugs and invalid assumptions, such as this optional 
leading zero, for example:

      $s =~ s/&#038;/&amp;/g;

etc.?

Oh, I think you wanted us to comment on what a foul job M$ does, messing 
around with HTML and nonstandard characters!  OK, they do.  But this 
simple little (but long) filter doesn't do a great job fixing it.  And 
why do you call it a proxy?

Maybe I'll send back something that fits on one page, and works much 
faster and better.

Oh ---

MICRO$OFT DOES A FOUL JOB MESSING WITH HTML AND NONSTANDARD CHARACTERS!

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


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

Date: 11 May 1999 20:37:05 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Seizing the Bull by the Horns
Message-Id: <3738e951@cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:What would you like us to focus on?

I would like you to focus on the code you're following up to.  You didn't
do that.  You're talking about the demoroniser code.  You're getting
things crossed.  Please unpack the proxy if you care to comment.

--tom
-- 
 "I do not feel obliged to believe that the same God who endowed us with sense,
 reason and intellect has intended us to forgo their use."   -- Galileo Galilei


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

Date: Tue, 11 May 1999 09:02:35 +0100
From: "Dave Evans" <devans@radius-retail.kom>
Subject: Re: SQL Escape routine
Message-Id: <7h8r8f$33ac3@news.gomontana.com>

Could you be a little more specific - replace what with what exactly?

Darren wrote in message <7h80eg$24h@dfw-ixnews10.ix.netcom.com>...
>I am trying to find a quick subroutine which will escape characters such as
>" and ' so that a user cannot try to put them into a text field ... or,
even ...





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

Date: Wed, 12 May 1999 00:44:40 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: SQL Escape routine
Message-Id: <slrn7jhnaa.5f.alastair@calliope.demon.co.uk>

Darren <darrensw@ix.netcom.com> wrote:
>Hi
>
>I am trying to find a quick subroutine which will escape characters such as
>" and ' so that a user cannot try to put them into a text field ... or, even
>better, to have the sub replace them with an escape character to allow them
>in so that my text field can accept, for example:

If you are using the DBI module for your SQL excursions, it has a 'quote'
method. Could this be of use? You could always check the source code for help.

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Tue, 11 May 1999 17:09:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: sub return undef @array ?
Message-Id: <MPG.11a2667fd4ebab18989a32@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <OR2_2.259$6x6.141@news.rdc1.sfba.home.com> on Tue, 11 May 
1999 23:14:54 GMT, Stephen Warren <swarren@www.wwwdotorg.org> says...
 ... 
> sub retundef
> {
>    return undef ;
> }

     return ();

> my @x = retundef() ;
> 
> my $text = ( defined @x ) ? "defined\n" : "not defined\n" ;

perlfaq4:  "Why does defined() return true on empty arrays and hashes?
 
The short story is that you should probably only use defined on scalars 
or functions, not on aggregates (arrays and hashes). See perlfunc in the 
5.004 release or later of Perl for more detail." 

The following is a fun (i.e., semi-obscure) way of printing the right 
thing:

  my $text = (@x && 'not ') . "empty\n";

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


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

Date: 11 May 1999 18:31:27 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: The Parable of the Broken Capsule
Message-Id: <3738cbdf@cs.colorado.edu>

It's springtime, which means it's tree pollen season again, so you're
all stuffed up from seasonal allergies.  Off you go to the corner
store to get an antihistamine, but all you find are packages filled with
combination capsules containing both an antihistamine and decongestant
in them.  You don't need or want the decongestant, because it's a
stimulant, and you're already drinking enough coffee to put you on the
verge of cardiac arrest.  But you buy the package anyway, figuring that
you can deconstruct it manually.

You take your encapsulated medication home with you and start looking
it over closely.  The casings on the capsules are clear on one half,
red on the other.  Despite the warning on the label not to open the
capsule, you do so anyway, having peered through the transparent half.
Inside you find a bunch of tiny beads: some red, others white.  After you
carefully divide them out, there seems to be about twice as many red
ones as white ones.  Taking the path of least risk, you consume just
the tiny white beads and leave the red ones alone.

Success!  You correctly picked the antihistamine, so now you start to
feel much better.

Time passes.

It's now autumn, and the ragweed is starting to get to you.  You go down
to the corner store and get more medication capsules.  They've got the
same brand, so you buy it and do the same trick.

This time you're in big trouble--the company switched what the colors
meant.  Red is now antihistamine, and white is now decongestant.
Your pulse quickly shoots through the roof and you have a heart attack.
But the ambulance gets there in time, so you live.

After a week convalescing, you find you have permanent coronary damage,
and will require expensive care the rest of your life.  Finding yourself
strapped for cash, do you what everybody else in our day and age does
in your situation: you file suit against the pharmaceutical corporation.

In court, their lawyers point out that you intentionally disobeyed
the labelling that told you not to open the capsules, so on your head
be it.  You argue that you could see inside, and it had worked before,
so it was their fault for switching the meanings of the colors.

The judge looks over the label and asks whether you'd read it.
You confess that you had, but since you could see through the capsule
in places and were so desperate, you did what you felt you had to do.
And it had even worked out the first time, hadn't it?

The judge shakes his head and not only finds for the pharmaceutical
company, he also makes you you pay their court costs as well.  You get
so flustered, you have an another heart attack and perish on the spot.

      -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

So what's the moral of our story?  

    +-------------------------------------------------------------+
    | Never violate the object's encapsulation, even if you can   |
    | see into it!  Nothing but the implementing accessor methods |
    | themselves should ever, *ever* touch data attributes on     |
    | an object.  Let everything else use the accessor methods,   |
    | even apparently friendly method calls in the same class.    |
    +-------------------------------------------------------------+


-- 
    #define SIGILL 6         /* blech */
        --Larry Wall in perl.c from the 4.0 perl source code


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

Date: Tue, 11 May 1999 18:14:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: The Parable of the Broken Capsule
Message-Id: <MPG.11a275e051229746989a34@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3738cbdf@cs.colorado.edu> on 11 May 1999 18:31:27 -0700, Tom 
Christiansen <tchrist@mox.perl.com> says...
> It's springtime, which means it's tree pollen season again, so you're
> all stuffed up from seasonal allergies.  Off you go to the corner
> store to get an antihistamine, but all you find are packages filled with
> combination capsules containing both an antihistamine and decongestant
> in them.  You don't need or want the decongestant, because it's a
> stimulant, and you're already drinking enough coffee to put you on the
> verge of cardiac arrest.  But you buy the package anyway, figuring that
> you can deconstruct it manually.

 ...

> So what's the moral of our story?  
> 
>     +-------------------------------------------------------------+
>     | Never violate the object's encapsulation, even if you can   |
>     | see into it!  Nothing but the implementing accessor methods |
>     | themselves should ever, *ever* touch data attributes on     |
>     | an object.  Let everything else use the accessor methods,   |
>     | even apparently friendly method calls in the same class.    |
>     +-------------------------------------------------------------+

My moral is based solely on your first paragraph.

Integrating unrelated software such as browsers into operating systems 
is bad.  Building omnibus commands with a zillion options, instead of 
relying on single-purpose filters hooked together, is bad.*  [Or big 
object classes with lots of methods. :-]  Unix is good;  Micro$oft is 
bad.

(* I write this as the principal perpetrator of the pr(1) command, which 
see for more details.  An example:  an option '-d' to double-space, 
instead of 'simply' piping a sed command that doubles linefeeds into pr.  
Tell that to my secretary!  :-)

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.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 5634
**************************************

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