Schrift
Wiki:Tipp zum Debugging: use Data::Dumper; local $Data::Dumper::Useqq = 1; print Dumper \@var;
[thread]7548[/thread]

Hash als Option missbrauchen (Seite 2)

Leser: 1


<< |< 1 2 3 4 5 ... 12 >| >> 119 Einträge, 12 Seiten
bloonix
 2005-12-19 06:33
#60969 #60969
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
wie kann ich denn sicherstellen, dass mir ein Hash und keine Referenz
übergeben wird?

Code: (dl )
die 'bad ...' if ref @_ eq 'HASH';


das klappt irgendwie nicht ...

ich könnte zwar mit

Code: (dl )
die 'bad ...' if ref $_[0] eq 'HASH';


prüfen, aber geht das nicht einfacher?
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
renee
 2005-12-19 06:54
#60970 #60970
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Wieso magst Du nicht die untere Version??
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
J-jayz-Z
 2005-12-19 11:20
#60971 #60971
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Sag mal, wann schlaft ihr den? ;)
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
Crian
 2005-12-19 11:33
#60972 #60972
User since
2003-08-04
5866 Artikel
ModeratorIn
[Homepage]
user image
ach, schlafen wird überschätzt ;)

Außerdem ist Renee ja down under...\n\n

<!--EDIT|Crian|1134984872-->
s--Pevna-;s.([a-z]).chr((ord($1)-84)%26+97).gee; s^([A-Z])^chr((ord($1)-52)%26+65)^gee;print;

use strict; use warnings; Link zu meiner Perlseite
renee
 2005-12-19 11:41
#60973 #60973
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
@Crian: Du muss doch nicht alles verraten *g*
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/
J-jayz-Z
 2005-12-19 11:44
#60974 #60974
User since
2005-04-13
625 Artikel
BenutzerIn
[Homepage] [default_avatar]
Ach komm schon, wir sind doch alle eine große Familie *gg* :p
perl -Mstrict -Mwarnings -e 'package blub; sub new { bless {} } sub bar {my $self=shift; $self->{bla}="5065726c2d436f6d6d756e697479"; return $self->{bla};} my $foo=blub->new();print "Hallo ";print pack("H*",$foo->bar()); print "\n"'

http://perl-tutor.de
esskar
 2005-12-19 12:29
#60975 #60975
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
[quote=J-jayz-Z,19.12.2005, 10:44]Ach komm schon, wir sind doch alle eine große Familie *gg* :p[/quote]
jaja, und dann nicht wissen, dass dein Bruder down-under ist. schöne familie. frohe weihnachten.
bloonix
 2005-12-19 14:22
#60976 #60976
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
[quote=renee,19.12.2005, 05:54]Wieso magst Du nicht die untere Version??[/quote]
[quote=renee,19.12.2005, 05:54]Wieso magst Du nicht die untere Version??[/quote]
weil ich sonst

Quote
die 'bad ...' if ref $_[0] eq 'HASH';
die 'bad ...' if ref $_[1] eq 'HASH';
die 'bad ...' if ref $_[2] eq 'HASH';
die 'bad ...' if ref $_[3] eq 'HASH';
die 'bad ...' if ref $_[4] eq 'HASH';
die 'bad ...' if ref $_[5] eq 'HASH';


prüfen müsste, oder nicht? Klar, mit einer Schleife könnte ich das
durchlaufen, aber ich dachte, da gäbe es irgendwie etwas, was ich noch
nicht kenne, halt sowas wie

Quote
die 'bad ...' if ref @_ eq 'HASH';


:-)
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
esskar
 2005-12-19 14:25
#60977 #60977
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
willst du jetzt swingend einen hashref oder zwingend einen hash haben ?
bloonix
 2005-12-19 14:29
#60978 #60978
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
ich möchte eigentlich beides zulassen
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.
<< |< 1 2 3 4 5 ... 12 >| >> 119 Einträge, 12 Seiten



View all threads created 2005-12-19 02:24.