Re: scalar / hash problem in HTML::Parser



On 02/25/2008 09:01:27 AM, Tim Bowden wrote:
-> Making progress. Needed to understand hash references, and how to
-> de-reference them.

delete($HASH{$KEY});

if that's what you mean; good luck with the stupid stick (i hope it ain't me)

->
-> Tim Bowden
->
-> On Mon, 2008-02-25 at 14:54 +0900, Tim Bowden wrote:
-> > Hi all,
-> >
-> > I'm using HTML::Parser to process files containing snippets of html
-> > looking like:
-> > <option value="1">First option</option><option value="2">Another
-> > choice</option><option value="4">pick me</option>
-> >
-> > I'm wanting to create a hash of option value, name pairs. Ie, 1 =>
-> > "First option",2=>"Another choice" and so on. Problem is, I don't
-> know
-> > how to handle the hash returned in $attr in the start sub:
-> >
-> > #!/usr/bin/perl -wT
-> > use strict;
-> > use HTML::Parser;
-> >
-> > my %choices;
-> > my $file = 'test_snippet';
-> > my $parser = HTML::Parser-> new(api_version => 3,
-> > start_h => [\&start, "tagname, attr"],
-> > );
-> >
-> > sub start {
-> > my ($tag, $attr) = @_;
-> > print "$tag\t$attr\n";
-> > # do something here to read the hash returned in $attr
-> > # and add the key value pair to %choices but what?
-> > }
-> > $parser->parse_file($file) or die "couldn't parse file";
-> >
-> >
-> > I realise it should be obvious and simple, but I feel like I've
-> been hit
-> > with the stupid stick for now. Any suggestions?
-> >
-> > Thanks,
-> > Tim Bowden
-> >
-> >
->
->
-> --
-> To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
-> For additional commands, e-mail: beginners-help@xxxxxxxx
-> http://learn.perl.org/
->
->
->
->


.



Relevant Pages

  • Re: Death of a Ranger (Vanilla)
    ... the phase door thing DOES help .. ... *Drolem without full detection may or may not be stupid, ... First is bad luck. ... plentiful no-fail teleport, tele level, and word of destruction. ...
    (rec.games.roguelike.angband)
  • Re: Crocodile hunter Steve Irwin dead...
    ... His luck finally ran out. ... He did some pretty stupid stuff. ... with fire long enough and all that, but stabbed in the heart by a ...
    (rec.arts.tv)
  • Re: an open letter to Jeffrey...
    ... I've ruined my life, and as things slowly unravel, I see a very ... real likelihood I won't here a year from now. ... Bad luck comes to everyone, and doing stupid things is how you learn. ...
    (rec.music.classical.recordings)
  • Re: Completely off topic, but I need help
    ... Good luck. ... Kathy ... I am in this stupid comp class and the entire class is 4-1/2 hours ... Civil Liberies Debate ...
    (sci.med.transcription)
  • Re: Murraysville biking incident
    ... >> Next time I hope that's you on a bike on the other side of the street. ... So you believe that story illustrates BAD LUCK? ... If I were you I wouldn't talk about someone else being stupid. ... Aren't you the one that thinks that being put in the position of understanding why a cyclist would be angry at being assaulted by a motorist is a personal threat? ...
    (rec.bicycles.racing)