🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.perl.misc
Article #273

splice

#273
From: Amri, Kuross [WOLL:4009-I:EXCH]
Date: Tue, 14 Mar 2000 00:00
63 lines
2585 bytes
Hello again,
        I have another dillemma. I am using a splice function to delete
an old
entry in an array after creating a new one. Pretty basic as far as edit
functions go. 
        However, to delete an old entry you need to know its position in
the
array. I don't know how to figure out its position so I can delete it.
As a result other things are being deleted in the array this is a
problem.
        The code is included below. If anyone can help me on this, it
would be
appreciated. 
        The Post{'seek'} that you see passed as an argument is an
identifier of
a particular entry. It is actually a combo of letters & numbers joined
by '%&'. 

Regards,

Kuross Amri

sub edit_save   {

   my $new_entry;
   my (@info, $entry);
   my $location;

   print $header;
   print(-s $comments_datafile);                #check file

   open (FILE, "<$comments_datafile") or die "Couldn't Open Datafile:
$!";
   @info = <FILE>;
   close FILE or die "Couldn't Close $comments_datafile: $!";

#   print "$#info";                                     #check array for
contents

   $new_entry.=$Post{"seek"};                           #creating the
new entry to be parsed
   $new_entry.="%&";
   $new_entry.=$Post{"bob"};
   $new_entry.="\n";
         
   splice (@info, $Post{'seek'}, 1);                    #delete entry. 
   push @info, $new_entry;                              #add new entry  
   @info = sort (@info);                                #re-sorts the
file


   open (FILE, ">$comments_datafile") or die "Couldn't open
$comments_datafile: $!";
   print FILE @info;
   close FILE or die "Couldn't close $comments_datafile: $!";

   print "@info";                               #testing to see what is
in array 
   print "$new_entry";                          #testing contents of
$new_entry
   print $footer;
}
Technical Details
Message-ID: <38CDC25C.3FD0874A@nortelnetworks.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1133f4,9530b6e516ce4505,start
X-Google-Attributes: gid1133f4,public
X-Google-Thread: fa0ae,9530b6e516ce4505,start
X-Google-Attributes: gidfa0ae,public
X-Google-Thread: 112333,9530b6e516ce4505,start
X-Google-Attributes: gid112333,public
From: "Amri, Kuross [WOLL:4009-I:EXCH]" <kamri@nortelnetworks.com>
Subject: splice
Date: 2000/03/14
Message-ID: <38CDC25C.3FD0874A@nortelnetworks.com>
X-Deja-AN: 597204905
Content-Transfer-Encoding: 7bit
Organization: Nortel Networks
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: comp.lang.perl.misc,de.comp.lang.perl,fr.comp.lang.perl