Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] New space at each line.

Expand Messages
  • Paul Archer
    perldoc -f seek should start you on your way. You also need to look at concurrency and locking issues. ... I d cry/cry for the future/but I wouldn t get
    Message 1 of 2 , Feb 18, 2005
      perldoc -f seek should start you on your way.
      You also need to look at concurrency and locking issues.

      4:17pm, wb_dsgn wrote:

      >
      >
      > It's just a few liner with the simplest code, reads the text files in
      > directory and open the file to edit it, fine till here, but after
      > editing and saving it's adding ONE additional space at begining of
      > every line?
      >
      > Help the beginner!!!!
      >
      > ######################### edit.pl ###################################
      >
      >
      >
      > #!e:/perl/bin/perl.exe
      >
      > use strict;
      > use warnings;
      > use CGI qw(:standard);
      > use CGI::Carp 'fatalsToBrowser';
      >
      > my $q = new CGI;
      >
      > my $file;
      > my $action = $q->param('action');
      > my $name = $q->param('name');
      > my $text = $q->param('text');
      >
      > print $q->header();
      >
      > if ($action eq "select") {
      > &READTPL;
      > }
      > elsif ($action eq "write") {
      > &WRITE;
      > }
      > else {
      > &READDIR;
      > }
      >
      > sub READDIR {
      > opendir (DIR, "./");
      > my @files = grep {!/^(\.)/ && /\.txt$/} readdir(DIR);
      > closedir DIR;
      >
      > print qq|<form method="POST" action="edit.pl">
      > <select size="1" name="name">
      > |;
      >
      > foreach $file (@files) {
      > print " <option>$file</option>\n";
      > }
      >
      > print qq|<\/select>
      > <input type=hidden name="action" value="select">
      > <input class="form_button" type="submit" value="Select">
      > </form>
      > |;
      > }
      >
      > sub READTPL {
      > &READDIR;
      > open (FILE, "$name");
      > my @filearray = <FILE>;
      > close FILE;
      > print qq|<form action="edit.pl" method="post">
      > <p align="center">
      > <textarea name="text" rows="16" cols="60">@filearray</textarea></p>
      > <input type="hidden" name="action" value="write">
      > <input type="hidden" name="name" value="$name">
      > <input type="submit" value="submit">
      > </form>
      > |;
      > }
      >
      > sub WRITE {
      > open (FILEWRITE, ">$name");
      > print FILEWRITE $text;
      > close FILEWRITE;
      > &READTPL;
      > }
      >
      > exit;
      >
      > ######################################################
      >
      >
      >
      >
      >
      >
      > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >

      --------------------------------------------------------------
      "I'd cry/cry for the future/but I wouldn't get anything done."
      ----------------------Hunters + Collectors--------------------
    Your message has been successfully submitted and would be delivered to recipients shortly.