Thread pointer auf array und hash (Inline::C) (13 answers)
Opened by Graf Herschel at 2010-11-26 15:05

topeg
 2010-11-26 16:22
#143077 #143077
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Meinst du so was?:
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
30
31
32
#!/usr/bin/perl;
use strict;
use warnings;

my $typles_ref1;
if(function(\$typles_ref1,"array"))
{
  print "ARRAY:\n";
  print join(', ',@$typles_ref1)."\n";
}

my $typles_ref2;
if(function(\$typles_ref2,"hash"))
{
  print "HASH:\n";
  while(my($k,$v)=each(%$typles_ref2))
  { print "$k = $v\n"; }
}

######################################################

sub function
{
  my($ref,$type)=@_;
  return 0 if($type ne 'array' and $type ne 'hash');

  $$ref=[qw(var1 var2 var3)] if($type eq 'array');
  
  $$ref={qw(key1 var1 key2 var2)} if($type eq 'hash');

  return 1;
}

View full thread pointer auf array und hash (Inline::C)