[17961] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 121 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 22 18:05:51 2001

Date: Mon, 22 Jan 2001 15:05:12 -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: <980204711-v10-i121@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 22 Jan 2001     Volume: 10 Number: 121

Today's topics:
    Re: Assistance in Oz (David H. Adler)
        automatic login script jchampio@engin.umich.edu
    Re: automatic login script <ralawrence@my-deja.com>
        Behaviour of __PACKAGE__ inside eval <hugh@grugach.freeserve.co.uk>
    Re: Directory Recursion Problem. (Eric Bohlman)
    Re: Directory Recursion Problem. (Tad McClellan)
    Re: embedded perl in korn shell <jwl@sgi.com>
    Re: FAQ 9.15:   How do I decode a CGI form? <joehecht@code4sale.com>
    Re: FAQ 9.15:   How do I decode a CGI form? <joehecht@code4sale.com>
    Re: full-jeopardy, was Re: Directory Recursion Problem. (Abigail)
    Re: full-jeopardy, was Re: Directory Recursion Problem. <jdf@pobox.com>
    Re: full-jeopardy, was Re: Directory Recursion Problem. (Jon Bell)
    Re: full-jeopardy, was Re: Directory Recursion Problem. <juex@deja.com>
    Re: full-jeopardy, was Re: Directory Recursion Problem. (Martien Verbruggen)
    Re: immortal program : catching signals <epa98@doc.ic.ac.uk>
    Re: immortal program : catching signals (Abigail)
        Is there a fflush? <jwl@sgi.com>
    Re: Is there a fflush? (Abigail)
    Re: Is there a fflush? (Garry Williams)
    Re: Is there a fflush? <joe+usenet@sunstarsys.com>
    Re: Lint for perl? <tore@extend.no>
    Re: Lint for perl? (Martien Verbruggen)
    Re: Lint for perl? <ansel@babylon.dyndns.org>
    Re: matrix <mischief@velma.motion.net>
        MP3::Napster: Error when using filehandle for download <ralawrence@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 22 Jan 2001 20:14:12 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: Assistance in Oz
Message-Id: <slrn96p54k.bqv.dha@panix2.panix.com>

On Mon, 22 Jan 2001 15:06:19 +1100, Scott Freeman wrote:

>Apologies if this is an inappropriate forum, but I am desperately seeking
>perl programmers for numerous projects around Australia.

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently
to "news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

There is a Perl Jobs Announce list that may be more helpful to you.  See
<http://www.pm.org/mailing_lists.shtml> for details.

Yours for a better usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
If I ever saw this in real code I'd beat the author senseless with
their own limbs.
      - Michael G. Schwern


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

Date: Mon, 22 Jan 2001 19:12:07 GMT
From: jchampio@engin.umich.edu
Subject: automatic login script
Message-Id: <94i0lv$22e$1@nnrp1.deja.com>

I am writing a parallel computing script and need to be able to login to
remote computers without manually typing in my login and password.  Is
there a way have my script automatically login after it telnets into a
foreign host?  Thank you.


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 22 Jan 2001 19:26:20 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Re: automatic login script
Message-Id: <94i1gg$2qi$1@nnrp1.deja.com>

In article <94i0lv$22e$1@nnrp1.deja.com>,
  jchampio@engin.umich.edu wrote:
> I am writing a parallel computing script and need to be able to login
to
> remote computers without manually typing in my login and password.  Is
> there a way have my script automatically login after it telnets into a
> foreign host?  Thank you.

Use the Net::Telnet module - from the documentation for it:

use Net::Telnet ();
$t = new Net::Telnet (Timeout => 10, Prompt => '/bash\$ $/');
$t->open("sparky");
$t->login($username, $passwd);
@lines = $t->cmd("/usr/bin/who");
print @lines;

You can get it from CPAN.

Rich


Sent via Deja.com
http://www.deja.com/


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

Date: Mon, 22 Jan 2001 21:44:42 -0000
From: "Hugh Williams" <hugh@grugach.freeserve.co.uk>
Subject: Behaviour of __PACKAGE__ inside eval
Message-Id: <94i96o$q7f$1@news8.svr.pol.co.uk>

Hi,

I found this strange bit of behaviour related to __PACKAGE__ and eval. The
following bit of code:

$a=1;
package no2;
$a=2;
print __PACKAGE__."\n";
print "$a\n";
print "$main::a\n";
eval <<'--END--'; # note single quotes - no interpolation
print __PACKAGE__."\n";
print "$a\n";
print "$main::a\n";
--END--

produces this output

no2
2
1
main
2
1

so although the variable $a in the eval statement resolves in the expected
namespace, the __PACKAGE__ symbol itself is inaccurate. Can anyone explain
what is happening here?

Thanks

Hugh





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

Date: 22 Jan 2001 21:52:29 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Directory Recursion Problem.
Message-Id: <94ia2t$3r0$6@bob.news.rcn.net>

Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> I am going to killfile outlook express for good now. I'm just sick of
> the attitude that comes with it.

I've come to the conclusion that OE's problem is that it mindlessly
extends something that makes sense in one context into other contexts
where it doesn't make sense.  Jeopardy quoting is probably the most
socially acceptable way to reply to e-mailed business memos, particularly
ones coming from people above you in the hierarchy; the discourse there is
one of announcement rather than conversation, and in all but the most
enlightened organizations picking apart your boss's arguments
point-by-point isn't a smart career move.  So maybe it's an appropriate
default for a mail reader.  But Usenet discourse is almost always
conversational, which calls for interspersed quoting, and it makes no
sense for a *newsreader* to default to Jeopardy quoting.

It reminds me of all the trouble people had learning OS/360 job control
language because IBM implemented whitespace-handling rules that made no
sense for JCL simply to be consistent with the whitespace rules for
assembler code.



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

Date: Mon, 22 Jan 2001 22:35:06 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Directory Recursion Problem.
Message-Id: <slrn96p3b2.1pi.tadmc@tadmc26.august.net>

Sean Meisner <sdmeisner@SPAMGUARDyahoo.com> wrote:
>> It is _not_ efficient to top-post. It is only efficient for _you_. It is
>> inefficient when seen in the larger context of the newsgroup. It is
>> selfish to call something that saves you three seconds but costs
>> hundreds of other people more than three seconds efficient.
>>
>> If you had read the group a littlebit before posting, then you wouldn't
>> have needed this personal explanation about why top posting in this
>> group is discouraged. You would have known, because we rehash this same
>> argument several times a week.
>>
>> I am going to killfile outlook express for good now. I'm just sick of
>> the attitude that comes with it.


I did that 3 days ago.


>> Martien
>> --
>> Martien Verbruggen              |
>> Interactive Media Division      | I took an IQ test and the results
>> Commercial Dynamics Pty. Ltd.   | were negative.
>> NSW, Australia                  |
>
>LOL!!!  
 ^^^
 ^^^
>Chill out guy, it was just a little joke, 


If you had lurked here a bit before posting, you would have known
that we get morons here twice a week busting in and telling us
we're not doing it right, and how we should do it from now on.

Joking like you are one of the morons too is asking for a case
of mistaken identity. The danger here is that most scorefile
entries are permanent. Once you get in there, you stay there.


>and I complied with the
>request.

Thank you.

>Sheesh.. who pissed in your cornflakes this morning??  :o)


Oh! You had almost made it past the scorefile minefield!

But now you went and did it. You have a personal entry now, on top
of the -6000 your posts had to begin with.

   % broken tools
   Score:: -1000
           X-Newsreader: Microsoft Outlook Express

   % mungers
   Score:: -5000
           From: @.*spam


Top posting (though you have fixed that at least)

Quoting with no attribution.

Quoting .sigs

No lurking before posting.

Snippety attitude with newsgroup regulars.

You've pushed all of your future posts into oblivion. 

Hope you found your LOL entertaining, seems a bit expensive to me...


You should have lurked first.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 22 Jan 2001 15:47:24 -0500
From: Jim Lynch <jwl@sgi.com>
Subject: Re: embedded perl in korn shell
Message-Id: <3A6C9C5C.A3C4B345@sgi.com>

This isn't a perl problem. 

Try :
export MYVAR=xyz
 
perl<<\eof
 
print $ENV{MYVAR};
 
eof

j355@my-deja.com wrote:
> 
> I am trying to pass environment variables, defined in a korn shell,
> into a perl script within the korn shell script.  I keep getting a perl
> compiler error: syntax error at line 2, near "};"
> 
> Any ideas?
> 
> For example:
> 
> #################
> export MYVAR=xyz
> 
> perl<<eof
> 
> print $ENV{MYVAR};
> 
> eof
> #################
> 
> Sent via Deja.com
> http://www.deja.com/


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

Date: Mon, 22 Jan 2001 22:28:19 GMT
From: "Joe C. Hecht" <joehecht@code4sale.com>
Subject: Re: FAQ 9.15:   How do I decode a CGI form?
Message-Id: <7u2b6.1617$716.184684@paloalto-snr1.gtei.net>

> *ploink*
>
> Consider your opinion judged.

I just love it when folks have to publically
waste bandwidth to show themselves adding
to the  killfile.

The plot gets thicker when the next message
they post is a reply to the person they just
claimed to have killfiled!!!!

So, I guess you just proved that you cannot
be believed or taken seriously.

BTW, I really dont wish to continue this
childishness you started. Lets just pretend
you relly did killfile me, and there is no
reason to reply, as you really cant see
this [wink]

Joe





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

Date: Mon, 22 Jan 2001 23:01:23 GMT
From: "Joe C. Hecht" <joehecht@code4sale.com>
Subject: Re: FAQ 9.15:   How do I decode a CGI form?
Message-Id: <7Z2b6.1643$716.195159@paloalto-snr1.gtei.net>


> >> So you'd both rather keep your own unreviewed bugs, than have a whole
> >> team of specialist volunteers world-wide working on submitting fixes
> >> to the author, without any particular effort on your part?  Strange.
> >
> >volunteer specialists??? Where?
>
> Ever heard of open-source code? Linux? Apache? Sendmail? BIND? Perl? CPAN?
> Every one of them built by volunteer specialists.

You are saying that if your publish some source code, that alone qualifies
you to be a
volunteer specialist?

So, you say your team of volunteer specialists will work on my code and root
out the
bugs. Is the quality the same as say... the faqs on decoding a CGI form???
If so, thanks
for the offer, but I think I will pass....

Also, I would like to address your comment on my keeping my "own unreviewed
bugs".
How do you know thier are bugs? How do you know they are unreviewed? How
do you know the QA testing done here is not better than the QA testing done
by
your team of volunteer specialists?

Truth is, anyone can be a specialist. I have been paid to do technical
reviews of
books and articles published by specialists, and have found many bugs and
errors
provided by these specialists.

 I love the "Perl 5 by example" book that is chock full of specialist talk
like,
on page 57 (in the section where he discusses the bitwise operators) the
author admits he has never found the "COMPLEMENT" operator usefull
so he will skip providing an example. What a idiot.

Finally,  your only argument for my using your team of volunteer specialists
is
really a plan to get my source code for free. Sorry, not a chance.

[off topic - Hey Nick! You just claimed to have killfiled me a few minutes
ago.
Why are you replying? Did your killfile overflow or something?]

Joe




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

Date: 22 Jan 2001 19:41:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: full-jeopardy, was Re: Directory Recursion Problem.
Message-Id: <slrn96p372.n3.abigail@tsathoggua.rlyeh.net>

Alan J. Flavell (flavell@mail.cern.ch) wrote on MMDCCI September MCMXCIII
in <URL:news:Pine.LNX.4.30.0101221918080.15660-100000@lxplus003.cern.ch>:
~~ On Tue, 23 Jan 2001, Martien Verbruggen wrote:
~~ 
~~ > I am going to killfile outlook express for good now.
~~ 
~~ Well, that's one approach, for sure.  But OE's not the only offender
~~ when it comes to upside-down quoting; and I'm told that it can be used
~~ to post properly (the alt.usage.english group's FAQ even has some
~~ helpful words about how to do it).
~~ 
~~ I think I'd rather kill on the upside-down quoting, than on the client
~~ header.

Been there, done that. I've close to 700 people in my killfile, most of
them for upside-down quoting. After thinking about it for months, I too
decided to permanently killfile Outlook Express; best thing I did for my
score file in years. For two weeks, I low scored it. I noticed I now miss
one or two regulars, but I also miss a lot of Jeopardy postings, FAQs,
and questions whose answers are trivially found in the documentation.

It's a small price to pay to get rid of a lot of lusers - leaving me 
more time to read more interesting groups (and where the usuage of 
outhouse express is almost non-existant).

But you are right, it isn't the only offender; Mozilla might be the next
one that's going to be killed.



Abigail
-- 
:$:=~s:$":Just$&another$&:;$:=~s:
:Perl$"Hacker$&:;chop$:;print$:#:


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

Date: 22 Jan 2001 15:25:18 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: abigail@foad.org
Subject: Re: full-jeopardy, was Re: Directory Recursion Problem.
Message-Id: <bsszxrkh.fsf@pobox.com>

abigail@foad.org (Abigail) writes:

> I noticed I now miss one or two regulars, but I also miss a lot of
> Jeopardy postings

Jeopardy?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Mon, 22 Jan 2001 20:26:38 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: full-jeopardy, was Re: Directory Recursion Problem.
Message-Id: <G7KzGE.3GL@presby.edu>

In article <bsszxrkh.fsf@pobox.com>, Jonathan Feinberg  <jdf@pobox.com> wrote:
>abigail@foad.org (Abigail) writes:
>
>> I noticed I now miss one or two regulars, but I also miss a lot of
>> Jeopardy postings
>
>Jeopardy?

After the TV quiz show in which you see the answers before the questions.

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA



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

Date: Mon, 22 Jan 2001 12:54:29 -0800
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: full-jeopardy, was Re: Directory Recursion Problem.
Message-Id: <3a6c9e04$1@news.microsoft.com>

"Jonathan Feinberg" <jdf@pobox.com> wrote in message
news:bsszxrkh.fsf@pobox.com...
> abigail@foad.org (Abigail) writes:
>
> > I noticed I now miss one or two regulars, but I also miss a lot of
> > Jeopardy postings
>
> Jeopardy?

First you read the answer, and then you find out what the question was.
Quite irritating unless you are a training for the TV quiz show with the
same name.

May i recommend reading one of the many *.newuser.* NGs?

jue




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

Date: Tue, 23 Jan 2001 08:22:55 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: full-jeopardy, was Re: Directory Recursion Problem.
Message-Id: <slrn96p95f.meu.mgjv@martien.heliotrope.home>

On Mon, 22 Jan 2001 12:54:29 -0800,
	Jürgen Exner <juex@deja.com> wrote:
> "Jonathan Feinberg" <jdf@pobox.com> wrote in message
> news:bsszxrkh.fsf@pobox.com...
>> abigail@foad.org (Abigail) writes:
>>
>> > I noticed I now miss one or two regulars, but I also miss a lot of
>> > Jeopardy postings
>>
>> Jeopardy?
> 
> First you read the answer, and then you find out what the question was.
> Quite irritating unless you are a training for the TV quiz show with the
> same name.
> 
> May i recommend reading one of the many *.newuser.* NGs?

heh :)

I don't believe Jonathan needs to read that :) The term 'jeopardy
posting' is actually quite local to clp.misc and hasn't been around for
that long. Most other places seem to refer to it as upside-down posting,
or something like that. Whatever you call it, it's bloody annoying.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Freudian slip: when you say one thing
Commercial Dynamics Pty. Ltd.   | but mean your mother.
NSW, Australia                  | 


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

Date: 22 Jan 2001 17:43:32 +0000
From: Edward Avis <epa98@doc.ic.ac.uk>
Subject: Re: immortal program : catching signals
Message-Id: <xn91ytvzdmj.fsf@sync28.doc.ic.ac.uk>

vivek@cse.iitd.ernet.in writes:

>i wanna write a perl script which will run on X (linux) with root
>owner....i want that a user should not be able to kill the script.....i
>tried using %SIG for the same...but crossing out the window kills the
>signal....

Do you mean that the user can close the window?  There's not a lot you
can do about that, AFAIK.  The best bet is to run your program without
its own window, but provide some sort of 'viewer' which can be opened
and closed without affecting the main program.  This isn't really a
Perl question.

I wrote something in Perl which runs at the gdm login screen, in its
own Eterm window.  There is no window manager running at that time, so
it cannot be closed, and I used %SIG to catch anything else like
Ctrl-C.  The latest Eterms have an option to ignore all keyboard and
mouse input (but of course that doesn't stop the window manager
closing it).

-- 
Ed Avis
epa98@doc.ic.ac.uk


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

Date: 22 Jan 2001 20:29:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: immortal program : catching signals
Message-Id: <slrn96p61t.n3.abigail@tsathoggua.rlyeh.net>

Edward Avis (epa98@doc.ic.ac.uk) wrote on MMDCCI September MCMXCIII in
<URL:news:xn91ytvzdmj.fsf@sync28.doc.ic.ac.uk>:
__ vivek@cse.iitd.ernet.in writes:
__ 
__ >i wanna write a perl script which will run on X (linux) with root
__ >owner....i want that a user should not be able to kill the script.....i
__ >tried using %SIG for the same...but crossing out the window kills the
__ >signal....
__ 
__ Do you mean that the user can close the window?  There's not a lot you
__ can do about that, AFAIK.  The best bet is to run your program without
__ its own window, but provide some sort of 'viewer' which can be opened
__ and closed without affecting the main program.  This isn't really a
__ Perl question.
__ 
__ I wrote something in Perl which runs at the gdm login screen, in its
__ own Eterm window.  There is no window manager running at that time, so
__ it cannot be closed, and I used %SIG to catch anything else like
__ Ctrl-C.  The latest Eterms have an option to ignore all keyboard and
__ mouse input (but of course that doesn't stop the window manager
__ closing it).


What is the point? If you do catch SIGINT and SIGTERM, and exit
gracefully, you know you don't leave a mess behind. If you simply ignore
SIGINT and SIGTERM, the user sends a SIGKILL, and your process is dead;
without a chance to catch the signal and do something.


Abigail
-- 
print v74.117.115.116.32, v97.110.111.116.104.101.114.32,
      v80.101.114.108.32, v72.97.99.107.101.114.10;


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

Date: Mon, 22 Jan 2001 15:40:00 -0500
From: Jim Lynch <jwl@sgi.com>
Subject: Is there a fflush?
Message-Id: <3A6C9AA0.D4AF991F@sgi.com>

I'm using Perl on a Unix system and know about $|, but I'm trying to
write a log file to other than standard out and would dearly love to
have an fflush function.  I don't see it in the documents that I have
anywhere.  I'd sure like to be able to tail -f the log file to get an
idea where the program is at any given time.  Does anyone have any
suggestions?

Thanks,
Jim.


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

Date: 22 Jan 2001 20:56:24 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Is there a fflush?
Message-Id: <slrn96p7jo.n3.abigail@tsathoggua.rlyeh.net>

Jim Lynch (jwl@sgi.com) wrote on MMDCCI September MCMXCIII in
<URL:news:3A6C9AA0.D4AF991F@sgi.com>:
\\ I'm using Perl on a Unix system and know about $|, but I'm trying to
\\ write a log file to other than standard out and would dearly love to
\\ have an fflush function.  I don't see it in the documents that I have
\\ anywhere.  I'd sure like to be able to tail -f the log file to get an
\\ idea where the program is at any given time.  Does anyone have any
\\ suggestions?


Are you sure you know about $|?


Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: Mon, 22 Jan 2001 21:02:24 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Is there a fflush?
Message-Id: <Ad1b6.36$BQ1.1633@eagle.america.net>

On Mon, 22 Jan 2001 15:40:00 -0500, Jim Lynch <jwl@sgi.com> wrote:
>I'm using Perl on a Unix system and know about $|, 

But, you don't -- judging from the following... :-)  

>but I'm trying to
>write a log file to other than standard out and would dearly love to
>have an fflush function.  

Check perlvar and then select FILEHANDLE in perlfunc.  You want
something like: 

  $old_cur = select($fh);
  $| = 1;
  select($old_cur);

-- 
Garry Williams


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

Date: 22 Jan 2001 16:03:27 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Is there a fflush?
Message-Id: <m34ryrs3j4.fsf@mumonkan.sunstarsys.com>

Jim Lynch <jwl@sgi.com> writes:

> I'm using Perl on a Unix system and know about $|, but I'm trying to
> write a log file to other than standard out and would dearly love to
> have an fflush function.  I don't see it in the documents that I have
> anywhere.  I'd sure like to be able to tail -f the log file to get an
> idea where the program is at any given time.  Does anyone have any
> suggestions?
> 

Seems you don't know $| as well as you think.

% man perlvar

  $|      If set to nonzero, forces a flush right away and
          after every write or print on the currently
          selected output channel.  
 ...


Hence select()'ing the logfile's filehandle and then setting $| should
do what you want; or else try an OO method like autoflush() on a 
filehandle object.

For details, see

% perldoc -f select

% man IO::Handle
% man FileHandle


HTH
-- 
Joe Schaefer



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

Date: Mon, 22 Jan 2001 20:51:21 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: Lint for perl?
Message-Id: <MPG.14d6ad9f3875b0e698985a@news.online.no>

In article <94hv1o$f0f$1@panix2.panix.com>, stanb@panix.com says...
> If I add a new variable dcleration as in:
> 
> my $foo;
> 
> and don't use it in the function it is declared in, I get no comlaints
> from any of the sugestiosn I have recieved so far.

Why not use Perl to do this?  Just a wild suggestion from me, but it 
should be fairly easy to write a script which checks if your variables 
are used only once?

:)


-- 
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/


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

Date: Tue, 23 Jan 2001 08:08:00 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Lint for perl?
Message-Id: <slrn96p89g.meu.mgjv@martien.heliotrope.home>

On Mon, 22 Jan 2001 20:51:21 +0100,
	Tore Aursand <tore@extend.no> wrote:
> In article <94hv1o$f0f$1@panix2.panix.com>, stanb@panix.com says...
>> If I add a new variable dcleration as in:
>> 
>> my $foo;
>> 
>> and don't use it in the function it is declared in, I get no comlaints
>> from any of the sugestiosn I have recieved so far.
> 
> Why not use Perl to do this?  Just a wild suggestion from me, but it 
> should be fairly easy to write a script which checks if your variables 
> are used only once?
> 
>:)

Nothing can parse Perl but perl.

It might be possible to do that, but it certainly isn't going to be
easy. You'll have to deal with arrays and hashes as well as simple
scalars. You'll have to keep track of the correct scoping, so that you
count the right lexical variable $foo in the lexical scope, if more than
one is defined. Most of my code has many instances of the same lexical
variable, in several subs. I hardly ever will next lexical scopes, but
it does happen. Then you need to make sure that you don't coutn things
that look like a variable as one.

my $foo;
my @foo;
my %foo;
{
	my $foo;
	my $bar = "$foo is called here\n";
	my $baz = 'but $foo isn't called here';

	s#$bar#$baz#; # $foo isn't in here.
	
	"And here is \@foo in the guise of $foo[1], but in a void context";
	"does this count? It's not going to be used anywhere";

	$foo{bar} = ${foo};
}

And I am sure people can come up with more obscure ones that will make
parsing even harder. I haven't even done my best. The problem isn't even
really finding things that _might_ be variables, but more to correctly
discard the ones that aren't.

If oyu want to extend this to dynamically scoped variables, your job
becomes even harder. Or if you want to allow this to run outside of
strict [1]:

use strict;
my $foo = 134;
my $name = 'foo';
no strict 'refs';
my $bar = eval "\$$name";
print $bar;

I'd say it would be easier to patch the perl source code to warn,
optionally, for this. And I'm not even entirely sure that it would be
possible, simply because the variable might actually be used at runtime,
without you knowing about it at compile time. If strict refs is in
force, there may be a chance that it actually is possible.

Martien

[1] the example is bad code. A bad idea. But you'd be surprised how
often people do that sort of thing. And since it's possible, your parser
will have to deal with it.
-- 
Martien Verbruggen              | 
Interactive Media Division      | The world is complex; sendmail.cf
Commercial Dynamics Pty. Ltd.   | reflects this.
NSW, Australia                  | 


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

Date: 22 Jan 2001 14:38:01 -0800
From: Ansel Sermersheim <ansel@babylon.dyndns.org>
Subject: Re: Lint for perl?
Message-Id: <871ytvkyba.fsf@redhawk.babylon.dyndns.org>

>>>>> "Martien" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:

> On Mon, 22 Jan 2001 20:51:21 +0100, Tore Aursand <tore@extend.no>
> wrote:
>> In article <94hv1o$f0f$1@panix2.panix.com>, stanb@panix.com says...
>>> If I add a new variable dcleration as in:
>>> 
>>> my $foo;
>>> 
>>> and don't use it in the function it is declared in, I get no
>>> comlaints from any of the sugestiosn I have recieved so far.
>>  Why not use Perl to do this?  Just a wild suggestion from me, but
>> it should be fairly easy to write a script which checks if your
>> variables are used only once?

> And I am sure people can come up with more obscure ones that will
> make parsing even harder. I haven't even done my best. The problem
> isn't even really finding things that _might_ be variables, but more
> to correctly discard the ones that aren't.

Also, keep in mind subs returning anonymous closures.  How could you
parse that?  E.g., from a program (inetd replacement) I'm playing
with:

sub Chroot {
  my $dir = shift;
  my $sub = shift;
  return sub {
    chdir $dir 
      or logerr "Unable to chdir to $dir prior to chroot: $!";
    chroot $dir 
      or logerr "Unable to chroot to $dir, $!";
    &$sub(@_);
  }
}

This and its cousins let me say something like (example, real code's
more complex):

{ 21 => 
  Accept Fork_redir Chroot '/home/ftp' Drop_privs sub {exec "/usr/bin/ftpd"},
  113 =>
  Accept Task_add Pinetd::Daemons::Ident,
}

I think one of the main problems is that perl blurs the line between
compilation and execution/interpretation to the point that anything
just looking at the source is doomed to failure.

(If anything can properly lint my signature, and not complain about @]
being unused without actually running it, I'll sponsor it for a
Turing test ;)

-Ansel
-- 
$_{\$,}=[];@,=(%_,\%_,\*_,sub{},'JaPH'x2);y/0-9a-y//d,for(@,);map{$_ x=3}@,;$q=
join'',sort'$y=shift@,; $y^= int(eval$q) $q=q-my eval${q}if@,;$y-;pr'=~/\S*/g;$
_=q]"^vp|\@Zi0e|12O7340CP567M[,"];s@\d@\$][$&]@g;@]=(split'',unpack qq^$&q^^q^,
^^q,nQ,,q^)%1T&'`P%"SD`^);push@,,eval;eval(('JXKCC'^q^/.*/g^).$q=~/(.{6}).$/g);



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

Date: Mon, 22 Jan 2001 21:57:26 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: matrix
Message-Id: <t6pb662obo5hcf@corp.supernews.com>

jdf@pobox.com wrote:
> Bob Walton <bwalton@rochester.rr.com> writes:

>> smittod@auburn.edu wrote:
>> > I need a module that can build and display a matrix for me.
>> ...
>> You'll have to be much more descriptive and explicit about what you want
>> -- nobody can decipher from the above what you want.  Maybe some
>> examples of what you mean by a "matrix" and its "display" would help.

> What *is* the matrix?

It is the world pulled over your eyes to blind you from the truth.

However, what the OP really wants isn't a matrix, but a tree. There
are lots of ways to do trees in Perl, but I haven't tested any for
speed or memory use. There are probably a lot better answers to be
had than I can answer, but I do know the OP will likely get better
answers with "tree", "directional graph", "cyclic directional
graph", "acyclic directional graph", or "nondirectional graph"
in the subject rather than "matrix".

Chris

-- 
Christopher E. Stith

If they can get you asking the wrong questions, they don't
have to worry about the answers.
  -- Thomas Pynchon, Gravity's Rainbow



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

Date: Mon, 22 Jan 2001 19:17:12 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: MP3::Napster: Error when using filehandle for download
Message-Id: <94i0ve$28a$1@nnrp1.deja.com>

Hi,

I've written the following using Napster::MP3 which connects to a user
and downloads a file (this will of course not stay this way). However
instead of putting it to a file it redirects it to the stdout. Well
thats the idea. Here is the code:

#!/usr/bin/perl -w
use strict;
use MP3::Napster;
use IO::Handle;
my $nap = MP3::Napster->new;
$nap->login('username', 'password', LINK_UNKNOWN);
$nap->listen();
my @songs = $nap->browse("farahmahmood");
my $io = new IO::Handle;
$io->fdopen(fileno(STDOUT),"w");
autoflush $io 1;
$io->print("Content-type: application/mp3\n\n");
$nap->download("Pink Floyd - Another Brick In The Wall.mp3", $io);
$nap->callback(TRANSFER_DONE,
        sub { my ($nap,$transf) = @_;
              undef $io;
              autoflush STDOUT 1;
              $nap->disconnect;
              exit;
            } );
END { $nap->disconnect(600) if $nap }

As you might have guessed, eventually this will run from a webpage
(hence the stdout redirect) but my problem seems to be that when I run
this from the command line I get:

usage: download($song,$file_or_filehandle)
at /usr/local/lib/perl5/site_perl/5.6
 .0/MP3/Napster.pm line 669.

which leaves me a little lost since I'm not really sure what I've done
wrong. According to the docs:

"You must pass filehandles as GLOB refs (\*FH), GLOBS (*FH) or as
IO::Handle objects."

which I thought I was doing (but obviously not)!

Can someone please enlighten me?

Thanks

Rich


Sent via Deja.com
http://www.deja.com/


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

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 V10 Issue 121
**************************************


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