Thread Separator mittels Variable??? (10 answers)
Opened by Gast at 2004-07-23 11:20

renee
 2004-07-23 12:51
#84806 #84806
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
Dann mach es so:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sub   fill_table{ 
my ($datei,$src_path,$delimiter,$header,$type) = @_;

open (IFILE, "< $src_path$datei") or die "can't open $src_path$datei: $!\n";
my $z = 0;
while(my $BomLine = <IFILE>){
$z++;
my @Bom = ();
if($type eq 'RegEx'){
@Bom = split(/$delimiter/, $BomLine);
}
else{
@Bom = split(/\Q$delimiter/, $BomLine);
}
for (0..(scalar(@Bom) -1)){
$arrayVar->{$z.','.($_ + 1)} = $Bom[$_];
}
}
close IFILE;
}


Und die möglichen Aufrufe: (RegEx)
Code: (dl )
1
2
3
4
5
6
7
my $delim = '\s+'; # wichtig: Hochkommas benutzen!
my $file = 'test2.txt';
my $path = '';
my $head = 'irgendwas';
my $type = 'RegEx';

fill_table($file,$path,$delim,$head,$type);


bzw. (keine Regex, sondern normaler String):
Code: (dl )
1
2
3
4
5
6
7
my $delim = '|';
my $file = 'test2.txt';
my $path = '';
my $head = 'irgendwas';
my $type = 'Char';

fill_table($file,$path,$delim,$head,$type);
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 Separator mittels Variable???