On Thursday 12 April 2018 19:53:16 Shlomi Fish wrote:
> Perhaps see http://perldoc.perl.org/perlunitut.html - you may need to read
> the file as binary or iso8859-1 or whatever. Also see

Thanks for this Shlomi. I have looked into that before briefly when doing http 
gets and reading office documents, but this time I didn't think I was going 
to need this.

> https://github.com/shlomif/how-to-share-code-online and read what Andy
> noted.

I thought the problem with my concepts rather than the program itself.  The 
following code shows that I was wrong.

#!/usr/bin/perl 

use strict;
use warnings;

my $line="A û ü  û";
my @arr=($line=~/(\xc3.)/g);
my $tick="\xc3\xbc";
my $cross="\xc3\xbb";

foreach my $c (split //,$line) {
  printf "%s = %X %d\n",$c,ord($c),ord($c);
}
if ($line=~/\xc3\xbb/) { print "true\n";}
foreach my $a (@arr) {
  print "start\n";
  if ($a eq $tick)  { print "tick\n";}
  if ($a eq $cross) { print "cross\n";}
}

[root@lou inet]# ./t1
A = 41 65
  = 20 32
� = C3 195
� = BB 187
  = 20 32
� = C3 195
� = BC 188
  = 20 32
  = 20 32
� = C3 195
� = BB 187
true
start
cross
start
tick
start
cross
[root@lou inet]# 

When I went back to gvim I noticed that it started showing two column values 
as as go past these fields, which should have given me a clue.

My production code now includes the following working code:

my $tick="\xc3\xbc";
my $cross="\xc3\xbb";

my @ticks=($line=~/(\xc3.)/g);
if (scalar(@ticks) == 5) {
  if ($ticks[0] eq $tick) {$job{sj_mot}='true';}
  if ($ticks[1] eq $tick) {$wuw='true'; $job{sj_wait}=20;}
  if ($ticks[2] eq $tick) {$job{sj_c_car}='true';}
  # 3 = advisor which we don't use
  if ($ticks[4] eq $tick) {$job{sj_wait}=30;}
} else {
  debugprint(1,"incorrect tick/cross count returned");
}

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to