perl-unicode

Re: encoding...

2003-11-02 17:30:04
On Sun, 2 Nov 2003 23:24:41 +0000, John Delacour <JD(_at_)BD8(_dot_)COM> wrote:

Question 1.

In this script I would like for convenience' sake to use variables in 
the second line, but I don't seem to be able to do so.  Am I missing 
something or is is simply not possible?


$source = 'MacRoman';  # I want to use this in the next line
use encoding qw(  MacRoman  ), STDOUT => qw(  utf-8 ) ;

Should work if you initialize the variable in a BEGIN block:

    BEGIN { $source = 'MacRoman'; }
    use encoding $source, STDOUT => 'utf-8';

"use" is executed at compile time, so variables initialized at runtime
won't be usable.

$text = "café" ;
print $text ;


Question 2

Is there a way, without using q(), to single-quote a block of text as 
one can double-quote it this way:

$text = <<EOT;

Yes, put single quotes around your EOT marker:

    $text = <<'EOT';

$ome$tuff
$ome$tuff
$ome$tuff
EOT
#

I want to be able to quote a block of JIS-encoded stuff (which 
contains lots of $)

Cheers,
-Jan

<Prev in Thread] Current Thread [Next in Thread>