Thank you all very much.

I think this gives me all the answers I need (and then some).
I needed to move forward on this project, so for the moment I have taken the
ugly route ad made the variables global.
But I hope to try applying some of these better methods by the middle of the
week.
I will post again to sa what I finally went with.

Thanks again.
--Alex

On 8/27/07, mirod <[EMAIL PROTECTED]> wrote:
>
> Alex Brelsfoard wrote:
>
> > sub main {
> >       my $catalog_timestamp;
> [...]
>
> >               my $catalog_settings = XML::Twig->new(
> >                   twig_handlers => {
> >                       'Item'    => \&get_catalog_field_names,
> >                       'Catalog' => \&get_catalog_timestamp,
> >                   }
> >               );
> [...]
> > sub get_catalog_timestamp {
> >       my ($twig, $elt) = @_;
> >
> >       # get the PublishTimeStamp attribute
> >       $catalog_timestamp = $elt->att('PublishTimestamp');
> >
> >       $twig->purge();
> > }
> However I get an error from this.
> > "Global symbol "$catalog_timestamp" requires explicit package name"
> > The error references the "$catalog_timestamp =
> > $elt->att('PublishTimestamp');" line.
>
> As per the error message ;--) $catalog_timestamp is in scope in the main
> sub, but not in the rest of the file.
>
> 2 options: make it global to the file by declaring it outside of the
> main sub, or (cleaner), pass it to the handler via a closure:
>
>
> my $catalog_settings= XML::Twig->new(
>    twig_handlers => {
>     'Item' => sub { get_catalog_field_names( @_, $catalog_timestamp); }
> ...
>
> sub get_catalog_timestamp {
>     my ($twig, $elt, $catalog_timestamp) = @_;
>     ...
>
> Does this help?
>
> --
> mirod
>
 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to