Re: [PBML] Arrays (again)
- burnt_ice091 <burnt_ice091@...> listed this:
: How do you split an array to a certian amount of bytes,
: and would it work just like splitting from a character?
Basically, you can't. You need a lower level language to
find how many bytes an array uses and where it can be split.
C comes to mind.
If you want to split on an _element_, there is no
problem. Just use an array slice:
my @array = ( 1 .. 8 );
my @first = @array[ 0 .. 4 ];
my @second = @array[ 5 .. 7 ];
my( @first, @second ) = ( @array[ 0 .. 3 ], @array[ 5 .. 7 ] );
: My problem still remains for a different question, though:
: where does the data go that perl 'returns' when you pop
: or un-shift an array? Would 'pop @array,$popkern' make
: the last item of the array go into $popkern?
No, pop returns the value:
my $popped = pop @array;
: I suggest this because it is the same syntax as pushing and
: shifting. Also, if there are any detailed and concise papers
: on manipulating arrays in perl, I would very much
: appreciate that.
You might look at:
perldata (Perl data types)
Randal L. Schwartz's Columns:
Return to Perl Hardware Store:
perldsc (Perl Data Structures Cookbook)
Multidimensional Arrays Tutorial:
Charles K. Clarkson
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Small commercial and residential rehabilitation specialists.
CJ Web Work - Solutions for Real Estate Investors.
> How do you split an array to a certian amount of bytes, and woulditpop(@array), the return for that function is the item removed from the
> work just like splitting from a character? My problem still remains for
> a different question, though: where does the data go that perl 'returns'
> when you pop or un-shift an array? Would 'pop @array,$popkern' make the
> last item of the array go into $popkern? I suggest this because it is
> the same syntax as pushing and shifting. Also, if there are any detailed
> and concise papers on manipulating arrays in perl, I would very much
> appreciate that.
array. You would do something like $val = pop(@array). It of course also
becomes the last return value if you prefer to do things that way....