Having some problems here. First time writing an IRC bot... I have the majority of it done (everything but commands), and that is where (funny enough) I am stuck.

Given the following inside of 'project.pjt':

project 1; project 2; project 3; project 4;

I want project 2; (for example) to be erased, leaving project 1; project 3; project 4; . My snippit is as follows:
if($text =~ /!project remove/i){ open(REMOVE, ">project.pjt") || print $sock "PRIVMSG #channel :Sor +ry $nick, I can't remove a project."; $remove = <REMOVE>; $text =~ s/!project remove //gi; $text = "$text; "; $remove =~ s/$text//gi; print $sock "PRIVMSG #channel :$remove"; print REMOVE "$remove"; close REMOVE; }
1) The file contents are stored into $remove.
2) $text, being everything being typed in the channel, is stripped from the given command that triggered it (!project remove ).
3) $text then is fitted for proper format inside the file (meaning, the project name that was to be removed)
4) The file contents are then to be cleared of the project named above in $text.
5) As a test, I'm printing it to the channel screen, and this shows up fine... however when I try to add $remove as the new file, everything is deleted...

I'm using the IO::Socket module, hence the $sock fields... Any input would be greatly appreciated. Again, this is my first bot, so be nice ;)

In reply to Write to file, after manipulation by FireBird34

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.