Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: "scalar found where operator expected" while printing to a glob ref

by seki (Monk)
on Mar 01, 2016 at 17:56 UTC ( [id://1156556]=note: print w/replies, xml ) Need Help??


in reply to Re: "scalar found where operator expected" while printing to a glob ref
in thread "scalar found where operator expected" while printing to a glob ref

I see... So it seems that I picked the wrong piece of code as an example to make my own xml consumer :p
  • Comment on Re^2: "scalar found where operator expected" while printing to a glob ref

Replies are listed 'Best First'.
Re^3: "scalar found where operator expected" while printing to a glob ref
by AnomalousMonk (Archbishop) on Mar 01, 2016 at 18:25 UTC

    Further to Eily's post: Instead of
        print $$self $data;
    try
        print { $$self } $data;
    (untested).


    Give a man a fish:  <%-{-{-{-<

      Yes, the block returning the dereferenced file handle is doing the job.

      Even if it is not very explicit in the documentation, it is suggested in the last paragraph.
Re^3: "scalar found where operator expected" while printing to a glob ref
by Eily (Monsignor) on Mar 02, 2016 at 08:16 UTC

    It does seem so, but I couldn't find that piece of code in XML::SAX::Writer, which is not really surprising since this is a syntax error, not just a warning.

      Well, I've just checked and it is not the actual package code.
      I remember now that I found the example of custom ConsumerInterface in the documentation of XML::SAX::Writer
      sub output { my $self = shift; $$self .= uc shift; }
      and I have adapted it to my needs: replacing the string scalar to store the data by a file handle. Thus I am responsible for print $$self $data;. Actually I was surprised for not having the warning while using the stock module... Mea culpa.

        What line 3 ($$self .= uc shift) is saying (just for those not understanding the above code) is that it dereferences the thingy that $self points to, and appends the upper cased version of the next parameter to thingy, putting the results back into thingy.

        --MidLifeXis

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-25 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found