[16744] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4156 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 28 18:16:50 2000

Date: Mon, 28 Aug 2000 15:15:34 -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: <967500934-v9-i4156@ruby.oce.orst.edu>
Content-Type: text

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

Today's topics:
        quickie obfuscation... <aspangler@lucent.com>
    Re: quickie obfuscation... (Marcel Grunauer)
    Re: quickie obfuscation... (Randal L. Schwartz)
    Re: quickie obfuscation... (Jakob Schmidt)
    Re: quickie obfuscation... (Jakob Schmidt)
    Re: quickie obfuscation... (Abigail)
    Re: quickie obfuscation... (Abigail)
    Re: quickie obfuscation... (Craig Berry)
    Re: quickie obfuscation... <callgirl@la.znet.com>
    Re: selling perl to management (Abigail)
    Re: selling perl to management (Abigail)
    Re: selling perl to management (Ilya Zakharevich)
    Re: selling perl to management (Ilya Zakharevich)
    Re: selling perl to management (Ilya Zakharevich)
    Re: turn characters into meta characters <lr@hpl.hp.com>
    Re: turn characters into meta characters aaronp243@my-deja.com
        Unclosed HTML Tags <y2jagar@icqmail.com>
    Re: Using a LoL to store multiline records rschram@reed.edu
    Re: Win32 path with spaces <abe@ztreet.demon.nl>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 28 Aug 2000 15:25:01 -0400
From: Aaron Spangler <aspangler@lucent.com>
Subject: quickie obfuscation...
Message-Id: <39AABC8D.A10C97C3@lucent.com>

Help me please.

Why does
           print 1 and 0;
return 1?

What is perl actually performing here?
-------

Please cc: aspangler@lucent.com


 -Aaron



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

Date: Mon, 28 Aug 2000 19:41:49 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: quickie obfuscation...
Message-Id: <slrn8qlg28.efv.marcel@gandalf.local>

On Mon, 28 Aug 2000 15:25:01 -0400, Aaron Spangler <aspangler@lucent.com> wrote:

>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().

-- 
Marcel Gr\"unauer - Codewerk plc . . . . . . . . . . . <http://www.codewerk.com>
Perl Consulting, Programming, Training, Code review . . .  <marcel@codewerk.com>
mod_perl, XML solutions - email for consultancy availability
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: 28 Aug 2000 12:45:31 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: quickie obfuscation...
Message-Id: <m1vgwlgof8.fsf@halfdome.holdit.com>

>>>>> "Aaron" == Aaron Spangler <aspangler@lucent.com> writes:

Aaron> Help me please.
Aaron> Why does
Aaron>            print 1 and 0;
Aaron> return 1?

Aaron> What is perl actually performing here?

  (print 1) and 0;

what did you want it to do?

-- 
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: Mon, 28 Aug 2000 21:46:28 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: quickie obfuscation...
Message-Id: <1eg3g5d.qoj0r51s6bhozN@[192.168.88.117]>

Aaron Spangler <aspangler@lucent.com> wrote:

> Help me please.
> 
> Why does
>            print 1 and 0;
> return 1?
> 
> What is perl actually performing here?

printing '1' (stringification of 1) and evaluating the boolean
expression consisting of the returnvalue of print, the operator 'and'
and the zero (which should give false though the print returns true if
it succeeds (which it does apparantly)

This is because of the low priority of the 'and' operator.

To get something closer to what you may be expecting either use the
higer priority && operator or put parens around the parameter list for
print.

-- 
Jakob


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

Date: Mon, 28 Aug 2000 21:48:54 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: quickie obfuscation...
Message-Id: <1eg3gkl.1wcdfnrl54o8cN@[192.168.88.117]>

Jakob Schmidt <sumus@aut.dk> wrote:

> printing '1' (stringification of 1) and evaluating the boolean
> expression consisting of the returnvalue of print, the operator 'and'
> and the zero (which should give false though the print returns true if
> it succeeds (which it does apparantly)

)

;-)

-- 
Jakob


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

Date: 28 Aug 2000 20:15:38 GMT
From: abigail@foad.org (Abigail)
Subject: Re: quickie obfuscation...
Message-Id: <slrn8qli1q.bbg.abigail@alexandra.foad.org>

Aaron Spangler (aspangler@lucent.com) wrote on MMDLIV September MCMXCIII
in <URL:news:39AABC8D.A10C97C3@lucent.com>:
\\ Help me please.
\\ 
\\ Why does
\\            print 1 and 0;
\\ return 1?

But it doesn't.

    $ perl -wle 'sub test {print 1 and 0} print "It returned: ", test' 
    1
    It returned: 0
    $

It might print 1 as a side effect, the expression returns 0.

\\ What is perl actually performing here?

It evaluates the LHS of "and", finds it to be true, and hence evaluates
the RHS, returning that value as the return value.



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: 28 Aug 2000 20:17:34 GMT
From: abigail@foad.org (Abigail)
Subject: Re: quickie obfuscation...
Message-Id: <slrn8qli5e.bbg.abigail@alexandra.foad.org>

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> wrote:
\\ 
\\ >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.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Mon, 28 Aug 2000 20:52:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: quickie obfuscation...
Message-Id: <sqlk99jqt91111@corp.supernews.com>

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.

Make sense?

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


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

Date: Mon, 28 Aug 2000 14:12:46 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: quickie obfuscation...
Message-Id: <39AAD5CE.52B809DF@la.znet.com>

Craig Berry 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.
 
> Make sense?


* 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.

Godzilla!


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

Date: 28 Aug 2000 18:35:10 GMT
From: abigail@foad.org (Abigail)
Subject: Re: selling perl to management
Message-Id: <slrn8qlc5b.bbg.abigail@alexandra.foad.org>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDLIV September
MCMXCIII in <URL:news:slrn8qkh0d.3fr.mgjv@martien.heliotrope.home>:
--
-- But, Perl is very good at pointing out where things break. Of course, if
-- the syntax is still acceptable, but the runtime effects are severely
-- different, that would be bad. However, has that ever happened? Without a
-- warning?  And perldelta does tell us about things.

Yes, it has happened. It happens over and over again. Here's a recent example:

    $ perl5.00503 -wle 'print 80.101.114.108'
    80.101114.108
    $ perl5.6.0   -wle 'print 80.101.114.108'
    Perl
    $

I'd call that severely different run time effects. And no, no warnings
or deprecation cycle. The different run time effects are due to a change
in _syntax_.

Here's another. Also, no warning, not even a mentioning in perldelta.

    $ perl5.00503 -le 'sub AUTOLOAD {print $AUTOLOAD} *foo = *bar; foo ()'
    main::bar
    $ perl5.6.0.  -le 'sub AUTOLOAD {print $AUTOLOAD} *foo = *bar; foo ()'
    main::foo
    $

And in case you are not satisfied yet:

    $ perl5.00503 -le 'sub CHECK {print "foo"} if (1) {print "bar"; CHECK}'
    bar
    foo
    $ perl5.6.0   -le 'sub CHECK {print "foo"} if (1) {print "bar"; CHECK}'
    foo
    bar
    $

--                                                    Yes, Perl upgrades
-- change some things, but no more than anything else (upgrades of other
-- languages, compilers, interpreters), and not in a dangerous way, and
-- always with as much care as reasonable for the backward compatibility.

Please, you sound as unfounded as Godzilla. Recently, I went for
interviews with a very large company, who uses Perl in many critical
mission applications. Perl is the number 1 language for anything developed
in house. They are only to start rolling out 5.005 now, because of all
the things that break for each new version of Perl. The have a full time
position for managing Perl installation and upgrades.

Dismissing any changes as "they are not dangerous" or "other software
changes as well" isn't going to make you win friends with the people who
suffer from their programs breaking on new versions of Perl.

-- > keep in mind that documentation does not say which features are
-- > "obscure", which are basic.  There *should* be a subset defined which is
-- > guarantied to stay put.
--
-- Yes. I do agree with you on this point. Although it will be hard to
-- define that subset. Operators, precedence, keywords, syntax. That would
-- probably limit it for Perl.. Even variables have changed over the
-- versions. However, if a standard could be written that would be broken
-- in two parts: An immutable core, and the rest, maybe some
-- future-proofness can be found. 

But the syntax did change without warning between 5.005 and 5.6.0. See
my first example. And new "keywords" did get added in 5.6.0, as my third
example shows.

-- But don't forget that C and C++ have had changes to core features in the
-- languages.[1]

Sure. But as often and with as severe effects as in Perl? If so, please
cite the change and give an example.

-- Just think of all the stuff we're still carrying around in the language,
-- that no one really uses anymore, but that's solely there so Perl 4
-- scripts, and in some cases Perl 3 and older scripts, still run, or can
-- run with minimal changes. You must have personally spent quite a bit of
-- work in making sure that certain things didn't break when new features
-- came in.

Yes, and that shows that the "but that will break older programs" argument
you've heard on p5p is partly used as a political argument to oppose a 
proposed change people don't like. Sure, it's sincerely used to prevent
removal of parts of the language, like ancient relics, but there's so
much that changes that this rule is far from holy.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


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

Date: 28 Aug 2000 18:48:35 GMT
From: abigail@foad.org (Abigail)
Subject: Re: selling perl to management
Message-Id: <slrn8qlcuj.bbg.abigail@alexandra.foad.org>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDLIV September
MCMXCIII in <URL:news:slrn8qkjlo.3fr.mgjv@martien.heliotrope.home>:
## On 28 Aug 2000 06:49:00 GMT,
## 	Abigail <abigail@foad.org> wrote:
## > Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDLIII September
## > MCMXCIII in <URL:news:slrn8qhskl.3fr.mgjv@martien.heliotrope.home>:
## > ,, 
## > ,, But I can turn the argument around again. No standard out there
## > ,, guarantees anything either. And again I can point to the java language
## > ,, as well as the C language standards, and the various Unices. They change
## > ,, too when necessary. No standard will stop that. What a standard does is
## > ,, formalise what a given application should behave like during the
## > ,, lifetime of that standard. It does hardly ever guarantee anything about
## > ,, how long that lifetime is.
## > 
## > C and Unix don't change in the same way as Perl does. You can't compare
## > that.  And standardization does chance things. I've noticed a certain
## 
## I happen to think they can be compared. Especially C and Perl can be
## compared. They have differences, but also many things in common. The
## main difference is that C has standard, and Perl doesn't. However, the
## C standard, or rather, the various C standards, have never guaranteed
## any backward compatibility. In reality, of course, it is a major
## concern, but it is also a mjor concern for a new release of Perl.

Really? Is there active development in the C language, adding lots and
lots of features to the core every 18 to 24 months as Perl does?

## > behaviour change between 5.005 and 5.6.0. When I submitted a bugreport
## > for that, the only reply I got was "I don't know whether that's a bug or
## > a bugfix".  With a standard, you could at least determine whether the old,
## > or the new behaviour is "correct". Now, a patch could have an unintended
## > side effect that changes some behaviour, and without a standard, it's
## > not always possible to say that the side effect is a bug or a feature.
## 
## I concede that. A standard would give one a reference. But that wasn't
## exactly the point at hand. If the standard for Perl would have changed
## between 5.005 and 5.6.0[1], and it would have specified the new
## behaviour, you would also have no leg to stand on. Or if the standard
## leaves things open, or optional (undefined or inspecified in the C
## standards), you can also not rely on it. If Perl _had_ a standard, at
## least you would _know_ whether or not something was meant to be as it
## is, or is a fluke.

The point of standards is of course not that you change it willy-nilly
to match whatever todays implementation of your software does. Netscape
might work that way, but sensible people don't. The point of having a
standard is that you can't break something by accident and then say "oh,
well, who cares". If you break something, you not only have to patch the
source, you also have to change the standard. Changing a standard ought
to be a big hurdle.

## But, I do agree that a standard is wanted. I agree that a standard would
## be good. I just don't think that a standard would protect you from
## changes in an absolute way. (In a parallell post to this one, I also
## state that I don't believe Perl is ready for a standard anyway, unless
## you want the standard to change a few times over the next few years).

Safety belts don't protect you from being killed in an absolute way either.
That doesn't mean wearing them reduces the chance of being killed.

## > ,, Yes, obscure things broke. Abigail had one or two things break in her
## > ,, one-liners againts 5.6.0. Most things will keep working. Hardly any
## > ,, production code that has been written for maintainability breaks.
## > 
## > Really? I had everything that used dbmfiles break. I wouldn't want to
## 
## I didn't know about that. I hardly ever use dbm files myself, and hadn't
## actually seen anything about this (been away for a while from clpm).
## Was this a deliberate change, or a bug?

Beats me. Submitted a bug report, never heard back again.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


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

Date: 28 Aug 2000 21:24:39 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: selling perl to management
Message-Id: <8oelan$qul$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn8qkh0d.3fr.mgjv@martien.heliotrope.home>:
> > Yes it does.  As a minimum, it guarantees a level ground for
> > discussions of backward compatibility.
> 
> Maybe, but it does not guarantee that backward compatibility is
> maintained when the language changes, i.e. a new standard is going to be
> written. [...] I don't even
> believe that, in the case of perl, a standard would be a better
> guarantee than the discussions that p5p goes through now. pretty
> conservative crowd over there :)

Looks like you consider standard as a goal by itself.  I consider it
only as a supplement to the good will of p5p.  [Let us put aside the
topic that this good will is seriously jeopardized by the perl6 mania.]

> > If in a 2000-line-long script/module only 0.1% of lines broke (and you
> > do not know which), your argument does not quiet the worries.  And
> 
> But, Perl is very good at pointing out where things break. Of course, if
> the syntax is still acceptable, but the runtime effects are severely
> different, that would be bad. However, has that ever happened? Without a
> warning?

In my vague recollections, 1/3 of breakage is catched by
warnings/errors.  The rest is silent changes.

> That is not the way I meant it. Rephrase:
> 
> "I think you implied that Perl is the only language that changes,
> because it lacks a standard.  I have trouble with that statement."

I cannot argue with this.  But I do not see how existence of bad guys
frees us from responsibility to make Perl a better place to live.

> A standard will not protect Perl from change. It might formalise the
> change process, and maybe slow change down a bit more, but it won't
> stop change. It probably won't even guarantee any better backward
> compatibility than we have right now.

Protecting things from change is last objective I would have in mind.
And I said it many times, my opinion on influence of a Perl standard
on Perl backward compatibility is exactly the opposite.

> Just think of all the stuff we're still carrying around in the language,
> that no one really uses anymore, but that's solely there so Perl 4
> scripts, and in some cases Perl 3 and older scripts, still run, or can
> run with minimal changes. You must have personally spent quite a bit of
> work in making sure that certain things didn't break when new features
> came in.

You need to do it anyway.  But the line between features and bugs is
not demarcated yet.  There is no firm ground for
backward-compatibility police.  There is no firm ground for developers
of radical enhancements.

> If Perl had the same age as for example C, I would probably agree with
> you that it was time for a standard that nailed it down, to the same
> degree that the ISO C99 standard defines C.

How old was C when ISO C was accepted?  [And I repeat that I'm not
for nailing things down.  I'm for a layering things down: this is how
Perl works, and this is how the current verion of Perl works.
Currently all of the documentation is in the latter category.]

> Perl was a glue language. it is now a full programming language.

It *is advertised* as such.  IMO it hardly *is* yet.  But it is quite
close.  Most probably *all* that is needed is to abandon the current
joke of documentation.  Well-designed layered (on the level of
bizzareness - and the level of preparation of the reader. which may be
the same ;-) documenation, and pragmas which enable features
layer-by-layer would radically change how people use Perl.

> Furthermore, some other reasons that I do not think that Perl is ready
> for a standard: The core features of perl are still very much focused on
> Unix operating systems, and some things in the language (mainly builtin
> functions) still express this. It needs to get rid of these things.

*Needs*?  I see no *need* for this.  Most unixisms map well into how
contemporary OSes do things (with an exception of fork/exec, which is
not *needed* for Perl).  As far as you not suppose that flock() is
mandatory-only, or advisory-only, these unixisms provide a convenient
language to speek about problem-solving.

And if you want more control that *nix gives you, you may want
OS-specific extensions...

Ilya


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

Date: 28 Aug 2000 21:37:36 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: selling perl to management
Message-Id: <8oem30$r6o$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Abigail
<abigail@foad.org>],
who wrote in article <slrn8qk7ag.bbg.abigail@alexandra.foad.org>:
> Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MMDLIV September
> MCMXCIII in <URL:news:8od5ei$bs7$1@charm.magnus.acs.ohio-state.edu>:

[No, my september was not in 1JC.]

> == > I had things
> == > break in one liners that up till 5.6.0 I would not have hesitated to
> == > use in production code. (map {$_ .= "a"} "b" broke). A chance that,
> == > as far as I can tell, had no other justification than making Perl more
> == > "orthogonal" - quite a non-Perl thing to do.

>     $ perl5.00503 -wle 'sub a {map {chop} ABC} print a'
>     C
>     $ perl5.6.0   -wle 'sub a {map {chop} ABC} print a'                  
>     Modification of a read-only value attempted at -e line 1.
>     $

"I would not have hesitated to use in production code."  Wow.  And it
never worked...

  perl5.00503 -wle 'sub a {map {chop} ABC} print a; print a'
  C
  B

Enough said,
Ilya


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

Date: 28 Aug 2000 21:46:15 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: selling perl to management
Message-Id: <8oemj7$rbm$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was NOT sent to Martien Verbruggen
<mgjv@tradingpost.com.au>],
who wrote in article <slrn8qkjlo.3fr.mgjv@martien.heliotrope.home>:
> > ,, Yes, obscure things broke. Abigail had one or two things break in her
> > ,, one-liners againts 5.6.0. Most things will keep working. Hardly any
> > ,, production code that has been written for maintainability breaks.
> > 
> > Really? I had everything that used dbmfiles break. I wouldn't want to
> 
> I didn't know about that. I hardly ever use dbm files myself, and hadn't
> actually seen anything about this (been away for a while from clpm).
> Was this a deliberate change, or a bug?

I would suspect AnyDBM.  It being "a cool hack" (in the same category
as fork/exec paradigm, or other DWIMisms), I understood only recently
how dangerous it is.  [And I think I've never seen this danger mentioned.]

Say, on our Solaris network we do not have DB_File installed.  And now
we would not be able to install it, lest all the scripts using AnyDBM
break...

Ilya


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

Date: Mon, 28 Aug 2000 12:52:08 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: turn characters into meta characters
Message-Id: <MPG.141462c07154449c98ace9@nntp.hpl.hp.com>

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

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


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

Date: Mon, 28 Aug 2000 20:34:44 GMT
From: aaronp243@my-deja.com
Subject: Re: turn characters into meta characters
Message-Id: <8oeid3$2l4$1@nnrp1.deja.com>

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

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

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

my $string = 'asdf\nsdfg\t\xwrt';
$string =~ s/([\\][a-z])/escape($1)/eg;
print $string;


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


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

Date: Mon, 28 Aug 2000 21:11:54 +0100
From: "Tazz" <y2jagar@icqmail.com>
Subject: Unclosed HTML Tags
Message-Id: <RGzq5.5228$EB2.117717@news2-win.server.ntlworld.com>

This is a multi-part message in MIME format.

------=_NextPart_000_001E_01C01134.978018A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi.
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?

Thanks


------=_NextPart_000_001E_01C01134.978018A0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2><FONT face=3D"Times New Roman" =
size=3D3>Hi.<BR>I have a=20
news Perl scrpt im working on, a user fills out a form, submits<BR>it, =
and then=20
it is later displayed with all the news items on one page,<BR>the =
problem is=20
this: if someone forgets to close an HTML tag in their<BR>post (they use =

&lt;b&gt; but forget to add the &lt;/b&gt; end tag) it makes =
the<BR>entire page=20
bold.<BR><BR>Beyond the obvious of adding "&lt;/B&gt; &lt;/i&gt; =
&lt;/A&gt;=20
&lt;/H1&gt; &lt;/small&gt;" etc to the<BR>end of each post, how can I =
deal with=20
this problem? Is there a<BR>fixallhtml( )=20
function?<BR><BR>Thanks</FONT><BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_001E_01C01134.978018A0--



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

Date: Mon, 28 Aug 2000 21:02:04 GMT
From: rschram@reed.edu
Subject: Re: Using a LoL to store multiline records
Message-Id: <8oejvv$4iu$1@nnrp1.deja.com>

Thanks to all that replied in various ways about my post on how to use
the $/ special variable:

The code now looks like this

#!/usr/bin/perl -w

$|=1;
$/="-30-\n";

use strict;

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

while (<DATA>) {        # Or, open(FILE, "/etc/pswd.txt"), as you like.
        my ($date,$title,$body) = split /\n/, $_;
        print "<b>$date:</b> $title<br>\n";
        print "$body<br><br>\n\n";
        last if $. == 3;
}

__DATA__
Field1.0
Field1.1
Field1.2
-30-
Field2.0
Field2.1
Field2.2
-30-
Field3.0
Field3.1
Field3.2
-30-
__END__

It was fun to play with the $/ variable. Now it's time to get serious.
If this were, say, a data file of little news briefs for a web page,
wouldn't it also be nice to write up a dumb form to process new
stories? Wouldn't it also be nice to take advantage of the latent
structure of the data fields (Date, Headline, and Body) rather than
artificially impose some nonsense about multiline records and hanging
the relevance of each entry on its position in the data file?

I have heard that there exists a DBD::CSV module for performing SQL
queries on arrays of comma (or whatever) separated values. I wonder if
I could just mimic a sort function along these lines, rather than mess
with a SQL statement.

#!/usr/bin/perl -w

use strict;
my %dates;
my @records;
my ($i, $j);

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

while (<DATA>) {

       push @records, [ split /:/, $_ ];

}

foreach $i (@records) {

      $dates{${$records[$i]}[0]} = $i;

}

my @newdates = sort keys %dates;

foreach $j (@newdates[0..2]) {

       print "${$records[$dates{$j}]}[0]: ${$records[$dates{$j}]}[1]\n"
       print "${$records[$dates{$j}]}[2]";

}

__DATA__
Field1.0
Field1.1
Field1.2
-30-
Field2.0
Field2.1
Field2.2
-30-
Field3.0
Field3.1
Field3.2
-30-
__END__


Not the prettiest, but I merely am posting to provoke, and maybe
generate some thoughts on ways of cross-referencing multidimensional
arrays. If I have a multidimensional array, is this a viable way to
turn the whole thing 90 degrees and examine the structure in terms of
fields, rather than records?


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


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

Date: Mon, 28 Aug 2000 22:04:05 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Win32 path with spaces
Message-Id: <juflqs8gkdo4bkglmkp7hpeaoahoop9qdn@4ax.com>

On Mon, 28 Aug 2000 12:19:07 -0400, "BobS" <sturdevr@yahoo.com> wrote:

> Hi,
> 
> I'm having a problem with spaces in win32 path names. Specifically:
> 
> system( 'C:/program files/windows nt/accessories/wordpad.exe',
> 'c:/sms/readme.doc' );

OT, but ok:

	system( '"C:/program files/windows nt/accessories/wordpad.exe"',
		'c:/sms/readme.doc' );

Like you do on the command line.

>      I've found that
> 
> system( 'c:\program~1\window~2\access~1\wordpad.exe', 'c:\sms\readme.doc' )
> 
> opens wordpad and displays the readme but I'm concerned the numerals in the
> DOS equivalent names may not be the same on all systems.

	my $short = Win32::GetShortPathName 
		'c:/program files/windows nt/accessories/wordpad.exe';

Look at the doc for the Win32 module.

Also NT doesn't have to be installed on C:, $ENV{SystemDrive} looks a
better drive to start the path.

-- 
Good luck,
Abe


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

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 4156
**************************************


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