Japhy:  Thanks very much for the answer.

Everybody:

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];
    my $delimiter = substr($value, 3, 1);
    if ($delimiter =~ /[0-9]./){
        $value = substr($value, 0, 3);
    }
    if ($delimiter =~ /[J-R]/){
        my $tempChar = ord($delimiter) - 73;
        $value += ($tempChar/10);
        $value = 0 - $value;
    }else{
        if ($delimiter eq "}"){
            $value = 0 - $value;
        }else{
            $value = $value/10;
        }
    }

    return $value;
}

sub parseFrom400_2 {
    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;
    }

    return $value;
}

Shawn




                                                                                       
                            
                    japhy@perlmon                                                      
                            
                    k.org                To:     [EMAIL PROTECTED]         
                            
                                         cc:     [EMAIL PROTECTED]                    
                            
                    10/17/2002           bcc:                                          
                            
                    11:53 AM             Subject:     Re: How can I open and read two 
files at once in a loop?     
                    Please                                                             
                            
                    respond to                                                         
                            
                    japhy                                                              
                            
                                                                                       
                            
                                                                                       
                            




On Oct 17, [EMAIL PROTECTED] said:

>while (<FIRSTIN><SECONDIN>){
>     #assume $otherData would be the $_ from <SECONDIN>
>     print FIRSTOUT "$_\n";
>     print SECONDOUT "$otherData, $_\n";
>
>}

Like so:

  while (<FIRSTIN>) {
    my $otherData = <SECONDIN>;
    print FIRSTOUT $_;
    print SECONDOUT $otherData, $_;
  }

--
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


--
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]

Reply via email to