in reply to input special characters

Depending on what you mean by "input", be sure to put your separator in double quotes, not single quotes.

my @data = ("a", "b", "c"); say join "\t", @data; say join '\t', @data;

prints:

$ perl test.pl a b c a\tb\tc $

See perlop's section on quotes and quote-like operators.

Replies are listed 'Best First'.
Re^2: input special characters
by kepler (Scribe) on Jul 13, 2014 at 10:40 UTC
    Hi, The input is $char = <>: Then I use it like this: $out = "Field1$charField2$char....." Regards, Kepler

      I'm not sure what the issue is, then. Take this snippet of code:

      chomp(my $sep = <>); say join $sep, @data;

      if I run this (with the above @data) and input a tab character, I do indeed get the output separated by tabs. Or do you want to be able to input the characters "\t" and have them interpreted as a tab, rather than a literal backslash followed by a literal lower-case t? In that case, you can use a regular expression to transform your separator:

      chomp(my $sep = <>); $sep =~ s/\\t/\t/g; say join $sep, @data;
        Hi, Your code is brilliant - problem solved! Thank you very much :) But I was thinking....is there a way to apply this to all special characters (\t, \n, ....etc)? Kind regards, Kepler