Thread next LABEL in Subroutinen: gibt es feinere Lösungswege? (9 answers)
Opened by bloonix at 2006-12-13 15:17

renee
 2006-12-13 16:32
#72511 #72511
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Oder wenn Du Methoden generisch aufrufen willst:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/perl

use strict;
use warnings;
use CGI;

MYLOOP: for(0..10){
$_ % 2 or test(CGI->new, 'header') and next;
print $_,"\n";
}

sub test{
my ($obj,$method) = @_;
no strict 'refs';
print $obj->$method();
}


Ausgabe:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
~/entwicklung 25> perl modulo.pl 
Content-Type: text/html; charset=ISO-8859-1

1
Content-Type: text/html; charset=ISO-8859-1

3
Content-Type: text/html; charset=ISO-8859-1

5
Content-Type: text/html; charset=ISO-8859-1

7
Content-Type: text/html; charset=ISO-8859-1

9
Content-Type: text/html; charset=ISO-8859-1
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/

View full thread next LABEL in Subroutinen: gibt es feinere Lösungswege?