11-07-2011
PERL : check + or - sign in a variable
I have a variable $max = -3;
It can be $max = +3;
I need to check if this variable is a positive/negative value.
if its positive, should print "positive" if not "negative"
How can this be done?
Thanks in advance
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'd like to make a script that I can execute every time I sign on to my linux box that keeps track of the time and allows to me to add a remark to a file. So basically once I log in, I run the script, and it outputs the date and time to a text file (log.txt). But that isn't my problem.
I need... (1 Reply)
Discussion started by: Glider
1 Replies
2. Shell Programming and Scripting
Logic of code
if ( $var is a number ) {
Do something
}
else {
Do something else
}
My question is: How do I check if a variable is a number. All the reg ex that I came up with to match this is failing. Please help. (3 Replies)
Discussion started by: garric
3 Replies
3. Shell Programming and Scripting
Take a look at this code:
#!/usr/bin/perl
use 5.008;
$_ = "somename@address.com";
if(/\@\w+\.com/)
{
print "\n\nmight be an email address\n\n";
}
else
{
print "\n\nnot an email address\n\n";
}
Shouldn't the /\@\w+\.com/ evaluate as true? I've also tried:
... (3 Replies)
Discussion started by: mrwatkin
3 Replies
4. UNIX for Dummies Questions & Answers
Ok so I am working on a command that is going to do a Dig @ a certain IP address which is enclosed in a variable.
Now I thought I had this figure out because it works. The problem is that it does not ALWAYS work.
the variable is IP=192.168.1.1
the commands I have tried are
dig... (2 Replies)
Discussion started by: MrEddy
2 Replies
5. Shell Programming and Scripting
I am working on a perl script that is used to update a list of hosts to a certain file but I am having an issue when I try to perform a check to make sure the user enters valid information. The following is what I have currently written for the script:
IPINPUT:
print "Enter IP Address: ";... (2 Replies)
Discussion started by: Takau
2 Replies
6. Shell Programming and Scripting
Hi Experts,
I am checking how to get day in Perl.
If it is “Monday” I need to process…below is the pseudo code.
Can you please prove the code for below condition.
if (today=="Monday" )
{
while (current_time LESS THAN 9:01 AM)
... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies
7. Shell Programming and Scripting
HI
I'm terribly new to perl .. I;ve been trying to use this command to search and replace entries in a file
I tried this and it works
perl -p -i -e 's/old/new/' filename
Problem is that I have a list of email addresses and I need to serach and replace the entire email address as my... (5 Replies)
Discussion started by: mnassiri
5 Replies
8. Shell Programming and Scripting
I have a script which is reading value from property file and doing replacement in source location which contains multiple files.
property file has values
abc=xyz; yux=1;version=3.0;
bcd=123;apple==mango
when my script does search and reads value from property file.
its replacing value... (1 Reply)
Discussion started by: Shamkamde
1 Replies
9. Programming
My issue is that the perl script (as I have done it so far) created empty branches when I try to check some branches on existence.
I am using multydimentional hashes: found it as the best way for information that I need to handle. Saing multidimentional I means hash of hashes ... So, I have
... (2 Replies)
Discussion started by: alex_5161
2 Replies
10. Shell Programming and Scripting
Hello,
Below script works fine when I manually enter required information for each file. When it comes to shell in auto mode, it gives various errors.
I am under ubuntu 14.04 / trusty.
manual_run.sh:
#!/bin/bash
/usr/bin/ffmpeg -start_at_zero -copyts -i nicki.mp4 -c:v mpeg2video \
-b:v 500k... (3 Replies)
Discussion started by: baris35
3 Replies