Thread sigil/twigil/... um Instanzvariablen zu Kennzeichnen (Ruby!,Perl6?)
(10 answers)
Opened by KurtZ at 2008-07-16 18:39 KurtZ+2008-07-16 16:39:28-- so in dieser Art? Code (perl): (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 #!/usr/bin/perl package attribute; use Filter::Simple sub { s/(\$|\@|\%)(\.)(\w+)/selfify($1,$2,$3)/xeg; }; sub selfify { ($sigil,$twigil,$identifier)=@_; return "\$self->{$identifier}" if ($sigil eq '$'); return "$sigil\{\$self\-\>\{$identifier\}\}" if $sigil eq '%' or $sigil eq '@'; } 1; #!/usr/bin/perl use attribute; $self={ scalar => "SCALAR", array => ["ARRAY",], hash => {"HASH",}, }; print '$.scalar: ',$.scalar,"\n"; print '@.array: ',@.array,"\n"; print '%.hash: ',%.hash,"\n"; aber ich glaube was gelesen zu haben von CPAN-Modulen die das zuverlässiger erledigen als mein Hack. :-) me and my writeups
|