split around \t

S

soup_or_power

Hi
Can anyone please help me figure out why the following embedded
perl code doesn't produce the desired result when the $upstr is split
with "\t"?

[!
use FileHandle();
!]

[-

if ($fdat{upload}) {

my $FILEHANDLE = $fdat{dn_file};
my $buffer = '';

while ( read( $FILEHANDLE, $buffer, 9320) ) {
$upstr .= $buffer;
}
close($FILEHANDLE);
my $fd = '\t';
if ($fdat{outfs} eq 'tab') {
$fd = '\t';
} elsif ($fdat{outfs} eq 'semicolon') {
$fd = ';';
} elsif ($fdat{outfs} eq 'colon') {
$fd = ':'
} elsif ($fdat{outfs} eq 'pipe') {
$fd = '|';
}

$upstr =~ s/$fd/\|/g;
@up_arr = split(/\r?\n/, $upstr);
$upstr = join("\%", @up_arr);

}
-]
 
P

Paul Lalli

Hi
Can anyone please help me figure out why the following embedded
perl code doesn't produce the desired result when the $upstr is split
with "\t"?

The perl code you posted does not do any splits on "\t". It does a
split on '\t'. Very different.

Only double quoted strings interpolate. Single quoted strings do not.

Paul Lalli
 
G

Glenn Jackman

At 2005-08-15 10:29AM said:
Hi
Can anyone please help me figure out why the following embedded
perl code doesn't produce the desired result when the $upstr is split
with "\t"? [...]
my $fd = '\t'; [...]
$upstr =~ s/$fd/\|/g;
@up_arr = split(/\r?\n/, $upstr);
$upstr = join("\%", @up_arr);

Where does your string get split with \t?
 
X

xhoster

Hi
Can anyone please help me figure out why the following embedded
perl code doesn't produce the desired result when the $upstr is split
with "\t"?

"split" occurs only once in the code you posted. \t is not involved.
@up_arr = split(/\r?\n/, $upstr);


Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top