[17418] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4838 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 7 21:10:43 2000

Date: Tue, 7 Nov 2000 18:10:22 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973649422-v9-i4838@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 7 Nov 2000     Volume: 9 Number: 4838

Today's topics:
    Re: Monitoring PIDs <davidmac@austin.rr.com>
    Re: Multiple fork()s? <jhscrimsher@uswest.net>
    Re: Multiple fork()s? (Martien Verbruggen)
    Re: OOP and information hiding <joe+usenet@sunstarsys.com>
    Re: OOP and information hiding (Damian Conway)
    Re: OOP and information hiding (Abigail)
    Re: OOP and information hiding (Abigail)
    Re: OOP and information hiding (Damian Conway)
    Re: OOP and information hiding (Damian Conway)
    Re: OOP and information hiding (Richard J. Rauenzahn)
    Re: OOP and information hiding (Richard J. Rauenzahn)
    Re: Passing args as references (Mark-Jason Dominus)
        percent-underscore: %_ <mcdonabNO@SPAMyahoo.com>
    Re: percent-underscore: %_ <wyzelli@yahoo.com>
    Re: percent-underscore: %_ <tim@ipac.caltech.edu>
    Re: percent-underscore: %_ <ianb@ot.com.au>
    Re: percent-underscore: %_ <jeffp@crusoe.net>
    Re: percent-underscore: %_ (Martien Verbruggen)
    Re: Problems executing Perl scripts in a shell (Jon Ericson)
        Pushing a hash on to a stack... (Christopher Burke)
    Re: Q: Getting program line number? <james@NOSPAM.demon.co.uk>
    Re: Q: Getting program line number? (Martien Verbruggen)
    Re: Quick Perl Question (Gwyn Judd)
    Re: Quick short easy question (Gwyn Judd)
    Re: read > find > run <jeff@vpservices.com>
    Re: read > find > run (John Stanley)
    Re: read > find > run <bcanning@netresults-media.co.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 08 Nov 2000 00:34:01 GMT
From: David McMullen <davidmac@austin.rr.com>
Subject: Re: Monitoring PIDs
Message-Id: <3A089E7B.3E1AD383@austin.rr.com>

Nick Condon wrote:
> 
> David McMullen wrote:
> 
> > $i = (system "ps -ef | grep find | grep -v grep")
> > print $i
> >
> > returns 0 while process is running and 256 when it is not running.
> > What is the best way to monitor the process.
> 
> Use backticks instead of system, that way $i will contain the STDOUT of your
> command instead of the system return code, which is what you are getting at
> the moment.
> 
> Or open with a pipe:
> open (INPUT, "ps -ef | grep find | grep -v grep |")
> 
> while (<INPUT>) {
>    # do something
> }
Thank you.  That is what I was missing!

davidmac


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

Date: Tue, 7 Nov 2000 15:24:40 -0800
From: "John S" <jhscrimsher@uswest.net>
Subject: Re: Multiple fork()s?
Message-Id: <8a0O5.3473$b5.237151@news.uswest.net>

unless I mis-understand, this will wait for a count of 1 to 200, not wait
until all children are dead.  I want to do a set number of forks (200), then
wait for all of them to die and then do another 200.

John

"Ilya Zakharevich" <ilya@math.ohio-state.edu> wrote in message
news:8u9r9g$r4n$1@charm.magnus.acs.ohio-state.edu...
> [A complimentary Cc of this posting was sent to John S
> Do not you need
>
>   do { wait for 1..200 } if $procCount % 200 == 0;
>
> ?
>
> Ilya




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

Date: Wed, 08 Nov 2000 01:33:42 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Multiple fork()s?
Message-Id: <slrn90hbbo.7ck.mgjv@verbruggen.comdyn.com.au>

[Please, in the future, post your reply after the text you reply to.
It's the comman practice on this group, and Usenet in general]

On Tue, 7 Nov 2000 15:24:40 -0800,
	John S <jhscrimsher@uswest.net> wrote:
> "Ilya Zakharevich" <ilya@math.ohio-state.edu> wrote in message
> news:8u9r9g$r4n$1@charm.magnus.acs.ohio-state.edu...
>> Do not you need
>>
>>   do { wait for 1..200 } if $procCount % 200 == 0;
>>
>> ?

> unless I mis-understand, this will wait for a count of 1 to 200, not
> wait until all children are dead.  I want to do a set number of
> forks (200), then wait for all of them to die and then do another
> 200.

It will wait() 200 times. The same number of times are you have
forked. That's what's needed. You could also do it through a signal
handler, see perlipc.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | You can't have everything, where
Commercial Dynamics Pty. Ltd.   | would you put it?
NSW, Australia                  | 


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

Date: 07 Nov 2000 18:36:18 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: OOP and information hiding
Message-Id: <m3n1fbe4nh.fsf@mumonkan.sunstarsys.com>

abigail@foad.org (Abigail) writes:

> But that's the problem, isn't it? It isn't in the language, for the
> safe guard to work, you have to rely on the interface.

I disagree. IMHO you rely on the documentation.  If you build a 
module and intend for it to be inherited, you should document 
the attributes you use, just as you would with public variables 
in any other OO language.  I would consider it a bug in the 
documentation otherwise.

If you are a good perl programmer and know how to make some
of these variables effectively nonpublic, fine.  IMHO you don't 
have to document these except for a comment in your code that 
lets future maintainers know that this attribute isn't for
public consumption. 

If you're not capable of doing this, and you use attributes 
in your module that you don't intend to support in your API, 
you should document them as bugs in *your* code, not perl's.

-- 
Joe Schaefer


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

Date: 7 Nov 2000 23:38:39 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and information hiding
Message-Id: <8ua3pv$4un$1@towncrier.cc.monash.edu.au>

abigail@foad.org (Abigail) writes:

   > Unless the implementation is totally irrelevant, it ain't OO. What Perl
   > calls OO is nothing more than ADTs with a fancy syntax.

By that argument, C++ isn't OO either, since it allows protected and 
public data members.

To be sure, all reasonable definitions of OO include the notion of
a language being able to enforce encapsulation. But only the most fascist
definitions *insist* on perfect enforcement. And here's the point: the
(very few) languages which do utterly enforce encapsulation are almost
impossible to write real code in!

The notion of absolute, unbreakable, inescapable encapsulation is a nice
theory, but a lousy practice. What most developers soon discover they
need is the *ability* to enforce encapsulation when it's appropriate.

And that's exactly what Perl, like most other OO languages, offers. 

Damian


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

Date: 7 Nov 2000 23:42:04 GMT
From: abigail@foad.org (Abigail)
Subject: Re: OOP and information hiding
Message-Id: <slrn90h4qc.na9.abigail@tsathoggua.rlyeh.net>

On 7 Nov 2000 19:52:06 GMT, Damian Conway (damian@cs.monash.edu.au) wrote in comp.lang.perl.misc <URL: news:<8u9mh6$g06$1@towncrier.cc.monash.edu.au>>:
++ cfedde@fedde.littleton.co.us (Chris Fedde) writes:
++ 
++    > In article <slrn90fvml.ctp.abigail@tsathoggua.rlyeh.net>,
++    > Abigail <abigail@foad.org> wrote:
++    > >
++    > >Perls way of implementing OO is actually anti-OO, as it gives the
++    > >user of the class (that is, the inheriting class) all the baggage
++    > >of the implementation. Precisely what OO is *NOT* supposed to do.
++    > >"Stick to the interface" should all that's needed to succesfully
++    > >use objects. But in Perl, it's "stick to the implementation".
++ 
++ With the deepest respect to Abagail, this is FUD.
++ 
++ There are very few object oriented languages in common use that 
++ actually allow you to inherit without knowing something of the
++ internals of the base classes, especially under multiple inheritance.
++ 
++ As "Perl Cookbook" demonstrated, the dreaded attribute name clash
++ problem is easily avoided (yes, very few modules bother to avoid it, but
++ that's laziness, not incapacity).
++ 
++ And yes, very few CPAN classes bother to encapsulate, but that's mainly 
++ a cultural phenomenon too: until my book came out, encapsulation was
++ vaguely frowned upon in the Perl world.
++ 
++ There's now Tie::Securehash that allows you to use hash-based objects
++ that *do* encapsulate attributes on a class-by-class basis, and also 
++ to avoid the name attribute collision problem. 
++ 
++ There's now Class::Contract that gives you declarative class
++ specification, strong encapsulation, no attribute collision, *and*
++ design-by-contract checking.
++ 
++ The tools are now there, and significantly, they've been written in pure
++ Perl! There's no point in blaming the language because people are either
++ too lazy or too acculturated to use them.


Yes, I am aware of that. But it still means the programmer has to do it
all, instead of the language, and every player has to play the same game.
If everyone is willing to play the same game, (including those whose code
I download from the net), I can even program OO in C.

That doesn't make C an OO language.

Perl lacks the glue to bind objects together. You can still build nice
things if everyone makes lego bricks; you can also make things together
with velcro, or by using bolts. But velcro doesn't stick to lego.
I better make lego bricks when I want to reuse someone else lego bricks,
and work hard if I also want to incorperate someones velcro.

I do blame the language for neither providing the glue, nor the shield.



Abigail


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

Date: 7 Nov 2000 23:48:58 GMT
From: abigail@foad.org (Abigail)
Subject: Re: OOP and information hiding
Message-Id: <slrn90h57a.na9.abigail@tsathoggua.rlyeh.net>

On Tue, 07 Nov 2000 18:27:22 GMT, Chris Fedde (cfedde@fedde.littleton.co.us) wrote in comp.lang.perl.misc <URL: news:<eQXN5.226$Bf7.189811200@news.frii.net>>:
++ In article <slrn90fvml.ctp.abigail@tsathoggua.rlyeh.net>,
++ Abigail <abigail@foad.org> wrote:
++ >
++ >Perls way of implementing OO is actually anti-OO, as it gives the
++ >user of the class (that is, the inheriting class) all the baggage
++ >of the implementation. Precisely what OO is *NOT* supposed to do.
++ >"Stick to the interface" should all that's needed to succesfully
++ >use objects. But in Perl, it's "stick to the implementation".
++ >
++ 
++ OK, I'll accept that hash as instance variable was short sighted.
++ What is the fix?  Is it even possible to fix things now?  Or will
++ fixing it break backward compatibility? Most of the CPAN classes
++ use this convention because that is what is recommended in the
++ documentation.   Can we simply re-write perltoot and perlbot to
++ encourage a safer technique?  Maybe we should adopt object as
++ closure as the recommended convention.


I don't think it's "fixable", for two reasons:
   -  It would break just too much code out there.
   -  People *like* the current mess; perhaps because it gives them
      a sensation of 'freedom'. Maybe for the same reason people
      like the lack of a string datatype in C: it gives them more
      freedom of implementing strings themselves.



Abigail


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

Date: 8 Nov 2000 00:06:40 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and information hiding
Message-Id: <8ua5eg$jb7$1@towncrier.cc.monash.edu.au>

abigail@foad.org (Abigail) writes:

>I do blame the language for neither providing the glue, nor the shield.

You might as well claim C++ is useless because it has no I/O. :-)

Perl gives you the *tools* to mix your own glue(s), and to forge your own
shield(s). I've built two such generic mechanisms in the last two years and
they're sitting on the CPAN waiting for anyone to use.

Nowadays you *can*, with virtually no extra effort, build fully encapsulated
classes (and class hierarchies). As I've pointed out, that people don't do
so is a *cultural* problem, not a defect in the language.

Damian


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

Date: 8 Nov 2000 00:16:13 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and information hiding
Message-Id: <8ua60d$elh$1@towncrier.cc.monash.edu.au>

   > You can still build nice things if everyone makes lego bricks; you can
   > also make things together with velcro, or by using bolts. But velcro
   > doesn't stick to lego. I better make lego bricks when I want to reuse
   > someone else lego bricks, and work hard if I also want to incorperate
   > someones velcro.

The alternative offered by every other OO language is to *only* have
lego, or *only* have velcro. Sure it's easier to write some types
of classes if everything is just a glorified struct, or if everything
is a list, but it's also appallingly limiting and frequently inefficient.

So languages that only offer One True Way To Do It end up accumulating
all manner of baroque ornaments (e.g. protected inheritance, or setq) to
allow real programmers to subvert the paradigm when they (inevitably)
need to.

The fault lies in the theory, not in the different ways that real
languages (including Perl!) must go about circumventing it in order
to get the job done.

Damian


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

Date: 8 Nov 2000 01:15:49 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: OOP and information hiding
Message-Id: <973646147.704156@hpvablab.cup.hp.com>

damian@cs.monash.edu.au (Damian Conway) writes:
>abigail@foad.org (Abigail) writes:
>
>   > Unless the implementation is totally irrelevant, it ain't OO. What Perl
>   > calls OO is nothing more than ADTs with a fancy syntax.
>
[...]
>
>And that's exactly what Perl, like most other OO languages, offers. 

My opinion, for what its worth:  Perl is OO by convention -- not by
language design.  [Sure, Perl offers some syntactic sugar to make the
conventions easier...]

Rich
-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: 8 Nov 2000 01:22:55 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: OOP and information hiding
Message-Id: <973646573.854522@hpvablab.cup.hp.com>

damian@cs.monash.edu.au (Damian Conway) writes:
>abigail@foad.org (Abigail) writes:
>
>>I do blame the language for neither providing the glue, nor the shield.
>
>You might as well claim C++ is useless because it has no I/O. :-)
>
>Perl gives you the *tools* to mix your own glue(s), and to forge your own
>shield(s). I've built two such generic mechanisms in the last two years and
>they're sitting on the CPAN waiting for anyone to use.

That sounds more like an OO Module, not an OO Language.

As I think Abigail alluded to, I could write OO conventions in C similar
to those in Perl -- does that make C OO?

>Nowadays you *can*, with virtually no extra effort, build fully encapsulated
>classes (and class hierarchies). As I've pointed out, that people don't do
>so is a *cultural* problem, not a defect in the language.

I think part of the argument lies in where you draw the line at "Perl --
The Language."  I don't consider the modules that provide OO conventions
to be part of "The Language."  I do consider it part of Perl.

Rich
-- 
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant     | I speak for me,     |   19055 Pruneridge Ave. 
Development Alliances Lab|            *not* HP |                MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014


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

Date: Wed, 08 Nov 2000 00:13:13 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Passing args as references
Message-Id: <3a089a99.713e$25a@news.op.net>
Keywords: childbear, drowse, portulaca, salmon

In article <YEZN5.64162$E85.1706259@news1.sttls1.wa.home.com>,
John <nobodyshere@com.home> wrote:
>How do you pass an argument as a reference to a function so you can actually
>modify the original variables value as opposed to a function value?

In Perl, function arguments are always passed by reference.

        sub set_to_37 {
          $_[0] = 37;
        }

        $x = 19;
        set_to_37($x);
        print $x, "\n";     # Prints 37



-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Tue, 7 Nov 2000 16:19:37 -0800
From: "Brian McDonald" <mcdonabNO@SPAMyahoo.com>
Subject: percent-underscore: %_
Message-Id: <f%0O5.174$8G5.87486@news.pacbell.net>


what is the formal perl name of the ("scratch") variable represented by %_?
i can't seem to locate this information in the perldocs.

plus, does anyone know how to use the symbols '%_' or '$_' in the search
string when searching the deja archives?

brian





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

Date: Wed, 8 Nov 2000 10:09:35 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: percent-underscore: %_
Message-Id: <Fc1O5.7$y5.2133@vic.nntp.telstra.net>

"Brian McDonald" <mcdonabNO@SPAMyahoo.com> wrote in message
news:f%0O5.174$8G5.87486@news.pacbell.net...
>
> what is the formal perl name of the ("scratch") variable represented
by %_?
> i can't seem to locate this information in the perldocs.

Since perlvar has no listing for %_ I don't know what you mean.

@_ holds parameters passed to subroutines and no other name is listed

$ARG

$_

The default input and pattern-searching space.

Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;




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

Date: Tue, 07 Nov 2000 17:40:24 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: percent-underscore: %_
Message-Id: <3A08AF08.5927FC43@ipac.caltech.edu>

Wyzelli wrote:
> 
> "Brian McDonald" <mcdonabNO@SPAMyahoo.com> wrote:
> >
> > what is the formal perl name of the ("scratch") variable represented by %_?
> > i can't seem to locate this information in the perldocs.
> 
> Since perlvar has no listing for %_ I don't know what you mean.

I don't know what %_ is either, but evidently it's real:

% perl -wle 'my %_'
Can't use global %_ in "my" at -e line 1, near "my %_"
Execution of -e aborted due to compilation errors.

So what is it?

--

-- Tim Conrow         tim@ipac.caltech.edu                           |


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

Date: Wed, 08 Nov 2000 11:33:10 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: percent-underscore: %_
Message-Id: <3A089F46.20397878@ot.com.au>

Tim Conrow wrote:

> I don't know what %_ is either, but evidently it's real:
>
> % perl -wle 'my %_'
> Can't use global %_ in "my" at -e line 1, near "my %_"
> Execution of -e aborted due to compilation errors.

I think you'll get this with any punctuation-mark variable, whether it has a
special meaning or not.

Regards,


Ian




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

Date: Tue, 7 Nov 2000 20:44:23 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: percent-underscore: %_
Message-Id: <Pine.GSO.4.21.0011072043170.11113-100000@crusoe.crusoe.net>

On Nov 7, Tim Conrow said:

>Wyzelli wrote:
>> 
>> "Brian McDonald" <mcdonabNO@SPAMyahoo.com> wrote:
>> >
>> > what is the formal perl name of the ("scratch") variable represented by %_?
>> > i can't seem to locate this information in the perldocs.
>> 
>> Since perlvar has no listing for %_ I don't know what you mean.
>
>I don't know what %_ is either, but evidently it's real:
>
>% perl -wle 'my %_'
>Can't use global %_ in "my" at -e line 1, near "my %_"
>Execution of -e aborted due to compilation errors.
>
>So what is it?

A punctuation variable held in the same typeglob as $_ and @_.  Such
variables do not belong to a package.  So, even though the variables %_
and @/ and %* aren't used by Perl, they're true globals and exist
everywhere.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/



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

Date: Wed, 08 Nov 2000 01:54:55 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: percent-underscore: %_
Message-Id: <slrn90hcjh.7ck.mgjv@verbruggen.comdyn.com.au>

On Tue, 07 Nov 2000 17:40:24 -0800,
	Tim Conrow <tim@ipac.caltech.edu> wrote:
> Wyzelli wrote:
>> 
>> "Brian McDonald" <mcdonabNO@SPAMyahoo.com> wrote:
>> >
>> > what is the formal perl name of the ("scratch") variable represented by %_?
>> > i can't seem to locate this information in the perldocs.
>> 
>> Since perlvar has no listing for %_ I don't know what you mean.
> 
> I don't know what %_ is either, but evidently it's real:

It's real because the symbol table entry with the name _ exists. It
has no special meaning to Perl, but you can use it if you want to.

[addition after supersede]
Actually, having thought a bit more about this... I'm not even sure
whether the typeglob really needs to exist, or whether the name itself
is treate specially by Perl. Anyone reading this who does know?
[end addition]

You can also use @., @1, @2, etc., %1, %2, etc., %& and all those nice
looking line noise variables. As long as perlvar doesn't mention
them, but does mention another 'type' of variable with the same name,
you can safely use them. Even under strict. The ones that perlvar does
mention may be subject to special treatment, so you can't always
treat them as a regular variable (or array, or hash).

The arrays might not always expand 'correctly' in double quotes, but
that can be fixed with {}.

#!/usr/local/bin/perl -l
use warnings;
use strict;

@& = @. = @1 = qw(a b c d);
print "@{&} @{.} @1";

%& = qw(a b c d);
print $&{$_} for keys(%&);

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Little girls, like butterflies, need
Commercial Dynamics Pty. Ltd.   | no excuse - Lazarus Long
NSW, Australia                  | 


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

Date: 7 Nov 2000 23:55:03 GMT
From: Jonathan.L.Ericson@jpl.nasa.gov (Jon Ericson)
Subject: Re: Problems executing Perl scripts in a shell
Message-Id: <8FE5A7BCDJonathanLEricsonjpln@137.78.50.25>

[posted and mailed]

On 02 Nov 2000, webm@minorisa.es (Josep Martínez) wrote:
>I've made a perl script and I can only execute in that way:
>$ perl script_name.pl
>
>I put the 'x' permission to the perl and the header of the script
>contain:
>#!/usr/bin/perl
>and I've checked that perl is in that directory.
>
>I want to execute the script with
>$ ./script_name.pl

Two questions:

Does ./script_name.pl have execute permision (not just perl itself)?

What error message does your shell output?

Jon


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

Date: 8 Nov 2000 01:57:05 GMT
From: craznar@hotmail.com (Christopher Burke)
Subject: Pushing a hash on to a stack...
Message-Id: <8FE677620craznar@130.102.2.1>

Can any perl experts emulate the following using the push/pop idea.

%{$fulldata[scalar @fulldata]} = %hash;


Basically I want to be able to do this sort of thing...

$hash{X} = 4;
$hash{Y} = 5;
# push %hash onto stack .....
$hash{X} = 4;
$hash{Y} = 5;
# push %hash onto stack .....
 .
 .
 .
print $fulldata[0]{X}."\n";
print $fulldata[0]{Y}."\n";
print $fulldata[1]{X}."\n";
print $fulldata[1]{Y}."\n";


And no - I don't want to use references.




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

Date: Wed, 8 Nov 2000 01:43:47 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Q: Getting program line number?
Message-Id: <ant080147f7ffNdQ@oakseed.demon.co.uk>

In article <Pine.GSO.4.21.0011071058280.25313-100000@crusoe.crusoe.net>,
Jeff Pinyan <URL:mailto:jeffp@crusoe.net> wrote:
>
> On Nov 7, James Taylor said:
> >
> >Is there a similar way to get the error line number when you have
> >wrapped a large chunk of code in an eval to trap errors?
> >$@ seems to only contain the error message without the line number.
> 
> Really?

Err, apparently not.

Everything I try locally fails to reproduce error messages in $@ that
DON'T have the line number, yet I am quite sure that scripts I have
running on a remote web server have produced messages that unhelpfully
do not have a line number. This was when using MIME::Entity to
construct an email, so perhaps it is the module's fault for not
propagating the line number in some way - I don't know. I'll do some
more tests to pin it down tomorrow, but it's late here in the UK so
I'm off to bed for now. Goodnight!

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Wed, 08 Nov 2000 01:59:44 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Q: Getting program line number?
Message-Id: <slrn90hcsj.7ck.mgjv@verbruggen.comdyn.com.au>

On Wed, 8 Nov 2000 01:43:47 +0000,
	James Taylor <james@NOSPAM.demon.co.uk> wrote:
> 
> Err, apparently not.
> 
> Everything I try locally fails to reproduce error messages in $@ that
> DON'T have the line number, yet I am quite sure that scripts I have
> running on a remote web server have produced messages that unhelpfully
> do not have a line number.

Maybe what you saw was the result of an explicit die() or warn() with
a message ending in a newline. In that case, perl will not append line
number information. All of perl's internal error messages include a
line number, AFAIK.

# perl -e 'die "Boo"'
Boo at -e line 1.
# perl -e 'die "Boo\n"'
Boo

The Carp.pm variants behave in the same way.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If at first you don't succeed,
Commercial Dynamics Pty. Ltd.   | destroy all evidence that you tried.
NSW, Australia                  | 


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

Date: Wed, 08 Nov 2000 02:03:06 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Quick Perl Question
Message-Id: <slrn90hd2o.hbr.tjla@thislove.dyndns.org>

I was shocked! How could dnay@vbs.net <dnay@vbs.net>
say such a terrible thing:

By the way, you should really pick a better subject for your question,
most people score down posts with words like 'question'. A more
descriptive title is more likely to work.

>Can anyone tell me how to check a string for any characters other than
>characters ie. a-z/A-Z and integers 0-9.
>
>like this:
>
>if ($text =~ /check for illegal chars here/) {

if ($text =~ tr/a-zA-Z0-9//c) {
if ($text =~ m/[^a-zA-Z0-9]/) {

>print error...
>
>}

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Better to light a candle than to curse the darkness.
-Chinese proverb


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

Date: Wed, 08 Nov 2000 02:04:41 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Quick short easy question
Message-Id: <slrn90hd5n.hbr.tjla@thislove.dyndns.org>

I was shocked! How could donoddy@my-deja.com <donoddy@my-deja.com>
say such a terrible thing:
>I would like to modify this line of my script:
>
>print "<A HREF=\"$advert_url\">";
>
>so it opens the link in a new window. Is this
>the correct way to do it:
>
>print "<A HREF=\"$advert_url\" target=\"_top\">";

Did you try it?

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Hear about...
	the guy who took a course in exotic lovemaking and announced that
	he'd never be able to face his girl again?


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

Date: Tue, 07 Nov 2000 15:12:39 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: read > find > run
Message-Id: <3A088C67.E863218D@vpservices.com>

Brian Canning wrote:
> 
> OK here is it, not no laughing, I'm not the best
> coder in the world

Your perl code is ok (although it could use some of the corrections I
suggested in an earlier posting).  It prints things in the correct order
and substitutes the comments as intended.

So, why does it appear to be out of order?  My guess is that you are not
printing your <TD> and </TD> tags correctly, possibly leaving off a
crucial </TD>.  Look at the HTML output of your script (using your
browser's View Source, or by running the script on the command line
instead of in a browser) and you will probably be able to spot where it
is going wrong.

Perl only does what you tell it to.  If you tell it to print incorrect
HTML, it will do that.

-- 
Jeff


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

Date: 7 Nov 2000 23:52:04 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: read > find > run
Message-Id: <8ua4j4$c42$1@news.NERO.NET>

In article <8u9ouu$lj6$1@news6.svr.pol.co.uk>,
Brian Canning <bcanning@netresults-media.co.uk> wrote:
>here is a bit of the HTML it reads in.
>
>      <TD WIDTH="25%"><FONT SIZE="+1">Type</FONT></TD>

Grrr. Another webmaster who thinks he knows better than the viewer what
font size is best. +1 isn't as bad as all the jerks who use -1 or 
-2 and leave the viewer with a three pixel high bit of text, or force
them to use hugh fonts for the rest of their page just so this bit of
text can be read.



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

Date: Wed, 8 Nov 2000 01:56:42 -0800
From: "Brian Canning" <bcanning@netresults-media.co.uk>
Subject: Re: read > find > run
Message-Id: <8uac0r$gfj$1@newsg3.svr.pol.co.uk>

GOT IT!!!!

Hi Jeff, you were right, what was happening as it read each line it,  if the
LINE
contained the <!--type--> then the hole line got replaced. so quick rethink
and this is what I came up with, I would be interested to know what you
think
as it works :)

and a quick message to John Stanley, what's your problem? there is nothing
wrong with
changing the font size of text, if there was then you wouldn't be able to do
it, it's
all part of web design you know.

Thanks for all your help Jeff, I hope one day I could return the favour.

#############
 # show form #
 #############

sub show_form {
 open (formfile, "add.htm") || die print "Oh my god, where is the form file
called add.htm";
 &create_types;
 &create_music;
 while (<formfile>) {
  s/<!--type-->/$types_list/;
  s/<!--music-->/$music_list/;
  print $_;
 }
}
 ################
 # create types #
 ################

sub create_types

 @types = split(/\|/,$types);
 foreach $type(@types){
    push (@types_list, "<input TYPE=\"RADIO\" NAME=\"type\"
value=\"$type\">$type<br>\n ");
 }
 $types_list = join(" ",@types_list);
}

 ################
 # create music #
 ################

sub create_music {
 @music_list = ("<TABLE border=0 CELLPADDING=2 CELLSPACING=5> \n<TR>\n<TD
VALIGN=TOP ALIGN=LEFT>");
 @musicT = split(/\|/,$musicT);
 $colcount = 0;
 $rowcount = 0;
 foreach $music(@musicT){
  if ($colcount == 10 ) {
   push (@music_list, "</TD><TD VALIGN=\"TOP\" ALIGN=\"LEFT\">");
   $colcount = 0;
   $rowcount++;
  }
  if ($rowcount == 3) {
   push (@music_list, "</TD></TR><TR><TD VALIGN=\"TOP\" ALIGN=\"LEFT\">");
   $rowcount = 0;
  }
  push (@music_list, "<INPUT TYPE=\"CHECKBOX\" NAME=\"music\"
value=\"$music\">$music<br>\n");
  $colcount++;
 }
 push (@music_list, "</TD></TR></TABLE>");
 $music_list = join(" ",@music_list);
}





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

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


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