Just a couple of questions about your corrections: (All snippets are taken
from
the e-mail below.)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Shawn:
> sub parseFrom400 {
> my $value = @_[0];
^^^^^
John:
You want a scalar here, not an array slice.
my $value = $_[0];
Shawn:
Okay. I just put this in because I saw the syntax somewhere else. Why is
this better? It works fine as it is.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Shawn:
> my $delimiter = substr($value, 3, 1);
> if ($delimiter =~ /[0-9]./){
^
John:
Do you want to match any character except newline here or a literal
dot? Since $delimiter only contains one character trying to match two
characters will never work.
if ( $delimiter =~ /\d/ ) {
Shawn:
I wanted to find out if the character is numeric. I see that your line
above is exactly what I really wanted. It seems to be working, though.
The database I'm
ultimately populating with this data seems to be okay. Does what I wrote
do the same thing, although in an ugly way?
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Thank you,
Shawn
[EMAIL PROTECTED]
g To: [EMAIL PROTECTED]
cc:
10/17/2002 bcc:
04:57 PM Subject: Re: How can I open and read two
files at once in a loop? --
Thanks, and also here's a snippet someone
may fine useful...
Shawn Milochik wrote:
>
> I am working on a project which involves downloading files via FTP from
an
> AS/400, and I had to write a couple of functions because of the weird way
> IBM does things.
>
> The first function takes a value, and dependent upon the final character,
> does something to it.
>
> Rules:
> 1. If it is a letter, the letter represents a specific decimal amount,
and
> the number is negative.
> example: 4L = -3.7, or 6R = -6.3 <-- Note: these are not the actual
> numbers corresponding to the letters, I have the sub figure that out.
>
> 2. The close curly-brace '}' denotes that the value is negative.
> example: 4} = -4
>
> 3. All numeric means that the final character is the decimal amount.
> example 43 = 4.3
>
> The second function checks to see if the final character is numeric. If
it
> is not, the final character is a stand-in for a digit, and the entire
> statement is negative. Otherwise, the number stays as is.
> examples: 345M = -3452, 5634 = 5634
>
> Hope this is useful to someone. If not, maybe someone already has a
> resource for converting "mainframe" data types. If they do, I'd like to
> know about it.
>
> sub parseFrom400 {
> my $value = @_[0];
^^^^^
You want a scalar here, not an array slice.
my $value = $_[0];
> my $delimiter = substr($value, 3, 1);
> if ($delimiter =~ /[0-9]./){
^
Do you want to match any character except newline here or a literal
dot? Since $delimiter only contains one character trying to match two
characters will never work.
if ( $delimiter =~ /\d/ ) {
> $value = substr($value, 0, 3);
> }
> if ($delimiter =~ /[J-R]/){
> my $tempChar = ord($delimiter) - 73;
> $value += ($tempChar/10);
> $value = 0 - $value;
^^^
No need for the zero here.
$value = -$value;
> }else{
> if ($delimiter eq "}"){
> $value = 0 - $value;
$value = -$value;
> }else{
> $value = $value/10;
Can be shortened to:
$value /= 10;
> }
> }
>
> return $value;
> }
>
> sub parseFrom400_2 {
> my $value = @_[0];
my $value = $_[0];
> my $delimiter = substr($value, 7, 1);
>
> if ($delimiter =~ /[J-R]/){
> my $tempChar = ord($delimiter) - 73;
> $value *= 10;
> $value += $tempChar;
> $value = 0 - $value;
$value = -$value;
> }
>
> return $value;
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
**********************************************************************
This e-mail and any files transmitted with it may contain
confidential information and is intended solely for use by
the individual to whom it is addressed. If you received
this e-mail in error, please notify the sender, do not
disclose its contents to others and delete it from your
system.
**********************************************************************
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]