wise and venerable monks... I'm runnning perl 5.8.1 on OS X, 10.3.4. my code:
#!/usr/bin/perl -p use strict; use Net::FTP; use POSIX qw(strftime); my $filedir='./'; my $localfile='index.html'; my $bkup='index.html.tmp'; my $ftpserver='127.0.0.1'; my $ftpdir=""; my $user='scott'; my $password='tiger'; my $insertpoint='<!--insert here-->'; my $dateformat="%A, %d %B %Y, %H:%M:%S"; my $datestring=strftime($dateformat,localtime); my $headline=''; my $post=''; my $ftpfl=0; chdir($filedir) or die "can't chdir:$!\n"; my $old_fh=select(STDOUT); $| = 1; select($old_fh); print "\nheadline:\n"; do{ if ($headline eq ''){ $headline=$_; print "post:\n"; }else{ $post.=$_; } }while(<STDIN>); print "headline: $headline\npost: $post\n"; open(ORIG,"< $localfile") or die "can't open $localfile:$!"; open(BKUP,"> $bkup") or die "can't open $bkup:$!"; select(BKUP); while(<ORIG>){ print BKUP $_ or die "can't write $bkup:$!"; if ($_ =~ m/$insertpoint/ && $post =~ /^[A-Za-z]+$/){ print BKUP "<div class=box><strong>$datestring $headline</stro +ng>\n"; print BKUP "<p class=post> $post</p></div>\n" or die "can't wr +ite to $bkup:$!"; $ftpfl=1; } } close(ORIG) or die "can't close $localfile:$!"; close(BKUP) or die "can't close $bkup:$!"; if ($ftpfl){ print "renaming...\n"; rename($localfile, "$localfile.orig") or die "can't rename $localf +ile to $localfile.orig:$!"; rename($bkup,$localfile) or die "can't rename $bkup to $localfile: +$!"; print "transferring...\n"; my $ftp=Net::FTP->new($ftpserver) or die "Can't connect:$@\n"; $ftp->login($user, $password) or die "can't login\n"; $ftp->cwd($ftpdir) or die "can't cwd to $ftpdir\n"; $ftp->put($localfile) or die "can't put $localfile\n"; }
i'm sure there's more than a few glaring errors, as it's been some time since i tried my hand at perl..but, the biggest problem so far is that STDOUT isn't acting as if it is flushed. when i run this, i see nothing until i start to enter data. once i hit the first carriage return, i see both prompts. I type the rest of the data, hit ^D, and see no other output...even though the files get updated. I know it's a newbie question, and I've R'd the FM, but i still don't see it.

In reply to can not flush stdout by jawright

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.