"Tassilo Von Parseval" <[EMAIL PROTECTED]> wrote in
message news:[EMAIL PROTECTED]
> On Sun, Jun 01, 2003 at 08:36:34PM -0400 Todd Wade wrote:
>
> > "Tassilo Von Parseval" <[EMAIL PROTECTED]> wrote in
> > message news:[EMAIL PROTECTED]
> > > On Sun, Jun 01, 2003 at 11:22:32AM +0200 Kevin Pfeiffer wrote:
> > >
> > <snip />
> > >
> > >     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.
> > >

After a little research, "@{[ ... ]}" will interpolate as the perl
equivalent of:

join($", @{[ ... ]})

and then return in the string. To get the behavior you describe above, one
would use the code you provided below from the last post =0)

note:

[EMAIL PROTECTED] wadet]$ perl
$" = '-';
print( "time is: ${ \localtime }\n" );
print( "time is: @{ [localtime] }\n" );
Ctrl-D
time is: 1
time is: 13-24-6-2-5-103-1-152-1


> > If you want to interpolate a scalar value in a string you should
probably
> > avoid creating an array reference, if only to avoid confusion:
> >
> > [EMAIL PROTECTED] trwww]$ perl
> > use constant A_CONSTANT => '/some/path';
> > print("the constant's value is: ${ \A_CONSTANT }\n");
> > Ctrl-D
> > the constant's value is: /some/path
>
> That's a bit better here because ${ \... } will execute the code in
> scalar-context instead of list-context. However, it wont always work as
> expected which is why I seldom use it. For instance:
>
>     # this should work _theoretically_
>     print "${ \localtime }";
>     # but doesn't:
>     __END__
>     1
>

This is the code that evaluates the expression and returns its last element
to the "\" operator, But only because the argument is a list, and not an
array.

Ive done a s/expected/defined/g on the way I code and things started working
better for me =0)

Im clarifying my thoughts and not yours... Im still a bit unsure, but I have
to get to work now.

Todd W.




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

Reply via email to