I think this is better
#!/usr/bin/perl --
use strict;
use warnings;
use XML::Twig;
use Digest;
my $xml = q~<Transaction>
<MessageCode>100</MessageCode>
<ToAccountNo>12989898900</ToAccountNo>
<ToBranchCode>08876</ToBranchCode>
<FromAccountNo>S MARR SON </FromAccountNo>
<FromBranchCode>ABG89097</FromBranchCode>
<CurrencyCode>INR</CurrencyCode>
<Amount>0000000000221000000.00</Amount>
<TransactionDate>2008-07-10T12:04:25</TransactionDate>
<ValueDate>2008-07-10</ValueDate>
<CustomerRefNo>/CUST/</CustomerRefNo>
<ReferenceNo1>ADH7870822</ReferenceNo1>
<ReferenceNo2>/FRASER TRANSACTION</ReferenceNo2>
<DealerCode>1780</DealerCode>
<SalesOrganisation>1000</SalesOrganisation>
<TransactionType>N</TransactionType>
<SequenceNo>1</SequenceNo>
</Transaction>~;
{
my $ctx = Digest->new('SHA1');# MD5 ...
my $t = new XML::Twig(
TwigHandlers=> {
Transaction => sub {
print $_->children_text,$/;
$ctx->add($_->children_text);
}
}
);
$t->parse($xml);
print $/, $ctx->hexdigest,$/;
undef $ctx;
undef $t;
}
__END__
1001298989890008876S MARR SON ABG89097INR0000000000221000000.002008-07
+-10T12:04:252008-07-10/CUST/ADH7870822/FRASER TRANSACTION17801000N1
e5dc8115e0a2c22ffd034e07d4db8446b9d6696e
# FInal data will be as below
1001298989890008876S MARR SON ABG89097INR0000000000221000000.002008-07
+-10T12:04:252008-07-10/CUST/ADH7870822/FRASER TRANSACTION17801000N1
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|