LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 03-22-2006, 07:44 AM   #1
Singist
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";
$count=0;
$file="/opt/lampp/htdocs/Admin/stats/history/$year/$month/$day/stats.$hour.$min.shtml";
$current_stats="stats.$hour.$min.shtml";
$workdir="/opt/lampp/htdocs/Admin/stats";

#######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
Agrouf
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
Singist
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
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 40
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
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
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.
 
  


Reply


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


All times are GMT -5. The time now is 06:21 AM.

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