C
Chris Hamel
Greetings.
I am currently dealing with a dataset that is purely numeric, and some
time next year the data will be migrated to alphanumeric. The data is
structured such that the highest values represent the oldest entity
(reverse sort, essentially). This is signficiant to us when we process
the data in our system because there are times we need to sort the
orders from oldest to newest so we allocate them consistent with how
the source system allocates them.
Here's the rub: the source system is an IBM mainframe that is
assigning the values backwards in EBCDIC. Our system is on an AIX
server.
So, if I'm looking at four orders:
1 2 A B
The mainframe has created them in this order:
2 1 A B
But a descending sort in Perl will put them in this order:
B A 2 1
I looked in the Perl documentation, which basically suggests that I: 1)
get over it (not possible) 2) sort in only one system (not possible) or
3) convert, sort, re-convert. My only option of these is the third.
I'm thinking of something like this:
tr/0-9A-Za-z/a-zA-Z0-9/ for @list_of_orders;
@list_of_orders = sort @list_of_orders;
tr/a-zA-Z0-9/0-9A-Za-z/ for @list_of_orders;
This is conceptual, as the actual code will obviously have a lot more
gunk around it and resides in several programs. Am I on track? Are
there better ways? Has anyone done this before? Am I creating
efficiency problems that I'm not aware of? Is there a module in CPAN
that does this better that has managed to hide from my searches?
I'm not opposed to using a system call to the Unix sort if it has
advantages. Memory will not be an issue.
I am still in the conceptual design phase but am looking for any
feedback. We have several months before we have to do this, but before
I go off and start changing dozens of programs I wanted to see if
anyone had any feedback.
Thanks in advance,
Chris
I am currently dealing with a dataset that is purely numeric, and some
time next year the data will be migrated to alphanumeric. The data is
structured such that the highest values represent the oldest entity
(reverse sort, essentially). This is signficiant to us when we process
the data in our system because there are times we need to sort the
orders from oldest to newest so we allocate them consistent with how
the source system allocates them.
Here's the rub: the source system is an IBM mainframe that is
assigning the values backwards in EBCDIC. Our system is on an AIX
server.
So, if I'm looking at four orders:
1 2 A B
The mainframe has created them in this order:
2 1 A B
But a descending sort in Perl will put them in this order:
B A 2 1
I looked in the Perl documentation, which basically suggests that I: 1)
get over it (not possible) 2) sort in only one system (not possible) or
3) convert, sort, re-convert. My only option of these is the third.
I'm thinking of something like this:
tr/0-9A-Za-z/a-zA-Z0-9/ for @list_of_orders;
@list_of_orders = sort @list_of_orders;
tr/a-zA-Z0-9/0-9A-Za-z/ for @list_of_orders;
This is conceptual, as the actual code will obviously have a lot more
gunk around it and resides in several programs. Am I on track? Are
there better ways? Has anyone done this before? Am I creating
efficiency problems that I'm not aware of? Is there a module in CPAN
that does this better that has managed to hide from my searches?
I'm not opposed to using a system call to the Unix sort if it has
advantages. Memory will not be an issue.
I am still in the conceptual design phase but am looking for any
feedback. We have several months before we have to do this, but before
I go off and start changing dozens of programs I wanted to see if
anyone had any feedback.
Thanks in advance,
Chris