Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Arrays (again)

Expand Messages
  • Charles K. Clarkson
    ... 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
    Message 1 of 3 , Jun 6, 2002
    • 0 Attachment
      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 ];

      Or:
      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)
      <http://www.perldoc.com/perl5.6.1/pod/perldata.html>

      Randal L. Schwartz's Columns:
      <http://www.stonehenge.com/merlyn/UnixReview/col11.html>
      <http://www.stonehenge.com/merlyn/UnixReview/col35.html>

      Return to Perl Hardware Store:
      <http://perl.plover.com/yak/hw2/slide001.html>


      perldsc (Perl Data Structures Cookbook)
      <http://www.perldoc.com/perl5.6.1/pod/perldsc.html>

      Multidimensional Arrays Tutorial:
      <http://qs321.pair.com/~monkads/index.pl?node_id=90647>

      HTH,

      Charles K. Clarkson
      --
      Head Bottle Washer,
      Clarkson Energy Homes, Inc.
      Small commercial and residential rehabilitation specialists.
      254 968-8328

      CJ Web Work - Solutions for Real Estate Investors.
      972 216-4952
    • burnt_ice091
      How do you split an array to a certian amount of bytes, and wouldit work just like splitting from a character? My problem still remains for a different
      Message 2 of 3 , Jun 6, 2002
      • 0 Attachment
        How do you split an array to a certian amount of bytes, and wouldit 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.

        ,Thank you
      • Richard Maynard
        ... pop(@array), the return for that function is the item removed from the array. You would do something like $val = pop(@array). It of course also becomes the
        Message 3 of 3 , Jun 6, 2002
        • 0 Attachment
          > How do you split an array to a certian amount of bytes, and wouldit
          > 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.

          pop(@array), the return for that function is the item removed from the
          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....

          -Richard
        Your message has been successfully submitted and would be delivered to recipients shortly.