split around \t

Discussion in 'Perl Misc' started by soup_or_power@yahoo.com, Aug 15, 2005.

  1. Guest

    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);

    }
    -]
     
    , Aug 15, 2005
    #1
    1. Advertising

  2. Paul Lalli Guest

    wrote:
    > 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
     
    Paul Lalli, Aug 15, 2005
    #2
    1. Advertising

  3. At 2005-08-15 10:29AM, <> wrote:
    > 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?

    --
    Glenn Jackman
    NCF Sysadmin
     
    Glenn Jackman, Aug 15, 2005
    #3
  4. Guest

    wrote:
    > 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

    --
    -------------------- http://NewsReader.Com/ --------------------
    Usenet Newsgroup Service $9.95/Month 30GB
     
    , Aug 15, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    492
  2. Piet
    Replies:
    0
    Views:
    601
  3. Carlos Ribeiro
    Replies:
    11
    Views:
    741
    Alex Martelli
    Sep 17, 2004
  4. Network/Software Buyer
    Replies:
    0
    Views:
    442
    Network/Software Buyer
    May 23, 2010
  5. trans.  (T. Onoma)

    split on '' (and another for split -1)

    trans. (T. Onoma), Dec 27, 2004, in forum: Ruby
    Replies:
    10
    Views:
    240
    Florian Gross
    Dec 28, 2004
Loading...

Share This Page