LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 06-13-2003, 11:29 AM   #1
richhoward
LQ Newbie
 
Registered: May 2003
Posts: 18

Rep: Reputation: 0
Help in PERL with an IF statement!


Hey guys,
I have a .ini file that has 6 categories broke up by ˝ marks.
I am trying to figure out if the category called $t if it has anything in it to print this image, if it does not, to not pring that image. Cause in that $t it can only equal t.gif to pring the image. So can somebody please help me make an if statement for that please? Thanks and have a great day!
 
Old 06-13-2003, 11:37 AM   #2
richhoward
LQ Newbie
 
Registered: May 2003
Posts: 18

Original Poster
Rep: Reputation: 0
if ($t eq "t.gif") {
print "<img border=0 src=http://www.desaint.com/desa/images/t.gif>";
if ($t eq "") {
print "No Image";
}
}

this is what I tried but it is not working
 
Old 06-13-2003, 12:12 PM   #3
kiveol
LQ Newbie
 
Registered: Jun 2003
Location: North Shore Chicago
Distribution: Slack 9
Posts: 1

Rep: Reputation: 0
I'm not positive I fully understand your question, but the easiest way to do an IF statement of that sort is to first determine if there is anything in the variable $t. (In my code I'm making the assumption that you have the image name in $t) My suggestion is to do the following:

if ($t eq "")
{
print "No image loaded."
}
else
{
print "<img src='http://www.desaint.com/desa/images/$t'>";
}

Of course you can generalize this to make it only work if it has a certain image name, or to do different things for different cases.

Hope this helps.
 
Old 06-13-2003, 12:25 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
You need to close your bracket sooner - eg:
Code:
if ($t eq "t.gif") {
print "<img border=0 src=http://www.desaint.com/desa/images/t.gif>";
}
elsif(!$t) {
print "No Image";
}
 
Old 06-13-2003, 12:27 PM   #5
richhoward
LQ Newbie
 
Registered: May 2003
Posts: 18

Original Poster
Rep: Reputation: 0
Ok well that didnt work,
at the very end of my .ini i have two things $t and $r

you can go to this website and see what I am trying to do

http://12.153.20.72/cgi-bin/remotehome.cgi?product=6
you can go through all the products there is 23 of them,

but I am trying not to print that blank image at the top if that is not there, I am testing this out right above the Product so you see what I am doing but at the end of my code ti has this

˝t.gif˝˝

˝t.gif˝$r would go here˝

and if there is nothing in that $r i want it not even print that image, how do you do that?
 
Old 06-13-2003, 12:30 PM   #6
richhoward
LQ Newbie
 
Registered: May 2003
Posts: 18

Original Poster
Rep: Reputation: 0
nevermind i got it working, thanks alot man
 
  


Reply



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 - IO::Socket::INET - for (;;) statement?? AM1SHFURN1TURE Programming 3 03-29-2005 10:55 PM
the FOR statement (C) sk84blood813 Programming 3 12-09-2004 08:25 AM
For Statement bendeco13 Linux - General 6 10-31-2004 05:31 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 08:09 PM
need perl fuction like c #include statement for header file mrtwice Programming 5 06-19-2003 02:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:28 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration