This looks like homework to me. Did you consider doing this?

# 3. What is the value of "$portresults->{portfolio}->{riskgrade}"? print "port ", $portresults->{portfolio}->{riskgrade}, "\n"; # 3. What is the value of "sprintf("%.2f", -$portresults->{Bayer}->{xl +oss} )"? printf "sprintf: %.2f\n", -$portresults->{Bayer}->{xloss}; # 4. What is the first element of "sort {lc($b) cmp lc($a)} keys %{$po +rtresults}" ? @ary = sort {lc($b) cmp lc($a)} keys %{$portresults}; print "sort: $ary[0]\n";

As for Q5 this is a bizare regex that does this:

s # substitute / # begin search sequence < # find a literal < (?! # negative lookahead ie find a < not followed by \/* # 0 or more / chars [bi] # then either a 'b' or and 'i' char > # then a literal > ) # end of negative lookahead .*? # 0 or more of any characters, non greedy ie minimal > # a literal > /x/ # replacement sequence is a literal 'x' char g # do all occurences

In a nutshell this will subsitite all HTML tags with the letter 'x' except for <b> </b> <i> </i> tags. It is very broken.

$HTML = <<THIS; <html> <head> <title>Foo</title> </head> <body> <B>This regex is broken</b> <b>It will cope with this</b> <b >But not this< /b> <I>told you</i>ts<b>roken</b> </body> </html> THIS $HTML =~ s/<(?!\/*[bi]>).*?>/x/g; print $HTML;

When all else fails suck it and see! cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Perl with XML by tachyon
in thread Perl with XML by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.