Re: Remove last 10 lines of all files in a directory



usenet@xxxxxxxxxxxxxxx wrote:
DJ Stunks wrote:
$#file -= 10;

Hey, no kidding? I never realized $#foo could be assigned to... that's
a neat trick.

yeah, it is.

>>>>> "pd" == perldoc perldata writes:

pd> The length of an array is a scalar value. You may find
pd> the length of array @days by evaluating $#days, as in
pd> csh. However, this isn't the length of the array; it's
pd> the subscript of the last element, which is a different
pd> value since there is ordinarily a 0th element. Assigning
pd> to $#days actually changes the length of the array.
pd> Shortening an array this way destroys intervening values.
pd> Lengthening an array that was previously shortened does
pd> not recover values that were in those elements. (It used
pd> to do so in Perl 4, but we had to break this to make
pd> sure destructors were called when expected.)

-jp

.



Relevant Pages

  • Re: Assignment to slice
    ... > I do not understand why python behaves the way it does ... Python doesn't like that I'm assigning ... > Why does assigning to a slice of non-existent array ... at least the first index in the slice should be ...
    (comp.lang.python)
  • Re: non repeating random numbers
    ... numeric array, all of its elements are set to zero. ... However, as I said in the beginning, this method of assigning ... (making it an efficient method to use). ...
    (microsoft.public.vb.general.discussion)
  • Assignment to slice
    ... Python doesn't like that I'm assigning ... Why does assigning to a slice of non-existent array ... in which I tried to assign out-of-range, ...
    (comp.lang.python)
  • Re: never heard anything like it in my life?
    ... other progarmmers) talk about assigning "to an array", ... talk about assigning to a member of an array using the same terminology. ... But again, that is not assigning to an array, it is assigning to a pointer, ...
    (comp.lang.cpp)
  • Re: Automatic (?) array bounds checking
    ... we are clearly assigning a 6-element array ... Yeah, see Richard's comments--he caught my oversight on a ...
    (comp.lang.fortran)