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

I'm going to cry. I'm having the most unusual, frustrating problem, and to make matters worse it's a platform-specific problem (I think). But it's one of those things that is so simple as to be simply impossible. Help?

I'll sum up by saying that I have code where join seems to be just plain not working, broken.

I have a little bit of code that looks like this:

print @lines; # prints array, no prob. print join("", @lines); # prints array, but not on win32.
The problem is that only the first print statement causes anything to be printed. The first print statement causes @lines to be printed, but the second one doesn't. In other words, the first construction works, but using join seems to just eat the array. BUT only on win32 - on linux it works fine. I even thought maybe it was just a 5.6.0 bug, so I updated to activestate's 5.6.1 - same prob.

Even more frustrating is that I can't cause this reliably - I tried to tear it down into a simple test case...but the test case doesn't exibit the bug. I'm going insane. But I swear that damned join is NOT working and I can't imagine why. :-(

I would feel better if I could make a test case fail, but I can't and I can't imagine any difference between the simplest test case and my actual code. I mean the first line works and the second one doesn't - how can it be simpler?

Replies are listed 'Best First'.
Re: I think I'm going insane. Join doesn't work?
by pepik_knize (Scribe) on Mar 21, 2002 at 06:28 UTC
    I had a similar problem on Win98, using perl through cygwin. It turned out that somehow, someway, it was interpreting some of my data to be printed as escape sequences, and deleting surrounding text. Instead of printing :
    "The number 123 goes here." It would print
    "Th23 goes here." (Or something like that.) The number was a 12 digit UPC that was joined together, so maybe it's the same problem. I got around it by not printing it at all. Good luck.
Re: I think I'm going insane. Join doesn't work?
by Anonymous Monk on Mar 21, 2002 at 03:28 UTC
    What kind of data is in @lines? How large is @lines? Is it possible that joining it into a single scalar is causing a buffer or memory overflow when you try to print it on the win32 system (granted, you should see an error)?

    Try assigning the join to a scalar and printing the scalar on the win32 system. Or try joining @lines with a delimiter and splitting it again (if you want to prove the join statement works).

    Anyway, I'm no monk, these were just my initial thoughts.

    -Bird

Re: I think I'm going insane. Join doesn't work?
by Bobcat (Scribe) on Mar 21, 2002 at 03:08 UTC
    Would it be possible to post a bit more code?

    Simply looking at the above example, there really doesn't seem to be anything wrong. Perhaps there's a clue somewhere in a block above what you've posted?

Re: I think I'm going insane. Join doesn't work?
by erikharrison (Deacon) on Mar 21, 2002 at 13:24 UTC

    I second the motion to see more code. Perhaps we can help you whittle it down to something we could make a bug report out of, or help you fix.

    Cheers,
    Erik