LPM: RE: join

Tom Braun tom at ichthus.org
Sun Apr 2 20:25:31 CDT 2000


I'm no expert, but it looks to me that you have the join syntax right.  I
tried the following just to make sure

	$scalar = 50;
	for ($i = 1; $i <= 25; $i++) { push @array, $i }
	$temp = join(" ", $scalar, @array);
	print $temp . "\n";

and it printed

	50 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Are you sure you have nothing else in the array than just the numbers...no
endlines or other misc whitespace characters?  You may want to try just
printing out what join is doing manually to see if you get what you're
expecting.  The following should work:

	print $scalar;
	foreach $element (@array) {print " $element"}

If that give you the same funny output, then the problem is probably in your
array somewhere.  You can also try running the script from a prompt, rather
than from the C++ program, to make sure that works.

Hope that helps.

Tom

-----Original Message-----
From: owner-lexington-pm-list at pm.org
[mailto:owner-lexington-pm-list at pm.org]On Behalf Of repett0 at sac.uky.edu
Sent: Sunday, April 02, 2000 8:10 PM
To: LUG; lexington-pm-list at happyfunball.pm.org; UK Labrats
Subject: LPM: join



how do you do a join on a number and an array

say you have the following

$m = 50;
then an array @foo that is an array of 10000 ints...

I want to join them and pass them in too a program(c++)

I pring out the join and its showing wierd things

$temp = join(" ", $m, @foo);

It should look like

50 10 12 8 ....

but it is just flashing faint numbers occasinally by so fast and if I hit
control c it has nothing on the screen..

??

Thanks
Ron






More information about the Lexington-pm mailing list