Sponsored Content
Full Discussion: Comparing two variables
Top Forums Shell Programming and Scripting Comparing two variables Post 302184286 by rajip23 on Friday 11th of April 2008 05:22:38 AM
Old 04-11-2008
Still didnt work..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

comparing variables

I have searched and found a few threads that have dealt with this, but the examples I've tried haven't seemed to help. I am monitoring our database log for high checkpoints. I can parse out the checkpoint value which can be anywhere from zero into a 3 digit number. I set a variable to be the... (3 Replies)
Discussion started by: MizzGail
3 Replies

2. Shell Programming and Scripting

Grabbing variables and comparing

I have two computers with dynamic IP addresses and am using dyndns so that they are identifiable as the same computer even if their IPs change (we'll call them host1.dyndns.com and host2.dyndns.com). I also have a remote server which I would like to store my computers' IP addresses on. There is a... (9 Replies)
Discussion started by: kerpm
9 Replies

3. Shell Programming and Scripting

Comparing Variables in Perl

Hi. I have three arrays. @a=('AB','CD','EF'); @b=('AB,'DG',HK'); @c=('DD','TT','MM'); I want to compare the elements of the first two array and if they match then so some substition. I tried using the if statement using the scalar value of the array but its not giving me any output. ... (7 Replies)
Discussion started by: kamitsin
7 Replies

4. UNIX for Dummies Questions & Answers

comparing variables

im trying to compare ipaddresses. i loop through an array to see if the ip is already is in the array and if it is it should set a flag and then i wont add it to the array. but its just adding all the ipaddresses to the array if ] then ... (3 Replies)
Discussion started by: magnia
3 Replies

5. Shell Programming and Scripting

Comparing multiple variables

Hi! I've come up with a ksh-script that produces one or more lists of hosts. At the and of the script, I would like to print only those hosts that exists in all the lists. Ex. HOSTS="host1 host2 host3 host11" HOSTS="host1 host2 host4" HOSTS="host2 host11" HOSTS="host2 host5 host6 host7... (1 Reply)
Discussion started by: Bugenhagen
1 Replies

6. Shell Programming and Scripting

comparing multiple variables by 'if then'

Hi, I am a noob at shell scripting. basically I am trying to compare row counts from 8 tables in different databases. I have managed to get the row counts using awk from the spool files for both databases. now I have 16 variables with me for database 1 : $A $B $C $D $E $F $G... (3 Replies)
Discussion started by: smallville
3 Replies

7. Shell Programming and Scripting

Comparing content of two variables

I have very abstract need of "comparing two variables" and take subsequent actions. please refer to image below https://lh3.googleusercontent.com/-frNk5iA3q1c/TjI3lE0sWOI/AAAAAAAAAIE/fxzB1w07gas/script_block.JPG I have a part of script which reads a file and generates variables based on... (4 Replies)
Discussion started by: animesharma
4 Replies

8. UNIX for Dummies Questions & Answers

Comparing the characters of 2 variables

hi i am writing a hangman script and am having trouble checking the correct letters against the word i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario eg ... (13 Replies)
Discussion started by: lsecer
13 Replies

9. Shell Programming and Scripting

Comparing two variables

I have a script like this. Just couldn't get the comparison part work. Any thought? thanks, #!/usr/bin/ksh -x STEP=`echo $(basename $0 .ksh) | tr "" ""` log=/skip.log while read LINE do if then echo `date`: STEP $STEP skipped by user >> $log exit 0 fi done < $1 echo... (0 Replies)
Discussion started by: ghostmic
0 Replies

10. UNIX for Beginners Questions & Answers

Comparing 2 variables in UNIX

Hi, I have 2 variables as given below. How can i compare them and say its matching ? Appreciate your help VAR1=describe/read/write VAR2=read/write/describeThanks, Please use CODE tags as required by forum rules! (4 Replies)
Discussion started by: prince1987
4 Replies
Dumper(3pm)						User Contributed Perl Documentation					       Dumper(3pm)

NAME
XML::Dumper - Perl module for dumping Perl objects from/to XML SYNOPSIS
# ===== Using an object use XML::Dumper; $dump = new XML::Dumper; $xml = $dump->pl2xml( $perl ); $perl = $dump->xml2pl( $xml ); $dump->pl2xml( $perl, "my_perl_data.xml.gz" ); # ===== Using function calls use XML::Dumper; $xml = pl2xml( $perl ); $perl = xml2pl( $xml ); EXTENDED SYNOPSIS
use XML::Dumper; my $dump = new XML::Dumper; my $perl = ''; my $xml = ''; # ===== Convert Perl code to XML $perl = [ { fname => 'Fred', lname => 'Flintstone', residence => 'Bedrock' }, { fname => 'Barney', lname => 'Rubble', residence => 'Bedrock' } ]; $xml = $dump->pl2xml( $perl ); # ===== Dump to a file my $file = "dump.xml"; $dump->pl2xml( $perl, $file ); # ===== Convert XML to Perl code $xml = q| <perldata> <arrayref> <item key="0"> <hashref> <item key="fname">Fred</item> <item key="lname">Flintstone</item> <item key="residence">Bedrock</item> </hashref> </item> <item key="1"> <hashref> <item key="fname">Barney</item> <item key="lname">Rubble</item> <item key="residence">Bedrock</item> </hashref> </item> </arrayref> </perldata> |; my $perl = $dump->xml2pl( $xml ); # ===== Convert an XML file to Perl code my $perl = $dump->xml2pl( $file ); # ===== And serialize Perl code to an XML file $dump->pl2xml( $perl, $file ); # ===== USE COMPRESSION $dump->pl2xml( $perl, $file.".gz" ); # ===== INCLUDE AN IN-DOCUMENT DTD $dump->dtd; my $xml_with_dtd = $dump->pl2xml( $perl ); # ===== USE EXTERNAL DTD $dump->dtd( $file, $url ); my $xml_with_link_to_dtd = $dump->pl2xml( $perl ); DESCRIPTION
XML::Dumper dumps Perl data to XML format. XML::Dumper can also read XML data that was previously dumped by the module and convert it back to Perl. You can use the module read the XML from a file and write the XML to a file. Perl objects are blessed back to their original pack- aging; if the modules are installed on the system where the perl objects are reconstituted from xml, they will behave as expected. Intu- itively, if the perl objects are converted and reconstituted in the same environment, all should be well. And it is. Additionally, because XML benefits so nicely from compression, XML::Dumper understands gzipped XML files. It does so with an optional dependency on Compress::Zlib. So, if you dump a Perl variable with a file that has an extension of '.xml.gz', it will store and compress the file in gzipped format. Likewise, if you read a file with the extension '.xml.gz', it will uncompress the file in memory before pars- ing the XML back into a Perl variable. Another fine challenge that this module rises to meet is that it understands circular definitions and multiple references to a single object. This includes doubly-linked lists, circular references, and the so-called 'Flyweight' pattern of Object Oriented programming. So it can take the gnarliest of your perl data, and should do just fine. One caveat; XML::Dumper does not handle binary data. There have been discussions in the expat mailing list archives discussing the chal- lenges associated with encoding binary data with XML. I chose the cowardly path of making the problem a non-issue by not addressing it. To store binary data, one could encode the data into ASCII before encapsulating the data as XML, and then reverse the process to restore the data. There are several Perl modules that one can use for this, Convert::UU, for example. FUNCTIONS AND METHODS * new() - XML::Dumper constructor. Creates a lean, mean, XML dumping machine. It's also completely at your disposal. * dtd - Generates a Document Type Dictionary for the 'perldata' data type. The default behaviour is to embed the DTD in the XML, thereby creat- ing valid XML. Given a filename, the DTD will be written out to that file and the XML document for your Perl data will link to the file. Given a filename and an URL, the DTD will be written out the file and the XML document will link to the URL. XML::Dumper doesn't try really hard to determine where your DTD's ought to go or relative paths or anything, so be careful with what arguments you supply this method, or just go with the default with the embedded DTD. Between DTD's and Schemas, the potential for more free-form data to be imported and exported becomes feasible. Usage: dtd(); # Causes XML to include embedded DTD dtd( $file ); # DTD saved to $file; XML will link to $file dtd( $file, $url ); # DTD saved to $file; XML will link to $url dtd( 0 ); # Prevents XML from including embedded DTD * pl2xml( $xml, [ $file ] ) - (Also perl2xml(), for those who enjoy readability over brevity). Converts Perl data to XML. If a second argument is given, then the Perl data will be stored to disk as XML, using the second argument as a filename. Usage: See Synopsis * xml2pl( $xml_or_filename, [ $callback ] ) - (Also xml2perl(), for those who enjoy readability over brevity.) Converts XML to a Perl datatype. If this method is given a second argument, XML::Dumper will use the second argument as a callback (if possible). If the first argument isn't XML and exists as a file, that file will be read and its contents will be used as the input XML. Currently, the only supported invocation of callbacks is through soft references. That is to say, the callback argument ought to be a string that matches the name of a callable method for your classes. If you have a congruent interface, this should work like a peach. If your class interface doesn't have such a named method, it won't be called. * xml_compare( $xml1, $xml2 ) - Compares xml for content Compares two dumped Perl data structures (that is, compares the xml) for identity in content. Use this function rather than perl's built-in string comparison. This function will return true for any two perl data that are either deep clones of each other, or identi- cal. This method is exported by default. * xml_identity( $xml1, $xml2 ) - Compares xml for identity Compares two dumped Perl data structures (that is, compares the xml) for identity in instantiation. This function will return true for any two perl data that are identical, but not for deep clones of each other. This method is also exported by default. EXPORTS
By default, the following methods are exported: xml2pl, pl2xml, xml_compare, xml_identity BUGS AND DEPENDENCIES
XML::Dumper has changed API since 0.4, as a response to a bug report from PerlMonks. I felt it was necessary, as the functions simply didn't work as advertised. That is, xml2pl really didnt accept xml as an argument; what it wanted was an XML Parse tree. To correct for the API change, simply don't parse the XML before feeding it to XML::Dumper. XML::Dumper also has no understanding of typeglobs (references or not), references to regular expressions, or references to Perl subrou- tines. Turns out that Data::Dumper doesn't do references to Perl subroutines, either, so at least I'm in somewhat good company. XML::Dumper requires one perl module, available from CPAN XML::Parser XML::Parser itself relies on Clark Cooper's Expat implementation in Perl, which in turn requires James Clark's expat package itself. See the documentation for XML::Parser for more information. REVISIONS AND CREDITS
The list of credits got so long that I had to move it to the Changes file. Thanks to all those who've contributed with bug reports and sug- gested features! Keep 'em coming! I've had ownership of the module since June of 2002, and very much appreciate requests on how to make the module better. It has served me well, both as a learning tool on how I can repay my debt to the Perl Community, and as a practical module that is useful. I'm thrilled to be able to offer this bit of code. So, if you have suggestions, bug reports, or feature requests, please let me know and I'll do my best to make this a better module. CURRENT MAINTAINER
Mike Wong <mike_w3@pacbell.net> XML::Dumper is free software. You can redistribute it and/or modify it under the same terms as Perl itself. ORIGINAL AUTHOR
Jonathan Eisenzopf <eisen@pobox.com> SEE ALSO
perl(1) Compress::Zlib(3) XML::Parser(3) Data::DumpXML(3) perl v5.8.8 2006-04-18 Dumper(3pm)
All times are GMT -4. The time now is 09:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy