Thread Skalarer Kontext und Listenkontext (5 answers)
Opened by davix at 2014-04-29 22:18

Linuxer
 2014-04-29 22:48
#175128 #175128
User since
2006-01-27
3875 Artikel
HausmeisterIn

user image
Guest wer
Code (perl): (dl )
print "Ausgabe:@reverse";
entspricht
Code (perl): (dl )
print "Ausgabe:"; print join( $, , @reverse );


Nicht ganz. Bei "@array" wird nicht mit $, zusammengefügt, sondern mit $".

perldoc perlvar
$" When an array or an array slice is interpolated into a double-quoted string or a similar context such as "/.../", its elements are separated by this value. Default is a space. For example, this:

print "The array is: @array\n";

is equivalent to this:

print "The array is: " . join($", @array) . "\n";

Mnemonic: works in double-quoted context.
meine Beiträge: I.d.R. alle Angaben ohne Gewähr und auf Linux abgestimmt!
Die Sprache heisst Perl, nicht PERL. - Bitte Crossposts als solche kenntlich machen!

View full thread Skalarer Kontext und Listenkontext