Sponsored Content
Top Forums Shell Programming and Scripting Print perl hash value in foreach loop Post 302972597 by Aia on Sunday 8th of May 2016 05:59:04 PM
Old 05-08-2016
Quote:
Originally Posted by timj123
It's similar to the following:

Code:
          'Key1' => [
                      ' Value1',
                      ' Value2',
                      ' Value3',
                      ' Value4',
                      ' Value5',
                      ' Value6',
                      ' Value7',
                      ' Value8',
                      ' Value9'
                    ],

Notice that 'space Value1' is not the same that 'Value1'. Is that a copy and paste from your output?
If that is the case, $hash1{$y} or $hash1{"$y"} is undefined, since it would be equivalent to $hash1{' Value1'} and the key dereference should be $hash1{'Value1'}

Last edited by Aia; 05-08-2016 at 07:13 PM.. Reason: Add explanation
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl - Iterating a hash through a foreach loop - unexpected results

i've reworked some code from an earlier post, and it isn't working as expected i've simplified it to try and find the problem. i spent hours trying to figure out what is wrong, eventually thinking there was a bug in perl or a problem with my computer. but, i've tried it on 3 machines with the... (5 Replies)
Discussion started by: quantumechanix
5 Replies

2. Shell Programming and Scripting

Print Entire hash list (hash of hashes)

I have a script with dynamic hash of hashes , and I want to print the entire hash (with all other hashes). Itried to do it recursively by checking if the current key is a hash and if yes call the current function again with refference to the sub hash. Most of the printing seems to be OK but in... (1 Reply)
Discussion started by: Alalush
1 Replies

3. 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

4. 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

5. Shell Programming and Scripting

Perl question - print last element in a hash?

I am modifying someone else's code. There is a foreach statement printing the contents of a hash. Can someone give me an example of printing the last element in a hash? The output currently is A B C D E I want the output to be E (1 Reply)
Discussion started by: streetfighter2
1 Replies

6. Shell Programming and Scripting

Perl Hash:Can not keep hash data in the same order that it was inserted

Can Someone explain me why even using Tie::IxHash I can not get the output data in the same order that it was inserted? See code below. #!/usr/bin/perl use warnings; use Tie::IxHash; use strict; tie (my %programs, "Tie::IxHash"); while (my $line = <DATA>) { chomp $line; my(... (1 Reply)
Discussion started by: jgfcoimbra
1 Replies

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

8. Shell Programming and Scripting

perl hash - using a range as a hash key.

Hi, In Perl, is it possible to use a range of numbers with '..' as a key in a hash? Something in like: %hash = ( '768..1536' => '1G', '1537..2560' => '2G' ); That is, the range operation is evaluated, and all members of the range are... (3 Replies)
Discussion started by: dsw
3 Replies

9. 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

10. Shell Programming and Scripting

Need to print hash of hash in table format

Hi, I have a hash of hash where it has name, activities and count i have data like this - $result->{$name}->{$activities} = $value; content of that are - name - robert tom cat peter activities - running, eating, sleeping , drinking, work i need to print output as below ... (3 Replies)
Discussion started by: asak
3 Replies
IJSGUTENPRINT(1)					      Gutenprint Manual Pages						  IJSGUTENPRINT(1)

NAME
ijsgutenprint - Ghostscript driver for Gutenprint SYNOPSIS
gs -sDEVICE=ijs -sIjsServer=/usr/bin/ijsgutenprint -sDeviceManufacturer=vendor -sDeviceModel=name [ -dIjsUseOutputFD ] -sIjsParams=[ key1=value1,keyn=valuen... ] [ options ] [ files ] DESCRIPTION
ijsgutenprint provides Ghostscript with a Gutenprint driver, supporting all printers supported by libgutenprint. NOTE: ijsgutenprint should never be called directly. Ghostscript will run it if the IjsServer parameter is set to IjsServer=ijsgutenprint when invoking the IJS driver. NOTE: The only supported method of running ijsgutenprint is via Foomatic. Users running ghostscript directly will not be supported. The driver name used by Foomatic is gutenprint-ijs.5.2. OPTIONS
ijsgutenprint accepts the following Ghostscript IJS options. The Gutenprint-specific options are not documented here. -dIjsUseOutputFD This option should be specified whenever output from Ghostscript will go to stdout or into a pipe. It may be specified in all other cases, with only a slight performance degradation. -sIjsParams=Option1=Value1,Option2=Value2 This parameter contains a single string containing a comma-separated list of sub-options. -sDeviceManufacturer=vendor -sDeviceModel=name This option must be supplied. There is no default. The IJS driver requires the vendor (it's part of the protocol), but the ijsgutenprint driver ignores it. HISTORY
The Ghostscript stp driver was originally written by Henryk Richter (buggs@comlab.uni-rostock.de), and was integrated into Gutenprint dur- ing the 3.1 development series. Gutenprint (which was named Gimp-Print prior to release 5.0) itself was originally written by Michael Sweet <mike@easysw.com>, who released up to version 2.0; Robert Krawitz released version 3.0. The Gutenprint development team (http://gimp-print.sourceforge.net) now maintains the entire package. The IJS driver was originally written by Russell Lang, and incorporated into Gutenprint (known then as Gimp-Print) in early 2002. This driver corresponds with the IJS protocol 0.32. The stp driver is no longer supported as of Gutenprint 5.0. COPYRIGHT
Copyright (C) 2001-2006 Robert Krawitz (rlk@alum.mit.edu) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. AUTHORS
Robert Krawitz. Originally written by Russell Lang. This manual page was written by Robert Krawitz (rlk@alum.mit.edu) and Roger Leigh (rleigh@debian.org). SEE ALSO
gs(1) Version 5.2.9 07 Jul 2012 IJSGUTENPRINT(1)
All times are GMT -4. The time now is 02:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy