On Sun, Jun 01, 2003 at 01:13:31PM +0200 Kevin Pfeiffer wrote:

> Hi Tassilo,

Hi there,

> In article <[EMAIL PROTECTED]>, Tassilo Von Parseval wrote:

> > if your Perl is recent enough (>= 5.6.0). Or you use the
> > interpolate-anything trick:
> > 
> >     open DATA, ">@{[ CFG ]}" or die ...;
> > 
> > The part between @{[ ]} is arbitry Perl-code that is executed in list
> > context and the last expression evaluated in this Perl code is what gets
> > eventually printed.
> 
> This seems too confusing here for me (but I will add it to my save file for 
> future reference.)

It is quite orthogonal actually. You probably know that you can create a
reference to an anonymous array on the fly like this:

    my $ref = [ split /,/, $var ];
    # which can be dereferenced to
    my @fields = @{ $ref };

And now in one go you could do (a little silly of course):

    my @fields = @{ [ split /,/, $var ] };

The right-hand side interpolates...it is just an ordinary array (without
a name).

> > Btw: You probably shouldn't use the DATA handle. It's special in that it
> > refers to anything that follows the __DATA__ or __END__ token in your
> > scripts. It even is seekable so you can write a script that prints
> > itself with the help of this filehandle.
> 
> I almost asked about this earlier - if a script can also write to itself. I 
> wrote something to test it, but haven't had time to look up the seek 
> functions, etc. I suppose this only makes sense in very limited situations 
> (if at all)?

I don't think you can use it for writing. DATA is meant for reading. But
it's useful for embedded data:

    while (<DATA>) {
        ...
    }
    __DATA__
    some data
    to be used
    by script

Some CPAN modules use this technique to embedded some data.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to