in reply to Re: Globalize the XML writer object
in thread Globalize the XML writer object

Hi, I tried by declaring it as "Our". But the case is : Lets say :

Package foo sub create xml{ our $XmlWriterObject = new XML::Writer( DATA_MODE => 1, DATA_INDENT => + 4, OUTPUT => $Output ); } package Bar; sub { $Foo::XmlWriterObject->endTag("Config"); }
For this the xml file is created but no data has been written into it.

Please clarify.

Replies are listed 'Best First'.
Re^3: Globalize the XML writer object
by roboticus (Chancellor) on Sep 19, 2011 at 11:01 UTC

    priyaviswam:

    After I added use strict and use warnings and corrected the myriad errors, I was able to make it work just fine. I'd post the (trivial) code, but given that you didn't even bother to try to make a working example, despite being here since July, I'm not terribly motivated to cut & paste my working code snippet here.

    A couple hints:

    • Subroutines need names.
    • Case matters.
    • You actually need to *call* subroutines in order for them to do things for you.

    Please make your code at least *compile* first, and then I'll be happy to give you a few more pointers.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.