Sponsored Content
Full Discussion: Perl Json and Hash
Top Forums Programming Perl Json and Hash Post 302799503 by alister on Friday 26th of April 2013 03:32:02 PM
Old 04-26-2013
Why are you placing the decoded result in an array when decode_json() returns a scalar? If the json text represents an object, then the return type will be a reference to a hash. If "hostname" is at the top-level of the object, then you can access it with ${$href}{'hostname'} or $href->{hostname}.

Regards,
Alister
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Hash

HI I have a hash like this $hashname->{$filesystem}->{'fsname'}=$filesystem; How to get the values from this multilevel hash. Thanks in advance... :) (1 Reply)
Discussion started by: Harikrishna
1 Replies

2. Shell Programming and Scripting

Perl Hash

hi i have two hash achi %disk1,%disk2 with( key, value) (key1,value1) How to store it in another hash.. Plz replyyy. Regards Hari (1 Reply)
Discussion started by: Harikrishna
1 Replies

3. Shell Programming and Scripting

perl help on hash

I have line which is read from xml doc. I want to put this line into hash(perl variable). find line below and how i want to put this in hash <font size="10" type="int" name="ABC" > hash key should be size, type and name with corresponding value I doing as below:- $line =~ s/\s*.*?\s//;... (3 Replies)
Discussion started by: aju_kup
3 Replies

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

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

6. Shell Programming and Scripting

perl code-sequence of json format

Hi All , Below is the perl code. from below code want to confirm one thing that wahtever the sequence of data we are passing through json format which contains 3 tuples of different sequences Eg: ParentID,SystemID,SendingTime,Time,ClientLocation,ClientID, ... (1 Reply)
Discussion started by: aish11
1 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. Programming

Perl array / json

Hi All I have used the below code to print the dumper of a json #!/usr/bin/perl use LWP::Simple; use JSON qw( decode_json ); use Data::Dumper; use strict; use warnings; my (%list); my $trendsurl =... (5 Replies)
Discussion started by: ab52
5 Replies

9. Programming

Perl: restrict perl from automaticaly creating a hash branches on check

My issue is that the perl script (as I have done it so far) created empty branches when I try to check some branches on existence. I am using multydimentional hashes: found it as the best way for information that I need to handle. Saing multidimentional I means hash of hashes ... So, I have ... (2 Replies)
Discussion started by: alex_5161
2 Replies

10. Shell Programming and Scripting

UNIX or Perl script to convert JSON to CSV

Is there a Unix or Perl script that converts JSON files to CSV or tab delimited format? We are running AIX 6.1. Thanks in advance! (1 Reply)
Discussion started by: warpmail
1 Replies
GRS1(3pm)						User Contributed Perl Documentation						 GRS1(3pm)

NAME
Net::Z3950::Record::GRS1 - Perl package used to encode GRS-1 records. SYNOPSIS
use Net::Z3950::GRS1; my $a_grs1_record = new Net::Z3950::Record::GRS1; my $another_grs1_record = new Net::Z3950::Record::GRS1; $a_grs1_record->AddElement($type, $value, $content); $a_grs1_record->Render(); DESCRIPTION
This Perl module helps you to create and manipulate GRS-1 records (generic record syntax). So far, you have only access to three methods: new Creates a new GRS-1 object, my $grs1 = new Net::Z3950::GRS1; AddElement Lets you add entries to a GRS-1 object. The method should be called this way, $grs1->AddElement($type, $value, $which, $content); where $type should be an integer, and $value is free text. The $which argument should contain one of the constants listed in Appendix A. Finally, $content contains the "thing" that should be stored in this entry. The structure of $content should match the chosen element data type. For $which == Net::Z3950::GRS1::ElementData::String; $content should be some kind of scalar. If on the other hand, $which == Net::Z3950::GRS1::ElementData::Subtree; $content should be a GRS1 object. Render This method digs through the GRS-1 data structure and renders the record. You call it this way, $grs1->Render(); If you want to access the rendered record through a variable, you can do it like this, my $record_as_string; $grs1->Render(POOL => $record_as_string); If you want it stored in a file, Render should be called this way, $grs1->Render(FILE => 'record.grs1'); When no file name is specified, you can choose to stream the rendered record, for instance, $grs1->Render(HANDLE => *STDOUT); ## or $grs1->Render(HANDLE => *STDERR); ## or $grs1->Render(HANDLE => *MY_HANDLE); Hash2grs This method converts a hash into a GRS-1 object. Scalar entries within the hash are converted into GRS-1 string elements. A hash entry can itself be a reference to another hash. In this case, the new referenced hash will be converted into a GRS-1 subtree. The method is called this way, $grs1->Hash2grs($href, $mapping); where $href is the hash to be converted and $mapping is referenced hash specifying the mapping between keys in $href and (type, value) pairs in the $grs1 object. The $mapping hash could for instance look like this, my $mapping = { title => [2, 1], author => [1, 1], issn => [3, 1] }; If the $grs1 object contains data prior to the invocation of Hash2grs, the new data represented by the hash is simply added. APPENDIX A
These element data types are specified in the Z39.50 protocol: Net::Z3950::GRS1::ElementData::Octets Net::Z3950::GRS1::ElementData::Numeric Net::Z3950::GRS1::ElementData::Date Net::Z3950::GRS1::ElementData::Ext Net::Z3950::GRS1::ElementData::String <--- Net::Z3950::GRS1::ElementData::TrueOrFalse Net::Z3950::GRS1::ElementData::OID Net::Z3950::GRS1::ElementData::IntUnit Net::Z3950::GRS1::ElementData::ElementNotThere Net::Z3950::GRS1::ElementData::ElementEmpty Net::Z3950::GRS1::ElementData::NoDataRequested Net::Z3950::GRS1::ElementData::Diagnostic Net::Z3950::GRS1::ElementData::Subtree <--- Only the '<---' marked types are so far supported in this package. AUTHOR
Anders Sonderberg Mortensen <sondberg@indexdata.dk> Index Data ApS, Copenhagen, Denmark. 2001/03/09 SEE ALSO
Specification of the GRS-1 standard, for instance in the Z39.50 protocol specification. perl v5.14.2 2011-08-09 GRS1(3pm)
All times are GMT -4. The time now is 04:11 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy