Thread Parameterübergabe an sub (15 answers)
Opened by gamerzzz at 2007-03-12 09:56

gamerzzz
 2007-03-12 13:14
#74921 #74921
User since
2007-03-12
10 Artikel
BenutzerIn
[Homepage] [default_avatar]
so kann ich über $out = '2_1::0'; den Output auch ausserhalb der sub bestimmen:
Code: (dl )
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
use strict;
my $string = "testx_testy_testz";
my $in = "(testx)_(testy)_(testz)";

my $out = '2_1::0';

test("$string","$in","$out");

sub test
{
my $sub_string = shift;
my $sub_in = shift;
my $sub_out = shift;

print "$sub_string <=> $sub_in <=> $sub_out \n";

my @info = $sub_string =~ /$sub_in/;

my $new_string = "";
for my $rr ( 0 .. length($sub_out)-1 )
{
my $ch = substr($sub_out,$rr,1);
( $ch =~ /\d/ ) ? $new_string.=$info[$ch] : 1;
( $ch =~ /\D/ ) ? $new_string.=$ch : 1;

}


print "erg: $new_string \n";
}
\n\n

<!--EDIT|renee|1173698578-->

View full thread Parameterübergabe an sub