Re: Strings vs Arrays
- From: lgrinberg@xxxxxxxxx (Leonid Grinberg)
- Date: Sat, 30 Dec 2006 15:58:02 -0500
To push something to an array:
push(@array, $data);
To push something onto a scalar:
$scalar = $scalar . $data;
-or-
$scalar .= $data;
The better method depends entirely on what you intend to do with the
data and how you have it. It is also very easy to both split a string
into an array,
@array = split(/pattern_to_split_over/, $string); # note that the
pattern can just be //, to split every character into its own element
of the array
and to make an array into a string:
foreach (@array) { $string .= $_; }
One thing to note, though, is that array operations in Perl (push(),
splice(), etc.) are wicked fast.
.
- Follow-Ups:
- Re: Strings vs Arrays
- From: DJ Stunks
- Re: Strings vs Arrays
- References:
- Strings vs Arrays
- From: M. Lewis
- Re: Strings vs Arrays
- From: "John W. Krahn"
- Strings vs Arrays
- Prev by Date: Re: Negate a regular expression
- Next by Date: Re: Negate a regular expression
- Previous by thread: Re: Strings vs Arrays
- Next by thread: Re: Strings vs Arrays
- Index(es):
Relevant Pages
|