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
#!/usr/bin/perl
use strict;
use warnings;
my $line = '~1~,,~234~,7,~,,~,8';
my $newline = ""; # löl
my $in = 0;
for my $i ( 0 .. length($line) ) {
my $c = substr($line, $i, 1);
$newline .= $c;
print $newline;
# determine whenever we are in a field or outside.
if( $in == 0 and $c eq '~' ) {
# now we're in a field
$in = 1;
next;
}if( $in == 1 and $c eq '~' ) {
# now we're going outside to play hide and ...
$in = 0;
next;
}if( $in == 0 and $c eq ',' ) {
# we're outside, now check if next char is a , too
if( substr($line, $i, 2) eq ',,' ) {
print ' -> ' . substr($line, $i, 2);
$newline .= '~~';
}
}
print "\n";
}
print( $newline );
2009-05-25T11:24:29 pktmAuch mit normalen Quotes wirft phMyAdmin hier leere Felder ohne Quotes.
$line=s/((?:^|,)(?:~[^~]*~|[^,]*)|,)/$_=($1 eq ",")? ",~~": $1/ge;
1
2
3
$_='~1~,,~234~,7,~,,~,8,~223~,,9';
s/(~\d\d*~)(,,)/\1,~~,/g;
~1~,~~,~234~,7,~,,~,8,~223~,~~,9