Strange observation 
Author Message
 Strange observation

This is working
elsif ($read[7] == 70) {
           $read[0]=$REAL_VALUE[$i][14];   # save
REAL_VALUE[14]..REAL_VALUE[19].
           $read[1]=$REAL_VALUE[$i][15];            
           $read[2]=$REAL_VALUE[$i][16];
           $read[3]=$REAL_VALUE[$i][17];            
           $read[4]=$REAL_VALUE[$i][18];
           $read[5]=$REAL_VALUE[$i][19];
           $read[6]=$REAL_VALUE[$i][20];            
           $read[15]=$REAL_VALUE[$i][21];
           $read[8]=$REAL_VALUE[$i][22];            
           $read[9]=$REAL_VALUE[$i][23];
           $read[10]=$REAL_VALUE[$i][24];            
           $read[11]=$REAL_VALUE[$i][25];            
           $read[12]=$REAL_VALUE[$i][26];
           $read[13]=$REAL_VALUE[$i][27];            
           $read[14]=$REAL_VALUE[$i][28];

           printf TEMP_FILE
("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
$read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[15],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[7]);
and this is not how come ??
elsif ($read[16] == 70) {
           $read[0]=$REAL_VALUE[$i][14];   # save
REAL_VALUE[14]..REAL_VALUE[19].
           $read[1]=$REAL_VALUE[$i][15];            
           $read[2]=$REAL_VALUE[$i][16];
           $read[3]=$REAL_VALUE[$i][17];            
           $read[4]=$REAL_VALUE[$i][18];
           $read[5]=$REAL_VALUE[$i][19];
            $read[6]=$REAL_VALUE[$i][20];            
           $read[7]=$REAL_VALUE[$i][21];
           $read[8]=$REAL_VALUE[$i][22];            
           $read[9]=$REAL_VALUE[$i][23];
           $read[10]=$REAL_VALUE[$i][24];            
             $read[11]=$REAL_VALUE[$i][25];            
           $read[12]=$REAL_VALUE[$i][26];
           $read[13]=$REAL_VALUE[$i][27];            
           $read[14]=$REAL_VALUE[$i][28];

           printf TEMP_FILE
("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
$read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[7],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[16]);

i am trying to read the following line:
12 12 23 34 54 56 67 87 89 90 90 97 12 14 15                  7
0
forget about the spaces in the input line why is this happening



Tue, 22 Nov 2005 22:46:37 GMT  
 Strange observation

Quote:

> This is working
> elsif ($read[7] == 70) {
>            $read[0]=$REAL_VALUE[$i][14];   # save
> REAL_VALUE[14]..REAL_VALUE[19].
>            $read[1]=$REAL_VALUE[$i][15];            
>            $read[2]=$REAL_VALUE[$i][16];
>            $read[3]=$REAL_VALUE[$i][17];            
>            $read[4]=$REAL_VALUE[$i][18];
>            $read[5]=$REAL_VALUE[$i][19];
>       $read[6]=$REAL_VALUE[$i][20];            
>            $read[15]=$REAL_VALUE[$i][21];
>            $read[8]=$REAL_VALUE[$i][22];            
>            $read[9]=$REAL_VALUE[$i][23];
>            $read[10]=$REAL_VALUE[$i][24];            
>       $read[11]=$REAL_VALUE[$i][25];            
>            $read[12]=$REAL_VALUE[$i][26];
>            $read[13]=$REAL_VALUE[$i][27];            
>            $read[14]=$REAL_VALUE[$i][28];

>            printf TEMP_FILE
> ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
> $read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[15],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[7]);
> and this is not how come ??
> elsif ($read[16] == 70) {
>            $read[0]=$REAL_VALUE[$i][14];   # save
> REAL_VALUE[14]..REAL_VALUE[19].
>            $read[1]=$REAL_VALUE[$i][15];            
>            $read[2]=$REAL_VALUE[$i][16];
>            $read[3]=$REAL_VALUE[$i][17];            
>            $read[4]=$REAL_VALUE[$i][18];
>            $read[5]=$REAL_VALUE[$i][19];
>        $read[6]=$REAL_VALUE[$i][20];            
>            $read[7]=$REAL_VALUE[$i][21];
>            $read[8]=$REAL_VALUE[$i][22];            
>            $read[9]=$REAL_VALUE[$i][23];
>            $read[10]=$REAL_VALUE[$i][24];            
>         $read[11]=$REAL_VALUE[$i][25];            
>            $read[12]=$REAL_VALUE[$i][26];
>            $read[13]=$REAL_VALUE[$i][27];            
>            $read[14]=$REAL_VALUE[$i][28];

>            printf TEMP_FILE
> ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
> $read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[7],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[16]);

> i am trying to read the following line:
> 12 12 23 34 54 56 67 87 89 90 90 97 12 14 15                  7
> 0
> forget about the spaces in the input line why is this happening

Sheesh!

Slices are your friend for this sort of thing:

if( $read[7] == 70 ){

Quote:
}

As to why the second elsif is not working:  there appear to be only
16 fields in your input data yet you are trying an equality on the
17th element ( $read[16] ).  Is this what you want to do?

s.



Wed, 23 Nov 2005 00:24:06 GMT  
 Strange observation

Quote:

> This is working
> elsif ($read[7] == 70) {
>            $read[0]=$REAL_VALUE[$i][14];   # save
> REAL_VALUE[14]..REAL_VALUE[19].
>            $read[1]=$REAL_VALUE[$i][15];
>            $read[2]=$REAL_VALUE[$i][16];
>            $read[3]=$REAL_VALUE[$i][17];
>            $read[4]=$REAL_VALUE[$i][18];
>            $read[5]=$REAL_VALUE[$i][19];
>            $read[6]=$REAL_VALUE[$i][20];
>            $read[15]=$REAL_VALUE[$i][21];
>            $read[8]=$REAL_VALUE[$i][22];
>            $read[9]=$REAL_VALUE[$i][23];
>            $read[10]=$REAL_VALUE[$i][24];
>            $read[11]=$REAL_VALUE[$i][25];
>            $read[12]=$REAL_VALUE[$i][26];
>            $read[13]=$REAL_VALUE[$i][27];
>            $read[14]=$REAL_VALUE[$i][28];

>            printf TEMP_FILE
> ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
> $read[0],$read[1],$read[2],$read[3],$read[4],$read[5],$read[6],$read[15],$read[8],$read[9],$read[10],$read[11],$read[12],$read[13],$read[14],$read[7]);

You can simplify that code a bit:

elsif ( $read[ 7 ] == 70 ) {


];
    }

Quote:
> and this is not how come ??
> elsif ($read[16] == 70) {

Perhaps the value in $read[16] is not equal to 70?

John
--
use Perl;
program
fulfillment



Wed, 23 Nov 2005 01:13:29 GMT  
 Strange observation

: This is working
: elsif ($read[7] == 70) {
:            $read[0]=$REAL_VALUE[$i][14];   # save REAL_VALUE[14]..REAL_VALUE[19].
:            $read[1]=$REAL_VALUE[$i][15];            
[etc.]
:            printf TEMP_FILE
: ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
: $read[0],$read[1],$read[2],$read[3],
[etc.]

That's awful.  Array slicing and the '..' operator will help you
tremendously.


    printf TEMP_FILE
        "%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",

: and this is not how come ??
: elsif ($read[16] == 70) {
:            $read[0]=$REAL_VALUE[$i][14];   # save REAL_VALUE[14]..REAL_VALUE[19].
:            $read[1]=$REAL_VALUE[$i][15];            
[etc.]
:            printf TEMP_FILE
: ("%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",
: $read[0],$read[1],$read[2],$read[3],
[etc.]

Same thing.


    printf TEMP_FILE
        "%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%4d%20d\n",

: i am trying to read the following line:
: 12 12 23 34 54 56 67 87 89 90 90 97 12 14 15                  7
: 0

Spiffy.  What does that mean?  Which elements of which array are those
numbers being place in?

: forget about the spaces in the input line

Looks like your newsreader's auto-linewrap wrecked it anway.

: why is this happening

You haven't described what is happening.  "Does work" and "doesn't
work" describe nothing about what the code does or does not do.

As a WAG, I'd guess "doesn't work" means you're expecting
the value in $read[16] to be equal to 70, but Perl thinks differently.
Probably because you're counting array elements starting at 1 instead
of 0.



Wed, 23 Nov 2005 03:06:37 GMT  
 Strange observation
Basically there are 18 fields in the input line 15 are present and are
assigned some values 16 and17 the application takes default value and
the 20the field is the identifier 70. which i am trying to compare and
hence the ifels loop to compare the $read==70 or not. My problem is
there are 80 columns and each numberis given 4 columns. If i use
$read[7]==70 it is working and printing the numbers but if i use
$read[16]==70 its not working which it is supposed to and the line
formatting is same %4d * 15 %20d = 80 columns 15 for 15 numbers and
then forgetting some default values after these numbers nad moving to
end of the line which is 70 hence %20d. Now my question is why is the
order not working like read[16] as the end of the line and read[7] is
working fine.


Wed, 23 Nov 2005 19:57:24 GMT  
 Strange observation

Quote:
>Basically there are 18 fields in the input line 15 are present and are
>assigned some values 16 and17 the application takes default value and
>the 20the field is the identifier 70. which i am trying to compare and
>hence the ifels loop to compare the $read==70 or not. My problem is
>there are 80 columns and each numberis given 4 columns. If i use
>$read[7]==70 it is working and printing the numbers but if i use
>$read[16]==70 its not working which it is supposed to and the line
>formatting is same %4d * 15 %20d = 80 columns 15 for 15 numbers and
>then forgetting some default values after these numbers nad moving to
>end of the line which is 70 hence %20d. Now my question is why is the
>order not working like read[16] as the end of the line and read[7] is
>working fine.

use Data::Dumper and dump out the array before you get to the if.

use Data::Dumper;

also, my apologies if english is not your first language, but i have
no idea from your description exactly what it is that you are trying
to do.

-rs-



Fri, 25 Nov 2005 20:34:13 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Sorting observation

2. OT Observation of CPAN on diff't platforms

3. Sorting observation

4. an observation on why python will fail

5. An interesting observation

6. h2xs observation

7. LabOptionmenu observation!

8. Strange problem: strange character added during a mkdir

9. Strange $n behavior

10. Strange UTF error

11. strange interaction between perl and GNU find

12. Strange slowdown

 

 
Powered by phpBB® Forum Software