1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/perl use warnings; use strict; sub pront {for(@_){print"$_\n"}} pront "Hallo"; my @a = (1, 2, 3, 4); pront @a;
say for @array;
2012-01-13T19:13:54 pqaber bitte immer schön ein local() davor und in einen eigenen scope. bzw. aufpassen, dass nicht andere aufgerufene funktionen in diesem scope liegen.
sub pront { print @_,"\n"; }
Guest werCode (perl): (dl )sub pront { print @_,"\n"; }
1 2 3 4 5 6
sub pront { local $\ = "\n"; local $, = "\n"; local $" = "\n"; print @_ ? @_ : $_; }
2012-01-14T07:34:37 FIFO
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#! /usr/bin/perl use strict; use warnings; sub bla { local $\ = local $, = $/; local $" = "X"; print "@_"; } my @array = 1..5; my $from_here; bla <<"END_HERE"; first try: @array END_HERE # vs. { local $" = $/; bla <<"END_HERE"; second try: @array END_HERE } # vs. bla "third try: ", @array;
1
2
3
4
5
6
7
8
9
10
$ perl testing/bla.pl
first try: 1 2 3 4 5
second try: 1
2
3
4
5
third try: X1X2X3X4X5