Hello,
I am new to Perl - and so far I am enjoying it. Unfortunately I do not have the luxury to start completely from scratch. I have here a problem that i am struggling to solve. I have spent many hours trying to solve this issue without any success, hence why I am asking (or begging whichever makes you feel better ;)) for help.
Problem
In Isodraw (technical illustration app) I am exporting a filename to a text file. Perl accesses the file, and places the text into a variable. I compare this variable to cell data within a spreadsheet until a positive match is made. I have everything working perfectly except that when Perl reads the text inside the text file it reads it differently:
V6558-04505-011_01 (Original - Text File)
■V 6 5 5 8 - 0 4 5 0 5 - 0 1 1 _ 0 1 (PROBLEM - Perl)
From my research it is due to different encoding. Now my options within Isodraw when creating the text file are either UNICODE or 8-bit ASCII. Neither has a good result in Perl, but I cannot change this inside Isodraw so Perl has to do it. (Note: if I manually save the text file out in notepoad to ANSI perl reads it perfectly).
I desperately need some assistance this is currently beyond my knowledge if anyone can help I would really appreciate it.
Many thanks
Alan
Example code
#!/usr/bin/perl -w
use v5.10.0;
use strict;
############# READ NOTE HERE ##############
###### -Uncomment below to see it working perfectly!
#our $VarFileName = "V6558-01501-011_01";
##### IF you wish to see it reading from the file comment above and uncomment Notes Y and Z.
my $record;
our $VarFileName; ############ NOTE Y
my $VarISS = "VarISS_TestValue";
my $VarICN = "VarICN_TestValue";
############## READ FILE FROM ISODRAW ##################
open (ReadFILE, "<D:/ForJim/FROM_ISODRAW.txt") or die "couldn't open the file!";
while ($record = <ReadFILE>)
{
say $record;
chomp($record);
$VarFileName = $record; ############ NOTE Z
}
#############################
#############################
my $VarComparison = "V6558-01501-011_01"; ### TEMP
if ($VarComparison eq $VarFileName)
{
say "MATCH!!!";
} else {
say "NOT THE SAME!";
}
#say our $varFilename;