perl: howto print to screen & filehandle


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl: howto print to screen & filehandle
# 1  
Old 08-04-2008
perl: howto print to screen & filehandle

Hello,

I need to print messages both to screen and to file handle in perl , like tee does in unix .
Any suggestions ?


Thanks
# 2  
Old 08-04-2008
Is this what you mean?

Code:
$messages = "This is some message!!\n";
$messages .= "Another message!!\n";

$filename = "/some/dir/file.log";

open (FILE, "< $filename" ) or print " Error \n";
 print FILE $message;    #Sends message to {$filename}
 print $message;         #Sends message to Screen
close FILE;

Would write:
This is some message!!
Another message!!

To file and screen.
# 3  
Old 08-05-2008
check if this helps
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl FileHandle Closure during after unlock

Hi we have one function which is used to append data the file in exclusive lock mode in aperl script. This script is executed by multiple threads at the same time. accessing the same file.this script runs throught the day. sometimes the file2.txt size is getting reduced. for eg from 10 M... (1 Reply)
Discussion started by: Shahul
1 Replies

2. Programming

Error:readline() on closed filehandle Perl

Hi, i have run the below perl code and i am getting an error Error:readline() on closed filehandle OR at run.pl line 31. CODE: =========================================== open OR,$ARGV; while (<OR>) { # find the batch date next if length $_ < 3; # BLANK LINE # last if $. > 120; #... (3 Replies)
Discussion started by: pspriyanka
3 Replies

3. Shell Programming and Scripting

How to call a shell script from a perl module which uses Filehandle to login

Hi Guru's, Pardon me for the breach of rules..... I have very little knowledge about Shell Programming and Scripting hope you guys help me out of this troble I have very little time hence could not find the right way to direct my queries. coming to the problem I need to call a... (2 Replies)
Discussion started by: saikrishna_tung
2 Replies

4. Shell Programming and Scripting

awk print: howto single quote not interpreted!?

cat a | awk -F";" '{print "update db set column=' "$2" ' where column1=\""$1"\";"}' > ip-add.sql Hi! I'm a new user! i need to use single quote in the double quotes print string The apex between che "$2" should not be interpreted, but....how?! I'm trying to use \ but don't work correctly! ... (4 Replies)
Discussion started by: Re DeL SiLeNziO
4 Replies

5. Shell Programming and Scripting

Howto Print File Path or Print the Filename

I'm trying to clean up my samba share and need to print the found file or print the path of the image it tried to searched for. So far I have this but can't seem to get the logic right. Can anyone help point me in the right direction? for FILE in `cat list`; do if ; then ... (1 Reply)
Discussion started by: overkill
1 Replies

6. Solaris

Howto troubleshoot Perfomance using vmstat & iostat

Can anyone tell me what to look for in terms of abnormal numbers on vmstat or iostat? I have a box with figures pbelow, how would I tell if it's underperforming & what remedies \ perfomance tuning could I perform? thanks all ------------------------------------- -vmstat 5 5 kthr ... (4 Replies)
Discussion started by: stevie_velvet
4 Replies

7. Shell Programming and Scripting

Perl: Opening a filehandle but not getting anything back from it

I have two perl functions defined, both run a set of shell commands on some somplied data and return hashs of the resulting parsed output from these shell commands. One works, one doesn't and I can't seem to see why. It's driving me insane :mad: The working one: sub getcellstatus { ... (8 Replies)
Discussion started by: Smiling Dragon
8 Replies

8. AIX

print screen

Hi all, Could you please tell me how to take a screenshot in aix (like Print Screen button in windows)? Thanks (7 Replies)
Discussion started by: prashantchavan
7 Replies

9. Shell Programming and Scripting

perl - print to a log file and screen

as the title suggests, i need to print a user message to a log file and the screen using perl. in unix i set up a function using 'tee' like so function Display_Message { echo "$*" | tee -ai $LOGFILE } the following command then obviously displays to the screen and prints to a log... (6 Replies)
Discussion started by: mjays
6 Replies

10. Programming

Howto convert Ascii -> UTF-8 & back C++

While working with russian text under FreeBSD&MySQL I need to convert a string from MySQL to the Unicode format. I've just started my way in C++ under FreeBSD , so please explain me how can I get ascii code of Char variable and also how can i get a character into variable with the specified ascii... (3 Replies)
Discussion started by: macron
3 Replies
Login or Register to Ask a Question