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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |