Thread subroutine mit foreach schleife (8 answers)
Opened by blaise4714 at 2007-05-14 19:26

topeg
 2007-05-15 00:06
#76722 #76722
User since
2006-07-10
2611 Artikel
BenutzerIn

user image
Dafür gibt es doch die Objektorientierung:
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
33
34
35
36
37
38
package liste;
sub new
{
  my $self={list=>[@_]};
  bless($self);
  return $self;
}

sub next
{
  my $self=shift(@_);
  my $l=$self->{list};
  push(@$l,shift(@$l));
  return $$l[0];
}

sub before
{
  my $self=shift(@_);
  my $l=$self->{list};
  unshift(@$l,pop(@$l));
  return $$l[0];
}

sub now
{ 
  my $self=shift(@_);
  return $$self->{list}[0];
}
package main;

my $list=liste::new(was, wie,wo,wann,wozu,wieso);

for(0..6)
{
  print $list->next();
  print "\n";
}

View full thread subroutine mit foreach schleife