[plug] Perl Question.

David Buddrige buddrige at wasp.net.au
Thu Nov 21 14:45:24 WST 2002


Hi all, 

I am writing a perl subroutine which is intended to take an array of 
strings, and concatenate each string in the array into a single [very long] 
string. 

The subroutine is listed at the end of this email. 

My problem is that for some reason when I print out the variable 
"$single_comment_line", rather than getting a very long string, I get 
something like: 

ARRAY(0x8118e34) 

printed out instead.  Can anyone see why this is happening? 

I am calling the subroutine by passing it a reference to an array of strings 
like this: 

	format_docpp_comment( \@doc_comment ); 

thanks heaps 

David Buddrige. 


# This subroutine takes as input a single array reference, and rearranges 
any
# doc++ commands that are split over multiple lines so that each doc++ 
command
# is on a line of its own, including the /** and */ delimiters which 
indicate
# the start and end of a doc++ comment. 

sub format_docpp_comment
{
   my @doc_comment;
   my $comment_line;
   my $single_comment_line;

   @doc_comment = $_[0]; # give a friendly name to the array

   foreach $comment_line ( @doc_comment )
   {
	chomp $comment_line;
	$single_comment_line .= $comment_line;
   }

   # At this point we have a single string that contains our entire doc++ 
comment.
   # we can now use simple pattern matching to parse it.

   # for now output it so we can see what it looks like:
   print $single_comment_line;
   print "\n";
} 



More information about the plug mailing list