Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re^4: Trying to Insert Alt Tags Programmatically

by GrandFather (Saint)
on Apr 03, 2011 at 01:17 UTC ( [id://897134]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Trying to Insert Alt Tags Programmatically
in thread Trying to Insert Alt Tags Programmatically

I strongly recommend that you keep the scope of lexical variables as small as possible. Generally you should only declare variables where they are initialised. Removing the block declaration of variables in the visit call back sub, then adding my where each variable is first initialised turns up the following dubious code:

my $newtitle = HTML::Element->new ('title'); $newtitle = $newtitleh1; my $newtitleh1 = $tree->look_down ('_tag', 'h1');

I also note the use of nested named subroutines which almost certainly is a mistake.

Aside from that, writing the same dozen lines of code four times should be a strong clue to use a sub.

Using named subs for the visit and broken link call backs would help clarify program flow and make the function of the various parts of the code clearer.

True laziness is hard work

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://897134]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-25 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found