Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Jenda's scratchpad

by Jenda (Abbot)
on Jun 02, 2004 at 20:43 UTC ( [id://359731]=scratchpad: print w/replies, xml ) Need Help??

for runrig

line 1485 -- if ($rule =~ s/\s*\bonly\(([^\)]+)\)//) { ++ if ($rule =~ s/^((?:(?:no\s+)?content\s+)?by\s+(\S+))\s+only\(([^\) +]+)\)$/$1/) { ++ my %only; ++ $only{$2} = undef; ++ @only{split /\s*,\s*/, $3} = (); ++ foreach (keys %$data) { ++ delete $data->{$_} unless exists $only{$_}; ++ } ++ } elsif ($rule =~ s/\s*\bonly\(([^\)]+)\)//) {

for MidLifeXis: save the following into a file with .reg extension and doubleclick.

Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\Folder\shell\CmdHere] @="&Command Prompt Here" [HKEY_CLASSES_ROOT\Folder\shell\CmdHere\Command] @="C:\\WINNT\\system32\\cmd.exe /k cd \"%1\""

for runrig:

use strict; use XML::Rules; my $parser = XML::Rules->new( rules => [ _default => 'content', 'other, Author' => 'as array', AuthorList => sub { return Authors => $_[1]->{Author} }, PubmedArticle => 'pass', ], stripspaces => 7, handlers => { Start => sub { my ( $Parser, $Element , %Attr) = @_; print "$Element\n"; # you can modify the elements of @_ for(my $i = 2;$i <= $#_; $i+=2) { $_[$i] = lc($_[$i]) }; #print "(@_)\n"; # and even add attributes push @_, blah => 666; }, Comment => sub {my ($Parser, $String) = @_; print "Found a comment +: $String\n"}, } ); my $data = $parser->parse( \*DATA); use Data::Dumper; print Dumper($data); print "Authors:\n"; foreach my $author (@{$data->{Authors}}) { print "$author->{ForeName} $author->{LastName}\n"; } __DATA__ <PubmedArticle> <!-- blah blah--> <AuthorList CompleteYN="Y"> <Author ValidYN="Y"> <LastName>van Beilen</LastName> <ForeName>J B</ForeName> <Initials>JB</Initials> </Author> <Author ValidYN="Y"> <LastName>Penninga</LastName> <ForeName>D</ForeName> <Initials>D</Initials> </Author> <Author ValidYN="Y"> <LastName>Witholt</LastName> <ForeName>B</ForeName> <Initials>B</Initials> </Author> </AuthorList> </PubmedArticle>
for ambrus:
$string = "xxabgi"; $_ = "abcghis"; print "Orig: \$string='$string'\t\$_='$_'\n"; $string =~ (0 ? y/a-c/d-f/ : y/g-i/j-l/); print "Changed: \$string='$string'\t\$_='$_'\n"; print "\n"; $string = "xxabgi"; $_ = "abcghis"; print "Orig: \$string='$string'\t\$_='$_'\n"; $string =~ (1 ? y/a-c/d-f/ : y/g-i/j-l/); print "Changed: \$string='$string'\t\$_='$_'\n";

XML::Rules examples

my $xml = <<'*END*'; <doc> <book> <name>Valka s mloky</name> <author>Karel Capek</author> <description>It's really <b>something</b> and I have to <u>underline + it</u>.</description> </book> <book> <name>Predtucha</name> <author>Pujmanova</author> <description>It's really a <u>stupid</u> pointless book. Confront <link id="12345">this one</link>. And don't read this one ple +ase! </description> </book> </doc> *END* my $parser = new XML::Rules ( rules => [ _default => 'content', u => sub {my $str = $_[1]->{_content}; $str =~ tr/ /_/; return + '_'.$str.'_'}, b => sub {my $str = $_[1]->{_content}; return '*'.$str.'*'}, link => sub { qq{<a href="http://www.books.com/find_book.pl?id +=$_[1]->{id}">$_->{_content}</a>} }, book => sub { my $desc = $_[1]->{description}; $desc =~ s/\n/\n\t/g; print "Book: $_[1]->{name}\nAuthor: $_[1]->{author}\nDescr +iption: $desc\n\n"; }, ], ); $parser->parsestring($xml);
my $xml = <<'*END*'; <doc> <person> <fname>Jane</fname> <lname>Luser</lname> <email>JLuser@bogus.com</email> <address> <street>Washington st.</street> <city>Old Creek</city> <country>The US</country> <bogus>bleargh</bogus> </address> <phones> <phone type="home">123-456-7890</phone> <phone type="office">663-486-7890</phone> <phone type="fax">663-486-7000</phone> </phones> </person> <person> <fname>John</fname> <lname>Other</lname> <email>JOther@silly.com</email> <address> <street>Grant's st.</street> <city>New Creek</city> <country>Canada</country> <bogus>sdrysdfgtyh degtrhy <foo>degtrhy werthy</foo>werthy drthyu</ +bogus> </address> <phones> <phone type="office">663-486-7891</phone> </phones> </person> </doc> *END* my $parser = new XML::Rules ( rules => [ _default => sub {$_[0] => $_[1]->{_content}}, 'fname,lname' => sub {$_[0] => $_[1]->{_content}}, bogus => undef, address => sub {address => "$_[1]->{street}, $_[1]->{city} ($_ +[1]->{country})"}, phone => sub {$_[1]->{type} => $_[1]->{_content}}, # let's use the "type" attribute as the key and the conten +t as the value phones => sub {delete $_[1]->{_content}; %{$_[1]}}, # remove the text content and pass along the type => conte +nt from the child nodes person => sub { # lets print the values, all the data is readi +ly available in the attributes print "$_[1]->{lname}, $_[1]->{fname} <$_[1]->{email}>\n"; print "Home phone: $_[1]->{home}\n" if $_[1]->{home}; print "Office phone: $_[1]->{office}\n" if $_[1]->{office} +; print "Fax: $_[1]->{fax}\n" if $_[1]->{fax}; print "$_[1]->{address}\n\n"; return; # the <person> tag is processed, no need to rememb +er what it contained }, ] ); $parser->parsestring($xml);
Have to look at xml parsers: do I need one? and test the speed to the benchmarks there.

The Czech declination models

MASCULINE
hard animhard unanimsoft animsoft unanimrare
1kdo/co:pánhradmužstrojpředsedasoudce
2bez koho/čeho:pánahradumužestrojepředsedysoudce
3ke komu/čemu:pánovihradumužistrojipředsedovisoudci
4vidím koho/co:pánahradmužestrojpředsedusoudce
5voláme:panehrademužistrojipředsedosoudče/soudce
6o kom/čem:pánuhradumužistrojipředsedovisoudci
7s kým/čím:pánemhrademmužemstrojempředsedousoudcem
plural
1kdo/co:pánovéhradymužistrojepředsedovésoudci
2bez koho/čeho:pánůhradůmužůstrojůpředsedůsoudců
3ke komu/čemu:pánůmhradůmmužůmstrojůmpředsedůmsoudcům
4vidím koho/co:pányhradymužestrojepředsedysoudce
5voláme:pánihradymužistrojepředsedovésoudci
6o kom/čem:pánechhradechmužíchstrojíchpředsedechsoudcích
7s kým/čím:pányhradymužistrojipředsedysoudci

FEMININE
1kdo/co:ženarůžepíseňkost
2bez koho/čeho:ženyrůžepísněkosti
3ke komu/čemu:ženěrůžipísnikosti
4vidím koho/co:ženurůžipíseňkost
5voláme:ženorůžepísnikosti
6o kom/čem:ženěrůžipísnikosti
7s kým/čím:ženourůžípísníkostí
plural
1kdo/co:ženyrůžepísněkosti
2bez koho/čeho:ženrůžípísníkostí
3ke komu/čemu:ženámrůžímpísnímkostem
4vidím koho/co:ženyrůžepísněkosti
5voláme:ženyrůžepísněkosti
6o kom/čem:ženáchrůžíchpísníchkostech
7s kým/čím:ženamirůžemipísněmikostmi

NEUTRAL
1kdo/co:městomořekuřestavení
2bez koho/čeho:městamořekuřetestavení
3ke komu/čemu:městumořikuřetistavení
4vidím koho/co:městomořekuřestavení
5voláme:městomořekuřestavení
6o kom/čem:městu/městěmořikuřetistavení
7s kým/čím:městemmořemkuřetemstavením
plural
1kdo/co:městamořekuřatastavení
2bez koho/čeho:městmoříkuřatstavení
3ke komu/čemu:městůmmořímkuřatůmstavením
4vidím koho/co:městamořekuřatastavení
5voláme:městamořekuřatastavení
6o kom/čem:městechmoříchkuřatechstaveních
7s kým/čím:městymořikuřatystaveními
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-19 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found