in reply to input special characters

Well, the simplest solution is to provide a literal tab character (rather than two characters: backslash and t). Alternatively, you can try to make a tab out of backslash-t with eval.
use strict; use warnings; my $t = '\\t'; print "$t:\n"; my $evaled = eval "qq/$t/"; print "$evaled:\n"
Result:
\t: :

(perlmonks changes literal tab to several spaces, heh)

Than again, maybe eval is more trouble than it's worth. I'd say a hash with all separators that you want to use would work better:
my %seps = ( '\\t' => "\t", '\\n' => "\n", # etc ); my $input = <>; my $separator = $seps{$input};

Replies are listed 'Best First'.
Re^2: input special characters
by kepler (Scribe) on Jul 13, 2014 at 13:17 UTC
    That works great... :) I was trying to substitute the "\" because of the \xhh character with hex. code hh. It's not working. Thanks. Kepler.
      If you decided to use eval, you should really consider this:
      # file eval.pl use strict; use warnings; my $sep = shift @ARGV; my $evaled = eval "qq/$sep/"; print "$evaled:\n"
      Now the user enters this:
      perl eval.pl 'hehe/; print "Hello there!\n"; unlink "./eval.pl"; q/foo +'
      Result:
      Useless use of a constant ("hehe") in void context at (eval 1) line 1. Hello there! foo:
      And the eval.pl file is gone. So, yeah... as I said, eval is usually more trouble than it's worth. Maybe consider module Safe, which provides restricted eval, if you're dealing with users there (users are evil).