Hello,
I am trying to write a small CGI program to edit one line of a very long aliases file. The one line consists of the name: pageoncall and a pager number in the form of:
email1234567890@pager.com
/email. The pager number listed within that aliases could be in several other locations within the file. I have written most everything with the exception of this. I cannot figure out how to edit just that one line within the file. Here is the code that i have so far:
#!/usr/bin/perl
use CGI qw(:standard);
open(FILE, "/test/aliases") or die "Couldn't open $0";
print header('text/html'),
start_html('Answer the call!'),
h1('Select your pager number and click submit:'),
start_form,
popup_menu(-name=>'pager',
-values=>['','1234567890@messaging.sprintpc
+s.com',
'1234567890@archwireless.net',
'0987654321@archwireless.net']),p
+,
submit,
end_form;
if (param() )
{
my $pager = param('pager');
if($pager == '')
{
print "You selected an invalid number, please
+try again.";
}
while(<FILE>)
{
if(/^pageoncall:/)
{
print FILE "pageoncall: $pager";
}
}
}
Any help would be gre
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.