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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-22-2006, 07:44 AM
|
#1
|
|
LQ Newbie
Registered: Mar 2006
Location: England
Distribution: RedHat 9
Posts: 16
Rep:
|
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
|
|
|
|
03-22-2006, 08:12 AM
|
#2
|
|
Senior Member
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591
Rep:
|
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.
|
|
|
|
03-22-2006, 08:56 AM
|
#3
|
|
LQ Newbie
Registered: Mar 2006
Location: England
Distribution: RedHat 9
Posts: 16
Original Poster
Rep:
|
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.
|
|
|
|
03-22-2006, 11:45 AM
|
#4
|
|
Member
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892
Rep:
|
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.
|
|
|
|
03-22-2006, 06:15 PM
|
#5
|
|
Guru
Registered: Aug 2004
Location: Brisbane
Distribution: Centos 6.4, Centos 5.9
Posts: 15,021
|
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 |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:24 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|