Mailing List Archive

1 2  View All
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
On Wed, 25 Oct 1995, Andy Dougherty wrote:

> Which saves typing 7 characters. Well, 3, actually, since you'd probably
> type:
> perl -e 'use rc; something'
>
> I guess I'm not convinced it's important to have yet a third way to say
> BEGIN { require "rc.pm"; import rc; }
>
> On the other hand, Tim apparently was and submitted a patch to implement
> it. When people care enough about an issue to solve it themselves, I tend
> to be sympathetic.

Of course, half of the impetus of that patch was (if I remember right) to
allow saying C<perl -man "foobar"> to substitute for perldoc. :-)

> Andy Dougherty doughera@lafcol.lafayette.edu
> --
> To subscribe or unsubscribe, send your request (subscribe, unsubscribe)
> in the BODY of a message to perl5-porters-request@africa.nicoh.com.
>
>

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
> From: Andy Dougherty <doughera@lafcol.lafayette.edu>
>
> > With the -mfoo option for doing "use foo" from the command line,
> > it could be
> > perl -myrc -e 'something'
>
> Which saves typing 7 characters. Well, 3, actually, since you'd probably
> type:
> perl -e 'use rc; something'
>
> I guess I'm not convinced it's important to have yet a third way to say
> BEGIN { require "rc.pm"; import rc; }
>
> On the other hand, Tim apparently was and submitted a patch to implement
> it. When people care enough about an issue to solve it themselves, I tend
> to be sympathetic.

The problem with the -e option is that perl no longer looks for a script
on the command line.

If I want to run foo.pl in a modified way, saying:

perl -e 'use BAR; do "foo.pl"'
or
perl -e 'use BAR; require "foo.pl"'

has a different meaning to:

perl -MBAR foo.pl

consider compile time errors, caller() etc.

Tim.

p.s. This is my first post from a new internal mail machine so
I hope it's okay. Hopefully nothing should appear changed.
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
> Of course, half of the impetus of that patch was (if I remember right) to
> allow saying C<perl -man "foobar"> to substitute for perldoc. :-)


Acutally, it was to substitute for "man perl foobar" :-)

--tom
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
> From: Kenneth Albanowski <kjahds@kjahds.com>
>
> On Wed, 25 Oct 1995, Andy Dougherty wrote:
>
> > Which saves typing 7 characters. Well, 3, actually, since you'd probably
> > type:
> > perl -e 'use rc; something'
> >
> > I guess I'm not convinced it's important to have yet a third way to say
> > BEGIN { require "rc.pm"; import rc; }
> >
> > On the other hand, Tim apparently was and submitted a patch to implement
> > it. When people care enough about an issue to solve it themselves, I tend
> > to be sympathetic.
>
> Of course, half of the impetus of that patch was (if I remember right) to
> allow saying C<perl -man "foobar"> to substitute for perldoc. :-)

A scurrilous rumour!

Actually the other half of the impetus was for perl -mDevel::Dprof :-)

(but it turned out that -d needs to be processed much earlier in the
perl startup code than where -m takes effect. Oh well.)

The points raised in my reply to Andy's message still stand.

Tim.
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
On Wed, 25 Oct 1995, Tim Bunce wrote:

> And the next logical step
>
> perl -MRC
>
> would be shorter still.

<Chuckle> Say, Tim, would that automatically pull in the HO package? For
that matter, is anybody planning on writing a Z package?

> Tim.
>

p.s. ;-)

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
Excerpts from the mail message of Tim Bunce:
) The problem with the -e option is that perl no longer looks for a script
) on the command line.
)
) If I want to run foo.pl in a modified way, saying:
)
) perl -e 'use BAR; do "foo.pl"'
) or
) perl -e 'use BAR; require "foo.pl"'
)
) has a different meaning to:
)
) perl -MBAR foo.pl
)
) consider compile time errors, caller() etc.

Since we already have:

perl -e 'use BAR;' -e 'require "foo.pl"' args

perhaps we could allow:

perl -e 'use BAR;' -f foo.pl -f fum.pl -e 'warn "Done!\n"' args

Anyone fired up enough to patch that in?

I can think of one other advantage of this; you could have an
alias of:

alias script='perl -f script.pl'
and
script -d -pi.bak -- -x *.bat

would be the same as

perl -d -pi.bak script.pl -x *.bat

(not that I've come up with a good use for this.)
--
Tye McQueen tye@metronet.com || tye@doober.usu.edu
Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
On Wed, 25 Oct 1995, Tim Bunce wrote:

> A scurrilous rumour!

:-)

> Actually the other half of the impetus was for perl -mDevel::Dprof :-)
>
> (but it turned out that -d needs to be processed much earlier in the
> perl startup code than where -m takes effect. Oh well.)
>
> The points raised in my reply to Andy's message still stand.

Actually, I think this is another count in favor of making some sort of -d
variant that works like -M too. Being able to say C<perl -Dprof> or C<perl
-Debug> would be a very handy feature for us debuggers and profilers.

If C<-m> means require, and C<-M> means C<use> then what should mean
"debug and use"?

> Tim.
>

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
Andy Dougherty writes:
>
> On Wed, 25 Oct 1995, Malcolm Beattie wrote:
>
> > Larry Wall writes:
> > >
> > > Saying
> > >
> > > perl -e 'use RC; ...'
> > >
> > > doesn't seem too terrible painful [ . . . ]
> >
> > With the -mfoo option for doing "use foo" from the command line,
> > it could be
> > perl -myrc -e 'something'
>
> Which saves typing 7 characters. Well, 3, actually, since you'd probably
> type:
> perl -e 'use rc; something'
>
> I guess I'm not convinced it's important to have yet a third way to say
> BEGIN { require "rc.pm"; import rc; }

It's not what you say, it's where you say it ;-)
perl -myrc -ple 'munge($_)' foo
versus
perl -myrc -e 'while (<>) { chop; munge($_); print "$_\n" }' foo

For one-liners, where you're using -l, -n, -p, -0, -a and/or -F,
you want your personal library of munging functions to be "used"
before all the magic loops and things get put in.

--Malcolm

--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
Tim Bunce wrote :
|| > From: Kenneth Albanowski <kjahds@kjahds.com>
|| >
|| > Of course, half of the impetus of that patch was (if I remember right) to
|| > allow saying C<perl -man "foobar"> to substitute for perldoc. :-)
||
|| A scurrilous rumour!
||
|| Actually the other half of the impetus was for perl -mDevel::Dprof :-)
||
|| (but it turned out that -d needs to be processed much earlier in the
|| perl startup code than where -m takes effect. Oh well.)

There's selective memory for you. I remembered the (third :-)
half being to allow easily such things as: "-mb64 -mdecrypt
-mungzip" to be specified so you could run a script that had
been compressed, encrypted and base64 encoded.

--
Maybe we can fix reality one of these days. | John Macdonald
<- Larry Wall Carl Dichter -> | jmm@Elegant.COM
I'd be happy if we could just index it. |
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
> From: Kenneth Albanowski <kjahds@kjahds.com>
>
> > Actually the other half of the impetus was for perl -mDevel::Dprof :-)
> >
> > (but it turned out that -d needs to be processed much earlier in the
> > perl startup code than where -m takes effect. Oh well.)
> >
> > The points raised in my reply to Andy's message still stand.
>
> Actually, I think this is another count in favor of making some sort of -d
> variant that works like -M too. Being able to say C<perl -Dprof> or C<perl
> -Debug> would be a very handy feature for us debuggers and profilers.
>
> If C<-m> means require, and C<-M> means C<use> then what should mean
> "debug and use"?

The -d:FOO approach would be fine by me.

In fact it's so neat and the patch so small that I've attached it below.
Note the interesting problem with environ which it uncovers and fixes.

With this patch you *can* now say

perl -d:Devel::DProf ...

Yippee!

Larry, are you happy with this?

Tim.


*** ./perl.c.1m Thu Oct 26 13:30:08 1995
--- ./perl.c Thu Oct 26 17:02:25 1995
***************
*** 907,910 ****
--- 907,916 ----
case 'd':
taint_not("-d");
+ s++;
+ if (*s == ':') {
+ sprintf(buf, "use %s;", ++s);
+ s += strlen(s);
+ my_setenv("PERL5DB",buf);
+ }
if (!perldb) {
perldb = TRUE;
***************
*** 911,915 ****
init_debugger();
}
- s++;
return s;
case 'D':
--- 917,920 ----
***************
*** 1654,1657 ****
--- 1659,1669 ----
hv_clear(hv);
#ifndef VMS /* VMS doesn't have environ array */
+ /* Note that if the supplied env parameter is actually a copy
+ of the global environ then it may now point to free'd memory
+ if the environment has been modified since. To avoid this
+ problem we treat env==NULL as meaning 'use the default'
+ */
+ if (!env)
+ env = environ;
if (env != environ) {
environ[0] = Nullch;
*** ./miniperlmain.c.1m Thu Oct 26 17:03:20 1995
--- ./miniperlmain.c Thu Oct 26 17:03:30 1995
***************
*** 28,32 ****
}

! exitstatus = perl_parse( my_perl, xs_init, argc, argv, env );
if (exitstatus)
exit( exitstatus );
--- 28,32 ----
}

! exitstatus = perl_parse( my_perl, xs_init, argc, argv, NULL );
if (exitstatus)
exit( exitstatus );

Tim.
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
> From: John Macdonald <jmm@elegant.com>
>
> Tim Bunce wrote :
> || > From: Kenneth Albanowski <kjahds@kjahds.com>
> || >
> || > Of course, half of the impetus of that patch was (if I remember right) to
> || > allow saying C<perl -man "foobar"> to substitute for perldoc. :-)
> ||
> || A scurrilous rumour!
> ||
> || Actually the other half of the impetus was for perl -mDevel::Dprof :-)
> ||
> || (but it turned out that -d needs to be processed much earlier in the
> || perl startup code than where -m takes effect. Oh well.)
>
> There's selective memory for you. I remembered the (third :-)
> half being to allow easily such things as: "-mb64 -mdecrypt
> -mungzip" to be specified so you could run a script that had
> been compressed, encrypted and base64 encoded.

I've always been a man of many halves ;-)

Tim.
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
: It's not what you say, it's where you say it ;-)
: perl -myrc -ple 'munge($_)' foo
: versus
: perl -myrc -e 'while (<>) { chop; munge($_); print "$_\n" }' foo
:
: For one-liners, where you're using -l, -n, -p, -0, -a and/or -F,
: you want your personal library of munging functions to be "used"
: before all the magic loops and things get put in.

Huh? Offhand I can't think of any way in which it matters whether say

use yrc; while (<>) { ... }

or

while (<>) { use yrc; ... }

But I don't think we can do a general "use" before processing the
switches, since we have switches like -I, -p and -d that may influence
how you find and compile files. But perhaps if we reduce every switch
to its corresponding BEGIN {}, we can keep the semantics straight. I
don't think it's a trivial undertaking though.

Larry
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
Tim Bunce writes:
>
> The -d:FOO approach would be fine by me.
>
> In fact it's so neat and the patch so small that I've attached it below.
> Note the interesting problem with environ which it uncovers and fixes.
>
> With this patch you *can* now say
>
> perl -d:Devel::DProf ...
>

I would prefer
perl -d:DProf
with Devel:: autoprepended. I may move modified perl5db to Devel::DB
(internally it will be still in DB).

Ilya
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
On Sat, 28 Oct 1995, Ilya Zakharevich wrote:

> Tim Bunce writes:
> >
> > The -d:FOO approach would be fine by me.
> >
> > In fact it's so neat and the patch so small that I've attached it below.
> > Note the interesting problem with environ which it uncovers and fixes.
> >
> > With this patch you *can* now say
> >
> > perl -d:Devel::DProf ...
> >
>
> I would prefer
> perl -d:DProf
> with Devel:: autoprepended. I may move modified perl5db to Devel::DB
> (internally it will be still in DB).

Actually, that's why "Auto::" crept into one of my examples. Indeed, any
name will do, as you can just have "MFooBar::DProf" pull in Devel::DProf
(or whatever) in turn.

> Ilya
>

--
Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
Larry Wall writes:
>
> : It's not what you say, it's where you say it ;-)
> : perl -myrc -ple 'munge($_)' foo
> : versus
> : perl -myrc -e 'while (<>) { chop; munge($_); print "$_\n" }' foo
> :
> : For one-liners, where you're using -l, -n, -p, -0, -a and/or -F,
> : you want your personal library of munging functions to be "used"
> : before all the magic loops and things get put in.
>
> Huh? Offhand I can't think of any way in which it matters whether say
>
> use yrc; while (<>) { ... }
>
> or
>
> while (<>) { use yrc; ... }

My apologies: I was thinking of the overhead caused by the "use"
being done every loop iteration but, of course, the implicit
"BEGIN { }" prevents that.

> But I don't think we can do a general "use" before processing the
> switches, since we have switches like -I, -p and -d that may influence
> how you find and compile files. But perhaps if we reduce every switch
> to its corresponding BEGIN {}, we can keep the semantics straight. I
> don't think it's a trivial undertaking though.

Not worth it, for my mistaken point anyway. I have a bad habit that if
I see a one-liner with real words in it instead of line noise then I
automatically assume it can be shortened :-)

--Malcolm

--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
Larry Wall writes:
>
> : It's not what you say, it's where you say it ;-)
> : perl -myrc -ple 'munge($_)' foo
> : versus
> : perl -myrc -e 'while (<>) { chop; munge($_); print "$_\n" }' foo
> :
> : For one-liners, where you're using -l, -n, -p, -0, -a and/or -F,
> : you want your personal library of munging functions to be "used"
> : before all the magic loops and things get put in.
>
> Huh? Offhand I can't think of any way in which it matters whether say
>
> use yrc; while (<>) { ... }
>
> or
>
> while (<>) { use yrc; ... }

My apologies: I was thinking of the overhead caused by the "use"
being done every loop iteration but, of course, the implicit
"BEGIN { }" prevents that.

> But I don't think we can do a general "use" before processing the
> switches, since we have switches like -I, -p and -d that may influence
> how you find and compile files. But perhaps if we reduce every switch
> to its corresponding BEGIN {}, we can keep the semantics straight. I
> don't think it's a trivial undertaking though.

Not worth it, for my mistaken point anyway. I have a bad habit that if
I see a one-liner with real words in it instead of line noise then I
automatically assume it can be shortened :-)

--Malcolm

--
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Unix Systems Programmer
Oxford University Computing Services
Re: VERY SMALL FEATURE REQUEST [ In reply to ]
> From: Ilya Zakharevich <ilya@math.ohio-state.edu>
>
> Tim Bunce writes:
> >
> > The -d:FOO approach would be fine by me.
> >
> > In fact it's so neat and the patch so small that I've attached it below.
> > Note the interesting problem with environ which it uncovers and fixes.
> >
> > With this patch you *can* now say
> >
> > perl -d:Devel::DProf ...
>
> I would prefer
> perl -d:DProf
> with Devel:: autoprepended. I may move modified perl5db to Devel::DB
> (internally it will be still in DB).

Yes, given that specialist nature of the -d flag I think that's a
very good idea - and typing Devel:: all the time would be anti-lazy ;-)

Larry, would you like a revised patch? (Or you can just add the seven
chars by hand :-)

Tim.

1 2  View All