The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Checking the Empty line in csv file sollins Shell Programming and Scripting 4 05-15-2008 04:48 AM
Re-write first line of a file before printing alexop Shell Programming and Scripting 2 05-06-2008 05:36 AM
How to check for empty file in Perl? deepakwins UNIX for Dummies Questions & Answers 1 03-04-2008 11:00 AM
Printing a Line from a file Nysif Steve UNIX for Dummies Questions & Answers 4 08-31-2007 04:58 AM
printing a line of a file clay UNIX for Dummies Questions & Answers 6 12-15-2000 01:24 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-06-2005
Registered User
 

Join Date: Apr 2005
Posts: 18
printing an empty line in a file (perl)

I know this must be really easy, but i can't get it to work
I've got a perl script, with a file.
I want to print an empty line, and the following doesn't seem to work:
print nameoffile "\n"

thanks for your help!!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-06-2005
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,422
open FILE, ">>/some/file" || die 'Cannot open file for writing';
print FILE "\n";
close FILE;
Reply With Quote
  #3 (permalink)  
Old 05-06-2005
Registered User
 

Join Date: Apr 2005
Posts: 18
thanks, that works, but it doen't when i open a file this way

open(FHConfi,"+< $CONFDIR/minstalador.conf");

(+< means:: +>$file&path Read, Write, Create, overwrites rather then appending.)

How could i write an empty line then??

thanks
Reply With Quote
  #4 (permalink)  
Old 05-07-2005
Moderator
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,422
use Fcntl ':seek';
seek(FILE, 0, SEEK_END);

before the print() to append.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0