Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Converting a array to a scalar
Is there any good function to convert an array (this is the content of a fil
e) to scalar (for email sending as the body)

Report this thread to moderator Post Follow-up to this message
Old Post
John
12-23-04 08:58 PM


RE: Converting a array to a scalar
Subject: Converting a array to a scalar

Is there any good function to convert an array (this is the content of a
file) to scalar (for email sending as the body)



I am not sure I understand your questions but I have recently had success
with the module Text-Template... You may wish to look at that module.

If you can send us some code that may help...

jwm

Report this thread to moderator Post Follow-up to this message
Old Post
John Moon
12-23-04 08:58 PM


Re: Converting a array to a scalar
John wrote:
> Is there any good function to convert an array (this is the content of a
> file) to scalar (for email sending as the body)

my $scalar = join '', @array;


John
--
use Perl;
program
fulfillment

Report this thread to moderator Post Follow-up to this message
Old Post
John W. Krahn
12-23-04 08:58 PM


Re: Converting a array to a scalar
----- Original Message -----
From: "Moon, John" <john.moon@myflorida.com>
To: "'John'" <isofroni@cc.uoi.gr>; "Perl Beginners" <beginners@perl.org>
Sent: Thursday, December 23, 2004 3:37 PM
Subject: RE: Converting a array to a scalar


> Subject: Converting a array to a scalar
>
> Is there any good function to convert an array (this is the content of a
> file) to scalar (for email sending as the body)
>
>
>
> I am not sure I understand your questions but I have recently had success
> with the module Text-Template... You may wish to look at that module.
>
> If you can send us some code that may help...
>
> jwm
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
I found a quite easy way to do that.

$content="@the_array";

Is the above method good or am i missing something?


Report this thread to moderator Post Follow-up to this message
Old Post
John
12-23-04 08:58 PM


Re: Converting a array to a scalar
On Thu, 23 Dec 2004 14:24:33 +0200, John <isofroni@cc.uoi.gr> wrote:
> Is there any good function to convert an array (this is the
> content of a file) to scalar (for email sending as the body)

Perhaps the module you are using can do this for you.  If not,
it *may* convert newline sequences to the correct type.  Not
enough information.

Anyway, the normal way to perform this task is to use join.

my $scalar = join "\n", @array;

The above example will join each line together, with a newline
between each.  There won't be a newline on the last line, unless
you add it on.

If you need more information, please include the module name
you are using.

Jonathan Paton

--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

Report this thread to moderator Post Follow-up to this message
Old Post
Jonathan Paton
12-23-04 08:58 PM


Re: Converting a array to a scalar
John wrote:
> I found a quite easy way to do that.
>
> $content="@the_array";
>
> Is the above method good or am i missing something?

That is the same as:

$content = join $", @the_array;

So if you want to have the array separated by the contents of the $" variabl
e
which defaults to ' '?


John
--
use Perl;
program
fulfillment

Report this thread to moderator Post Follow-up to this message
Old Post
John W. Krahn
12-23-04 08:58 PM


Re: Converting a array to a scalar
----- Original Message -----
From: "John W. Krahn" <krahnj@telus.net>
To: "Perl Beginners" <beginners@perl.org>
Sent: Thursday, December 23, 2004 4:06 PM
Subject: Re: Converting a array to a scalar


> John wrote: 
>
> That is the same as:
>
> $content = join $", @the_array;
>
> So if you want to have the array separated by the contents of the $"
variable
> which defaults to ' '?
>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
Thanks that also worked $content=join "", @the_array;
because i want nothing between the elements of the array during join.



Report this thread to moderator Post Follow-up to this message
Old Post
John
12-23-04 08:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:12 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.