John Doe wrote:
Hi Wiggins

Am Montag, 7. März 2005 17.19 schrieb Wiggins d'Anconia:

John Doe wrote:

Hi Hendrik

[snip]


Well, in writing this, I solved half of my problem, but one still
remains: how can I remove a line?  I tried with delete, as you see
below, but (of course) this does not work, as $lijn is no array element.

I think you also can't do it with an array (delete does not _remove_ an array element)

Err! More recent Perl's C<delete> can remove an element of an array. Whether this works with Tie::File I did not confirm, but it *should*.

perldoc -f delete



ok, read it, thanks.

"Note that deleting array elements in the middle of an array will not shift the index of the ones after them down--use splice() for that. See "exists"."

that was what I meant (and obviously did not say clear).


Gotcha, can be an important distinction, the difference seems to be when testing for 'exists'.



bash-2.05b$ perl -v
This is perl, v5.8.5 built for i686-linux

bash-2.05b$ perl
my @a=(qw/1 2 3 4 5/);
delete $a[2];
print join ', ', @a, "\n";
rint "size of array: ", scalar @a, "\n";

# this prints:
1, 2, , 4, 5
size of array: 5


Then I read the CHANGES of the most recent version 5.8.6-RC1 on search.cpan.org/dist/perl/, but I could only find there:


            [ 23158]
             [perl #30733] memory leak in array delete
             av_delete() wasn't mortalizing the returned value

             [ 23271]
             only mortalize deleted array elements for AvREAL
             (update to change #23158


What did I miss? What do you mean by "a more recent perl?"



To my knowledge once upon a time 'delete' didn't work at all on arrays, aka in much ealier Perl 5's, or even before. I could be mistaken as well.





BTW: In the case you read some of my posts: What do you, as a routined helper here, honestly think: Should I stop answering questions? I don't want to mainly confuse the people, and I'm not here for public relation, since my name is not john doe and I don't work for tele2.ch.



Certainly not my decision to make, nor am I really one to judge. I haven't read enough of your posts to form an educated opinion, but I haven't seen any harm come from them. Confusing a poster over delete wrt to 'exists' and delete wrt to 'splice' is hardly a reason not to post, I certainly have done such things. That is why it is such a great forum, lots of helpers who read things carefully. I am sure if you did make a gross error, one of the gurus would step in and correct, as long as you learn from them as well, that is the important thing. I have learned far more from these discussions than provided, which is why I feel an obligation to help when I have some tuits (which seem to be further apart these days).



greetings joe



HAND,

http://danconia.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to