[ic] This is *very* weird...

continuumdata interchange-users@icdevgroup.org
Fri Oct 18 17:55:02 2002


Cutting and pasting often grabs/creates extra whitepace characters-
noticeably carriage returns.  If you viewed the file in vi you'd probably
see them.  You need to edit them with an editor that lets you see them
before you paste.

It's the same reason why in mysql you don't want to cut and paste the
mysqldump output back into mysql.  You want to use the proper method of
restoring.

The weird explained.

This should be the X files.....
----- Original Message -----
From: "Interchange user" <interchange.mail@virgin.net>
To: <interchange-users@icdevgroup.org>
Sent: Friday, October 18, 2002 4:50 PM
Subject: [ic] This is *very* weird...


> (Was Re: [ic] Prevent from ordering more than is in stock)
>
> OK, I was trying to figure out why the following code wasn't working,
pasted
> into KEdit from KMail:
>
>
> [perl tables=inventory]
> my $item;
> foreach $item (@{$Carts->{main}}) {
> my $on_hand = tag_data('inventory', 'quantity', $item->{code});
> next if $on_hand >= $item->{quantity};
> if ($on_hand<=0) {
> $item->{quantity} = 0;
> $item->{q_message} = "Item is currently out of stock.";
> } else {
> $item->{quantity} = $on_hand;
> $item->{q_message} = "Limited item stock, order quantity adjusted.";
> }
> }
> [/perl]
>
>
> In the end, I decided to rewrite it from scratch as follows:
>
>
> [perl tables="inventory" failure="Error"]
>   my $item;
>   for $item(@$Items) {
>     my $on_hand = tag_data('inventory', 'quantity', $item->{code});
>     next if $on_hand >= $item->{quantity};
>     if ($on_hand <= 0) {
>       $item->{quantity} = 0;
>       $item->{q_message} = "Item is currently out of stock.";
>     } else {
>       $item->{quantity} = $on_hand;
>       $item->{q_message} = "Limited item stock, order quantity adjusted.";
>     }
>   }
> [/perl]
>
>
> It worked, but I was interested to know what was wrong with the original
> code, so I copied bits from my version to try and narrow down the problem,
> until I eventually ended up with an *identical* copy (yes, I'm sure) and
it
> still wouldn't work! I also re-typed the whole original listing, and it
> worked!
>
> So I had these four segments of code in the same page; the original pasted
> code, my rewritten code, the edited original, and the re-typed original -
> only the rewritten and re-typed versions worked.
>
> WTF? If the ASCII characters are identical, why is pasting the code having
> this effect?! I copied it into a hex editor and didn't notice any extra
> special characters. Weird.
> _______________________________________________
> interchange-users mailing list
> interchange-users@icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users
>