When I run that "hello.pl" in PS-ISE, it prints "Hello world" fine.
But, I would like to interact with the console, using Unicode characters. When I run this program, it hangs (doesn't even print the first message, which should be straightforward):

#!/usr/local/bin/perl # Load a conversion table from CONVTABLE to %ConvTable. Then find mat +ches in a file and convert them. use strict; use warnings; use Encode; use 5.014; use utf8; use diagnostics; use autodie; use warnings qw< FATAL utf8 >; use open qw< :std :utf8 >; use charnames qw< :full >; use feature qw< unicode_strings >; my ($i,$j,$InputFile, $OutputFile,$word,$from,$to,$linetoprint); my (@line, @lineout); my %ConvTable; # Conversion hash my ($CONVTABLE, $INPUT, $OUTPUT); print 'Conversion table: opening file: E:\My Documents\Technical\Perl +\Conversion table 1.txt'."\n"; my $sta= open ($CONVTABLE, "<:encoding(utf8)", 'E:\My Documents\Techn +ical\Perl\Conversion table 1.txt'); binmode STDOUT, ':utf8'; # output should be in UTF-8 binmode $DB::OUT, ':utf8' if $DB::OUT; # for the debugger # Load conversion hash while (<$CONVTABLE>) { chomp; print "$_\n"; @line = split; $/=','; chomp(@line); # Chomp chomps a variable if its last char equals $/ $/="\n"; # Restore $/ $ConvTable{$line[0]}=$line[1]; } # end while (<$CONVTABLE>) while ( ($i,$j) = each (%ConvTable) ) { print "$i => $j\n"; } # Open file to convert print "Input to convert: enter path\\fileName: "; $InputFile = <STDIN>; chomp($InputFile); print "\$InputFile=\"$InputFile\"\n"; $sta = open ($INPUT, "<:encoding(utf8)", $InputFile); # Open output file print "OUTPUT: enter path and fileName: "; $OutputFile = <STDIN>; chomp($OutputFile); print "\$OutputFile= \"$OutputFile\"\n"; $sta = open ($OUTPUT, ">:encoding(utf8)", ">$OutputFile"); # Iterate over lines of INPUT, convert according to %ConvTable, store +in OUTPUT while (<$INPUT>) { chomp; @line = split; foreach $word(@line) { while (($from, $to) = each(%ConvTable)) { # traverse the conv +ersion table. # check if there ar +e any matches in the word and substitue $word =~ s/$from/$to/; # substitute substrings if match } # end value in %ConvTable push(@lineout, $word); } # end foreach string in the line $linetoprint = join (", ",@lineout); print ($OUTPUT, "$linetoprint\n"); $#lineout= (-1); # empty @lineout } # end while over INPUT file

Should I flush the STDOUT buffer? How to do it?


In reply to Re^2: How to interact with the console (input/output) running a Perl program on “Windows Power Shell ISE”? by HelenCr
in thread How to interact with the console (input/output) running a Perl program on “Windows Power Shell ISE”? by HelenCr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.