Thread split Problem (3 answers)
Opened by perli at 2006-10-11 19:16

bloonix
 2006-10-11 20:29
#70692 #70692
User since
2005-12-17
1615 articles
HausmeisterIn
[Homepage]
user image
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use strict;
use warnings;
use Data::Dumper;

my $text = "foo##loop nase## foo  ##if nase-kz_gesetzt## foo\n##loop nase##foo ##if nase-kz_gesetzt##foo";

my @foo = split /(##.+?##)/, $text;
my @bar = split /##(.+?)##/, $text;
my @foobar = ($text =~ /##(.+?)##/g);

chomp(@foo,@bar,@foobar);

print Dumper(\@foo);
print Dumper(\@bar);
print Dumper(\@foobar);


$VAR1 = [
         'foo',
         '##loop nase##',
         ' foo  ',
         '##if nase-kz_gesetzt##',
         ' foo',
         '##loop nase##',
         'foo ',
         '##if nase-kz_gesetzt##',
         'foo'
       ];
$VAR1 = [
         'foo',
         'loop nase',
         ' foo  ',
         'if nase-kz_gesetzt',
         ' foo',
         'loop nase',
         'foo ',
         'if nase-kz_gesetzt',
         'foo'
       ];
$VAR1 = [
         'loop nase',
         'if nase-kz_gesetzt',
         'loop nase',
         'if nase-kz_gesetzt'
       ];



Aber nu sach ma, so aus reiner Neugier... erfindest du gerade das Rad
neu? Du weißt doch hoffentlich, dass es da schon zwei hervorragende
Module für gibt, oder? =)

CPAN:HTML Template
CPAN:HTML Template Compiled\n\n

<!--EDIT|opi|1160584319-->
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.

View full thread split Problem