Well, it's question time again... I have the following code:
#!/usr/bin/perl -w use strict; # Modules to use use Config::IniFiles; # Variables my ($CorE, $PlugInDir, $LogFile, $ForkLimit, $TftpRoot, $TftpPath, $Fi +leStyle, $DateStyle, $PreCmd, $PostCmd, $SNMPver, $SNMPretry, $SNMPwait, $SNMPm +tu, $SNMPdebug, $SNMPCommunity, $TFTPserver); # Start print 'Would you like to edit the current pancho configuration file or Create a new file [e/C]? ';$CorE=<STDIN>; # Create new file if ($CorE eq 'C') { open (CREATE,">>pancho.conf"); print CREATE "[Global]"; print 'What is the IP address of your TFTP server? '; $TFTPserver=<STDIN>; print CREATE $TFTPserver; close (CREATE); }
What I am trying to do is create a file when the user enters "C" as their answer. Then when it creates the file it will start the file heading with "Global" and all the user to then enter the ip address of their TFTP server. The script should then write their tftp server ip address to the file, close the file and then exit. However, what I have doesn't make anything in the if loop run. I enter "C" as my choice and then it just dies. I would appreciate any help you can offer.

In reply to Trying to Create and Write to a file by IPstacks

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.