Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: RFC: Is there more to alias?

by Solo (Deacon)
on Aug 25, 2004 at 03:55 UTC ( [id://385576]=note: print w/replies, xml ) Need Help??


in reply to RFC: Is there more to alias?

POD seemed to imply this wasn't supported (by not saying it was), but I wanted to ask in case it was obvious... can implicit assignment to $_ be aliased? As in

for alias my $line (<DATA>) {}

I'd probably never want to alias $_, just a curiosity.

I don't see anything about filehandles in the POD, either, as in

alias my $line = <DATA>; while ( defined( alias my $line = <DATA> ) ) {}

I'm not sure what I'd expect from the first, but the second involves another implicit assignment to $_. Would that work as 'expected'?

Deref is especially cool and I look forward to that very much. ++

--Solo

--
You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Replies are listed 'Best First'.
Re^2: RFC: Is there more to alias?
by Solo (Deacon) on Aug 25, 2004 at 16:59 UTC
    Attempting to follow xmath's advice and try myself. Unfortunately, I'm out of my league with xs compilation errors. (I can build Date::Calc, so it's not an environment problem.)

    Are there compiler options I'm missing?

      I think I've fixed the problem, and I've uploaded a fresh version. See if this helps.

      As for your original questions.. I have read your original post several times, and I have honestly no idea what you're trying to accomplish....

      for alias my $line (<DATA>) {}
      This is a syntax error. And "for" already aliases, so what's the deal here? On top of that, why would you need an alias to the temporary var that contains the line anyway?

      alias my $line = <DATA>; while ( defined( alias my $line = <DATA> ) ) {}
      These work, but again I don't see the point.. why alias $line to the read line? To prevent copying the line? I think perl already optimizes that away.

      Maybe I'm just missing something, in which case please enlighten me.

        Thanks, I'll try the new version.

        And I don't think you're missing anything... hope I didn't make you spin too many cycles on that.

        As I said it was a curiosity: A way to give $_ a 'pretty name' in a for or while loop. You're saying it's already the same to do:

        for $line (<DATA>) {} # or for alias $line (<DATA>) {}

        Ok. /shrug. I naively saw the named subroutine arguments as roughly the same thing. I am enlightened. =)

        --Solo

        --
        You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://385576]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-20 05:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found