Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-22-2006, 07:44 AM   #1
LQ Newbie
Registered: Mar 2006
Location: England
Distribution: RedHat 9
Posts: 16

Rep: Reputation: 0
Angry Problem concatenating a string in perl

Hi all,

Can someone please advise me as to why i keep getting a 'use of uninitialized value in concatentaion (.)0r string pointing at the line i have highlighted in red.

######these are my variables.

#Quote for execution:
chomp($date = qx#/bin/date #);
chomp($month = qx#/bin/date +%B#);
chomp($year = qx#/bin/date +%EY#);
chomp($day = qx#/bin/date +%d#);
chomp($hour = qx#/bin/date +%H#);
chomp($min = qx#/bin/date +%M#);

#chomp($webserver = qx#/sbin/hostname#);
#or set whatever you like wants
$webserver = "name_of_webserver";
$server= "localhost";

#######problem code

sub printhtml {
print FH "<TD>";
print FH "<A HREF\=\"$current_stats\#$server\"> $server </A>";
print FH "\<\/TD>";

any help would be appreciated,

Thank you, Singist
Old 03-22-2006, 08:12 AM   #2
Senior Member
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
try :

sub printhtml {
print FH "<TD>";
print $current_stats;
print $server;
print FH "<A HREF\=\"$current_stats\#$server\"> $server </A>";
print FH "\<\/TD>";

Last edited by Agrouf; 03-22-2006 at 08:13 AM.
Old 03-22-2006, 08:56 AM   #3
LQ Newbie
Registered: Mar 2006
Location: England
Distribution: RedHat 9
Posts: 16

Original Poster
Rep: Reputation: 0
thank you for replying. It didnt work however, it just sends the output to the command line. I should mention at this point, this script tries to login to hosts on local network using rsh <because they're trusted> to minotor uptime etc. all the output is sent to apache web server. The script creates all the necassary files and folders in apache but there is no content because it cant get past line 51 <as above>...its the $current_stats variable its having problems with.
Old 03-22-2006, 11:45 AM   #4
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Are you running Perl with warnings? If not, try that and see if it gives any more info. On the surface, it's hard to tell what could be going wrong.
Old 03-22-2006, 06:15 PM   #5
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,395

Rep: Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395Reputation: 2395
It might be having parsing probs with that line.
try using
${current_stats}\#${server}\"> ${server}
The '${}' syntax helps the parser separate real var names from similar strings.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
perl string comparison problem AM1SHFURN1TURE Programming 3 03-06-2005 10:29 AM
loop through string with perl lfur Programming 2 07-03-2004 08:05 AM
How to separate a string in Perl Bassam Programming 1 06-03-2004 01:33 AM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM
perl string split problem! farhanali Programming 4 06-22-2003 07:08 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration