Sponsored Content
Top Forums Shell Programming and Scripting Perl - Iterating a hash through a foreach loop - unexpected results Post 45113 by quantumechanix on Monday 15th of December 2003 09:26:38 AM
Old 12-15-2003
here is my output:

1 => Current: 101.2 Last: 101.2 Last - Current: 0 Slice Thickness: 3
1 => Current: 98.2 Last: 101.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 95.2 Last: 98.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 92.2 Last: 95.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 89.2 Last: 92.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 86.2 Last: 89.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 83.2 Last: 86.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 80.2 Last: 83.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 77.2 Last: 80.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 74.2 Last: 77.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 71.2 Last: 74.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 68.2 Last: 71.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 65.2 Last: 68.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 62.2 Last: 65.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 59.2 Last: 62.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 56.2 Last: 59.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 53.2 Last: 56.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 50.2 Last: 53.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 47.2 Last: 50.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 44.2 Last: 47.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 41.2 Last: 44.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 38.2 Last: 41.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 35.2 Last: 38.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 32.2 Last: 35.2 Last - Current: 3 Slice Thickness: 3

It appears a slice is missing between 32.2 and 29.2.
3 => Current: 29.2 Last: 32.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 26.2 Last: 29.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 23.2 Last: 26.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 20.2 Last: 23.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 17.2 Last: 20.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 14.2 Last: 17.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 11.2 Last: 14.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 8.2 Last: 11.2 Last - Current: 3 Slice Thickness: 3

2 => Current: 5.2 Last: 8.2 Last - Current: 3 Slice Thickness: 3
1 => Current: 2.2 Last: 5.2 Last - Current: 3 Slice Thickness: 3
1 => Current: -0.8 Last: 2.2 Last - Current: 3 Slice Thickness: 3
1 => Current: -3.8 Last: -0.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -6.8 Last: -3.8 Last - Current: 3 Slice Thickness: 3

It appears a slice is missing between -6.8 and -9.8.
3 => Current: -9.8 Last: -6.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -12.8 Last: -9.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -15.8 Last: -12.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -18.8 Last: -15.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -21.8 Last: -18.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -24.8 Last: -21.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -27.8 Last: -24.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -30.8 Last: -27.8 Last - Current: 3 Slice Thickness: 3

4 => Current: -33.8 Last: -30.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -36.8 Last: -33.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -39.8 Last: -36.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -42.8 Last: -39.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -45.8 Last: -42.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -48.8 Last: -45.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -51.8 Last: -48.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -54.8 Last: -51.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -57.8 Last: -54.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -60.8 Last: -57.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -63.8 Last: -60.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -66.8 Last: -63.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -69.8 Last: -66.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -72.8 Last: -69.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -75.8 Last: -72.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -78.8 Last: -75.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -81.8 Last: -78.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -84.8 Last: -81.8 Last - Current: 3 Slice Thickness: 3
1 => Current: -87.8 Last: -84.8 Last - Current: 3 Slice Thickness: 3
~fin~
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Foreach loop to run a perl script on multiple files

Hi, I have thousands of files in a directory that have the following 2 formats: 289620178.aln 289620179.aln 289620180.aln 289620183.aln 289620184.aln 289620185.aln 289620186.aln 289620187.aln 289620188.aln 289620189.aln 289620190.aln 289620192.aln.... and: alnCDS_1.fasta (1 Reply)
Discussion started by: greptastic
1 Replies

2. UNIX for Advanced & Expert Users

Perl loop txt and check if a hash key

Hi, The task i have to do is to 1- create a database contains the Names .run the query and store results in hash make the Name field is the hash key 2- in the same time i have a txt which i will loop through it word by word and check for each word if a hash key ( compare it with the Names in... (0 Replies)
Discussion started by: eng_shimaa
0 Replies

3. Shell Programming and Scripting

Not able to store the results of perl recursive function when applied under for loop

Hi Perl Gurus , need URGENT HELP PLEASE !!!!! I have one recursive Perl function which takes path of any directory as argument and returns array containing all the sub folders inside it recursively. Now the problem is that it works well if i use it with one time but the problem is that when... (0 Replies)
Discussion started by: anthriksh2000
0 Replies

4. Shell Programming and Scripting

Problem iterating in while loop

I am facing a problem in replacing the file contents by iterating through the list. My present code: Code: #!/bin/bash# TFILE="/tmp/vinay/testb_1.txt" while read linedo aline="$line" echo $aline code=`echo $aline|cut -d ',' -f1` country=`echo $aline|cut -d... (5 Replies)
Discussion started by: av_vinay
5 Replies

5. Programming

PERL, search and replace inside foreach loop

Hello All, Im a Hardware engineer, I have written this script to automate my job. I got stuck in the following location. CODE: .. .. ... foreach $key(keys %arr_hash) { my ($loc,$ind,$add) = split /,/, $arr_hash{$key}; &create_verilog($key, $loc, $ind ,$add); } sub create_verilog{... (2 Replies)
Discussion started by: riyasnr007
2 Replies

6. Shell Programming and Scripting

iterating over results from sqlplus

hi all, i am writing a ksh script, i am logging into an oracle db via sqlplus and running a select statement but i dont know how i can store the results from the sql so i can iterate over it and do more operations over it. I dont want to write a stored procedure with a cursor since i need to... (2 Replies)
Discussion started by: cesarNZ
2 Replies

7. Shell Programming and Scripting

Compare values of hashes of hash for n number of hash in perl without sorting.

Hi, I have an hashes of hash, where hash is dynamic, it can be n number of hash. i need to compare data_count values of all . my %result ( $abc => { 'data_count' => '10', 'ID' => 'ABC122', } $def => { 'data_count' => '20', 'ID' => 'defASe', ... (1 Reply)
Discussion started by: asak
1 Replies

8. Shell Programming and Scripting

Perl giving unexpected md5 hash values

I am trying to speed up creating a line by line hash file from a huge file using Perl. Here is my current (working but too slow) Bash code: (while read line; do hash=$(echo -n $line | md5sum); echo ${hash:0:32}; done)And here is my Perl code: perl -MDigest::MD5 -le 'foreach $line ( <STDIN> )... (3 Replies)
Discussion started by: Michael Stora
3 Replies

9. Shell Programming and Scripting

Print perl hash value in foreach loop

Experts - Any advice on how to get a hash value in a foreach loop? Values print correctly on standalone print statements, but I can't access value in foreach loop. See sample code below and thanks in advance. foreach my $z (sort keys %hash) { for $y (@{$hash{$z}}) { print "$z... (6 Replies)
Discussion started by: timj123
6 Replies
All times are GMT -4. The time now is 07:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy