The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
facing problem in starting a process in background using shell script. dtomar Shell Programming and Scripting 8 04-17-2008 08:11 AM
Problem facing with sed and awk jisha Shell Programming and Scripting 19 04-11-2008 05:20 AM
redirection problem user_prady Shell Programming and Scripting 4 12-10-2007 02:42 AM
please help as i am facing problem with uptime guy009 SUN Solaris 3 06-02-2005 06:59 PM
facing problem with cut command vivekshankar UNIX for Dummies Questions & Answers 3 05-25-2005 12:21 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-21-2005
vivekshankar vivekshankar is offline
Registered User
  
 

Join Date: May 2005
Posts: 69
facing a problem in redirection

Hi,
I am doing this perl script

print (@line(1..15));

the lines 1 to 15 get printed...

how can i redirect this to file?

thanks and regards
vivek.s
  #2 (permalink)  
Old 05-21-2005
auswipe's Avatar
auswipe auswipe is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Wide Awake Wylie, Texas
Posts: 535
There are two ways. The really simple method is to just redirect to a file. Anything that gets printed to STDOUT (by default, print goes to STDOUT) will go to a file.

`myPerlRoutine.pl > myFile.txt`

Or you can do it in code:

Code:
open (LOGFILE, ">logfile.txt") || die "$!";

# <blah blah blah>

print LOGFILE (@line(1..15));

close(LOGFILE);
  #3 (permalink)  
Old 05-22-2005
vivekshankar vivekshankar is offline
Registered User
  
 

Join Date: May 2005
Posts: 69
Hi!
I want to do it in the same file which i opened for editing.........without creating temporary files....can this be done?

THANKS!!!


Regards
Vivek.S
  #4 (permalink)  
Old 05-22-2005
cbkihong cbkihong is offline Forum Advisor  
Advisor
  
 

Join Date: Sep 2002
Location: Hong Kong, China
Posts: 1,624
If you have a filehandle which you previously open()ed for writing, you can print() to it.
  #5 (permalink)  
Old 05-23-2005
vivekshankar vivekshankar is offline
Registered User
  
 

Join Date: May 2005
Posts: 69
Thanks!!

regards
vivek.s
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0