CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Help with saving the output

 



zoomer003
Novice

May 17, 2010, 7:44 AM

Post #1 of 4 (719 views)
Help with saving the output Can't Post

 
chomp(@alllines = qx!/usr/bin/who!);


sysopen (LOG, 'C:\debuglog\log\GPSLOG.txt', O_RDWR|O_CREAT|O_TRUNC);
printf LOG "The data gathered from BCM4751 is below:";
printf LOG "\n\n";
printf LOG $alllines;
close (LOG);


hey guys this is my code im runnin an exe file and want to store the output of that file ... apparently there is some problem with my coding .. appreciate if you guys could help me out
thanks


toolic
User

May 17, 2010, 9:47 AM

Post #2 of 4 (716 views)
Re: [zoomer003] Help with saving the output [In reply to] Can't Post

One possible problem is that $alllines is not the same variable as @alllines. Perl would let you know of such things if you use this code:


Code
use strict; 
use warnings;


Also, you should use print instead of printf in your code.


7stud
Enthusiast

May 17, 2010, 11:30 AM

Post #3 of 4 (714 views)
Re: [zoomer003] Help with saving the output [In reply to] Can't Post

In addition:

1) Search google for 'code tags'. Read the first 10 results and come back and post what you have learned.

2) Start all your programs with the following lines:


Code
use strict; 
use warnings;
use 5.010; #if using perl 5.10+


3) Declare all variables with my(), e.g.:


Code
my $num; 
my @numbers;
my($num1, $num2) = (3, 4);
my %phone_number_for;



4) Use the 3-arg form of open(), and use a variable instead of a bareword filehandle:


Code
open my $INFILE, '<', 'data.txt' 
or die "Couldn't open data.txt: $!";



BillKSmith
Veteran

May 17, 2010, 1:38 PM

Post #4 of 4 (705 views)
Re: [zoomer003] Help with saving the output [In reply to] Can't Post

You probably mean to use print rather than printf. printf requires a format.
Good Luck,
Bill

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives