Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Does =$*ARGS work?

8 views
Skip to first unread message

Brian D Foy

unread,
Apr 11, 2007, 2:29:52 PM4/11/07
to perl6-l...@perl.org
Randal and I are starting work on "Learning Perl 6", and now
that I've completed a lot of other things, I can actually start
paying attention to Perl 6. Here's the first of my stupid, "where
have you been for the past 2 years you moron" questions. :)

I'm working on the chapter on I/O (Chapter 5 in the current Llama),
specifically reading from the command lines files.

Under the section "The for Statement" in S04, it says that the diamond
operator

while( <> ) { ... }

becomes in Perl 6

for =$*ARGS { ... }

In the Pugs I have (6.2.13 (r15868) on Intel darwin), =$*ARGS only
reads the lines from the first file in @ARGS. I don't see this idiom
used anywhere else in the tests or examples, either.

The $*ARGS variable shows up in this file, which looks like it's still
maintained:

http://svn.pugscode.org/pugs/docs/AES/S28draft.pod

but that points to another variable list that it says is more
complete, although it does not list $*ARGS:

http://svn.pugscode.org/pugs/docs/Perl6/Overview/Variable.pod

Is this something that's not yet implemented or just broken? Am I
missing some documentation about parts that aren't implemented yet?

I wrote a test to put into t/builtin/io (once I remember my password),
but since I haven't committed anything to pugs before, I want to ensure
it's not me being stupid. :)

Also, along with that, is there any counterpart to Perl 5's $ARGV? I
wanted to record the files =$*ARGS went through, but I didn't see a way
to discover that.

Moritz Lenz

unread,
Apr 12, 2007, 6:07:33 AM4/12/07
to perl6-l...@perl.org
Hi,

brian d foy wrote:
> Under the section "The for Statement" in S04, it says that the diamond
> operator
>
> while( <> ) { ... }
>
> becomes in Perl 6
>
> for =$*ARGS { ... }

Some time ago I read that too, and wondered why that's not =@*ARGS. That
seems more reasonable, because the command line arguments are stored in
@*ARGS.

I can't answer your question, sorry ;-).

Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ - http://sudokugarden.de/ - http://perl-6.de/

signature.asc

Brian D Foy

unread,
Apr 12, 2007, 7:29:11 AM4/12/07
to perl6-l...@perl.org
In article <461E04E5...@casella.verplant.org>, Moritz Lenz
<mor...@casella.verplant.org> wrote:

> Hi,
>
> brian d foy wrote:
> > Under the section "The for Statement" in S04, it says that the diamond
> > operator
> >
> > while( <> ) { ... }
> >
> > becomes in Perl 6
> >
> > for =$*ARGS { ... }
>
> Some time ago I read that too, and wondered why that's not =@*ARGS. That
> seems more reasonable, because the command line arguments are stored in
> @*ARGS.

well, $*ARGS is a magical filehandle, not a list of files. If you could
use an array there, I think you'd have to allow any array, and that
would be weird.

Moritz Lenz

unread,
Apr 12, 2007, 9:54:15 AM4/12/07
to perl6-l...@perl.org
Hi,

brian d foy wrote:
> In article <461E04E5...@casella.verplant.org>, Moritz Lenz
> <mor...@casella.verplant.org> wrote:
>
>> Hi,
>>
>> brian d foy wrote:
>>> Under the section "The for Statement" in S04, it says that the diamond
>>> operator
>>>
>>> while( <> ) { ... }
>>>
>>> becomes in Perl 6
>>>
>>> for =$*ARGS { ... }
>> Some time ago I read that too, and wondered why that's not =@*ARGS. That
>> seems more reasonable, because the command line arguments are stored in
>> @*ARGS.
>
> well, $*ARGS is a magical filehandle, not a list of files. If you could
> use an array there, I think you'd have to allow any array, and that
> would be weird.

Why would that be weird? When things like

my $file = "/etc/passwd";
for =$file -> $line { ... }

work, why shouldn't we allow things like

my @files = <foo bar>
for =@files -> $line { ... }

and let '=' followed by an empty list default to $*IN (like in =<>)?

I think that would be consequent magic, and very convenient.

(If you already had that discussion earlier, just say it and I'll shut
up ;-)

Cheers,

signature.asc

David Vergin

unread,
Apr 13, 2007, 6:22:40 AM4/13/07
to perl6-l...@perl.org, brian d foy
on 4/11/2007 10:29 AM brian d foy said the following:

> The $*ARGS variable shows up in this file, which looks like it's still
> maintained:
> http://svn.pugscode.org/pugs/docs/AES/S28draft.pod

That's a typo (mine). It should be @*ARGS and refers to simple access to
the command line arguments. (Fixed.)


dvergin

Brian D Foy

unread,
Apr 13, 2007, 8:55:17 AM4/13/07
to perl6-l...@perl.org
In article <461F59F0...@igc.org>, David Vergin <dve...@igc.org>
wrote:

Shouldn't $*ARGS still show up as the P6 counterpart to ARGV? S*ARGS as
the filehandle shows up in S04.

David Vergin

unread,
Apr 13, 2007, 11:51:25 AM4/13/07
to perl6-l...@perl.org, brian d foy
on 4/13/2007 4:55 AM brian d foy said the following:

> Shouldn't $*ARGS still show up as the P6 counterpart to ARGV?
> S*ARGS as the filehandle shows up in S04.

Yup. Fixed now in S28draft.pod. Mention in Variable.pod will follow.

dvergin

0 new messages