Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

print adds \n when using Spreadsheet::TieExcel

by dorko (Prior)
on Apr 11, 2006 at 15:53 UTC ( [id://542577]=perlquestion: print w/replies, xml ) Need Help??

dorko has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I've got a curious problem. I'm using Spreadsheet::TieExcel to read and write a MS Excel file. As soon as I use Spreadsheet::TieExcel, all my print statements have a \n appended to the end of them.

This snippet:

use strict; use warnings; #NOTE: you must have Excel open for this to work. use Spreadsheet::TieExcel; print "asdf"; print "1234";
prints
asdf 1234
Commenting out the use Spreadsheet::TieExcel works as expected.
use strict; use warnings; #use Spreadsheet::TieExcel; print "asdf"; print "1234";
prints
asdf1234 as expected.

I'm using Windows XP, Activestate Perl build 811, and Spreadsheet::TieExcel version 0.73.

Thoughts? Questions? Comments?

Cheers,

Brent

-- Yeah, I'm a Delt.

Replies are listed 'Best First'.
Re: print adds \n when using Spreadsheet::TieExcel
by ikegami (Patriarch) on Apr 11, 2006 at 16:06 UTC

    I just took a peek at the source of the latest Spreadsheet::TieExcel on CPAN (0.73). It executes $\ = "\n"; $, = "\t";. It doesn't even use either of these vars, directly or indirectly, as far as I can tell.

    The workaround is to change

    use Spreadsheet::TieExcel;

    into

    BEGIN { # Prevent Spreadsheet::TieExcel from clobbering $\ and $, local ($\, $,); require Spreadsheet::TieExcel; Spreadsheet::TieExcel->import(); }
Re: print adds \n when using Spreadsheet::TieExcel
by japhy (Canon) on Apr 11, 2006 at 16:06 UTC
    You should yell at Simone Cesano (simonecesano@libero.it), the author. He set $\ and $, without local()izing them.

    Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
    How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-25 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found