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: Intermediate: Re: [r00tuser] Put log dump in textarea using CGI : Edit Log



FishMonger
Veteran / Moderator

Apr 6, 2013, 6:39 AM


Views: 1032
Re: [r00tuser] Put log dump in textarea using CGI

The first thing that you're doing wrong is forgetting to include the strict and warnings pragmas, which should be in every perl script you write.


Code
use strict; 
use warnings FATAL => 'all';


The strict pragma will require you to declare your vars, which is done with the 'my' keyword.


Code
my @huge_log_details = `command | grep something`;


The key line that's causing your problem is this one.

Code
@formatted_log = $_ . "<BR><BR>";

You are overwriting the array on each iteration of the loop and at the end it will contain only a single element, which is the last element in the @huge_log_details array.


Code
#!/usr/bin/perl  

use strict;
use warnings FATAL => 'all';
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use Data::Dumper;

print header(), start_html(); #HTTP HEADER

my @huge_log_details = `command | grep something`;

my $row_cnt = @huge_log_details;
my $formatted_log = join '<br><br>', @huge_log_details;

print textarea(-name=>'foo',
-default => $formatted_log,
-rows => $row_cnt,
-columns => 150
);



(This post was edited by FishMonger on Apr 6, 2013, 6:39 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Apr 6, 2013, 6:39 AM


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

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