Programming :: Perl Script - Phone Number Validation

Apr 1, 2010

I am doing a perl script validation for Phone numbers. The normal phone number format is 01-32145. I need to do two validations for the phone number

1) A valid phone number can have at least two digits as prefix and at least five digits as postfix. e.g. 01-01011
2) A valid phnoe number can't contain only the digit "0" in either area code or phone number e.g. 00-11111 or 01-00000 is not allowed.

I am able to do the first validation, but not the second. I am pasting my code part here. How to add the second validation inside my current code.

open(TMPOUTPUT, "<$tmp_output_file") or die "Can't open output";
open(OUTPUT, ">$output_file") or die "Can't open output";
while ($line = <TMPOUTPUT>) { $line =~ s/ +
//; ($cur_phone, $xxxxxx, $xxxxxx) = split(";", $line);
($cur_phone_prefix, $cur_phone_postfix) = split("-", $cur_phone);
$length_prefix = length ($cur_phone_prefix);
$length_postfix = length ($cur_phone_postfix);
if ($length_prefix < 2 || $length_postfix < 5 ) {
print "Invalid phone number: $cur_phone ";
} else { print "Valid phone number: $cur_phone ";
} } close TMPOUTPUT; close OUTPUT;

View 9 Replies


ADVERTISEMENT

Programming :: Perl: Turning A Seconds-since-the-epoch Number Into "X Days Ago" Or Similar?

Aug 26, 2010

Is there a perl module that will let me turn numbers into human readable measures of time? For example, 1280513294 would be "26 days ago". If so, what's its name?

View 2 Replies View Related

Programming :: Form Field Validation Using PHP

Sep 10, 2009

I want to validate a web form using PHP. I spent ages confusing myself with client side scripting and realised until I worked out it is not what I want. My problem is that now I am looking at PHP and everything is mixed up in my brain. I need to point out that PHP is very new to me! This is what I already have:
1 An html page with my form on it.
2 PHP page which emails the contents of the form to me.

The above works well. For the sake of clarity, here are my pages (cut down to the essentials where appropriate): My html form:
first name surname
Email  
Home phone
Mobile
Work phone

I have read and understood your terms and conditions. My php script (regform.php)
$receiver = 'me@email'; $subject = 'New registration'; #$message = 'This is a new registration.'; $surname = $_POST['surname']; $firstname = $_POST['firstname']; $address = $_POST['address']; $email = $_POST['email']; $homeph = $_POST['homeph']; $mobileph = $_POST['mobileph']; $workph = $_POST['workph']; $time = $_POST['time']; #from here $oldaddress = $_POST['oldaddress']; $DOB = $_POST['DOB']; $elect = $_POST['elect']; $job = $_POST['job']; $salary = $_POST['salary']; $employer = $_POST['employer']; $benefit = $_POST['benefit']; $smoke = $_POST['smoke']; $claim = $_POST['claim']; $children = $_POST['children']; $children2 = $_POST['children2']; $pets = $_POST['pets']; $pets2 = $_POST['pets2']; $require = $_POST['require']; $terms = $_POST['terms']; $rooms = $_POST['rooms']; $body = "first name:$firstname
surname:$surname
DOB:$DOB
email:$email
home phone:$homeph
mobile phone:$mobileph
work phone:$workph
address:
$address
time at this address:$time
previous address:$oldaddress
electoral register:$elect
employment:$job
employer:$employer
salary:$salary
benefit claim:$benefit
future benefit:$claim
children:$children
ages:$children2
pets:$pet
pet type:$pets2
other requirements:$require
terms:$terms"; $headers = 'From: email' . "
" . 'Reply-To: email "
" . 'X-Mailer: PHP/' . phpversion(); mail($receiver, $subject, $body, $headers, "From: $firstname $surname
" . "Reply-To: $firstname $surname class="inlineimg" />;

You can see there are many more form fields than I have shown in my example html form above. What I want is that the following fields have to be filled:
1 mobileph
2 email
3 terms (checkbox)
I would like the user to be asked to fill the form in properly if any/all of the 3 fields have not been filled in. I imagine I need some php in the html page and some more in the php page. I am certainly not asking any one to do this for me but I am really confused. I have googled and copied and pasted and edited for 6 hours and I am lost. What I want is a very simple and clear example of the code needed. Sorry if I sound as if I can't search properly on Google: in this case I clearly can't!

View 2 Replies View Related

Programming :: If Test Validation - Using Char Arrays

Jun 9, 2010

I'm writing a code to get the index of the last occurrence of a given substring in a string.

Code:
int StringHandler::lastIndexOf(string src, const string s) {
unsigned int lastIndex = string::npos;
if (src.find(s, 0) == string::npos) {
return -1; } else {
bool isLast = false; unsigned int i = 0; do {
lastIndex = src.find(s, i);
if (lastIndex != string::npos) { i = lastIndex + 1;
if (i == src.size()) { isLast = true;
} } else { isLast = true;
} } while (!isLast);
} return lastIndex;
}

My problem is: execution steps into an if with a false condition! Check the values of i and src.size() at the right panel. How could be possible for the program to run the highlighted statement? The if condition above is false! [URL]. I could use char arrays, for example, but this kind of false validation has happened to me more than once, I'm using G++ 4.5 with these flags: -O0 -g -Wall -c

View 3 Replies View Related

Programming :: Data Validation - Input Contains Digits And Certain Alphabets

Apr 8, 2010

I am having a huge problem checking the data I input to make sure it is correct. What I am trying to achieve is when I input a value, it will check if the input is all digits and if it is not, check to see if it contains certain alphabets. Thus for example, if I were to input in data such as "11A" , the program will then inform me "There is an important alphabet in the program." This would be my expected output. Here is the program I have wrote...

Code:
int test(string r ){ const int arraySize = 10;
char array2[arraySize2] ={'A','B','E','F','G','H','J','K','N','O','P','Q','R','S','T','U','W','Y','Z'};
for(int cntr = 0; cntr <r.length(); cntr++)
if(!isdigit(r[cntr])){ for(int new1 =0; new1<arraySize2;new1++)
for(int cntr1 = 0; cntr1 <r.length(); cntr1++)
if(array2[new1] == r[cntr1]){ return 2; //will return2 when it finds the same
// char in the array and the string r. } else{ return 3;
//will return 3 when there is a char
//in the string which isnt in the array
} } else { return 1; // will return 1 when string is all digit.
} int main() { string r = "11D"; test(r);
if(test(r) == 1) { cout << "ALL ARE DIGITS" << endl;
} if (test(r)== 2) {
cout << "There is an important alphabet in the program." << endl;
} if (test(r)== 3) { // testRoman(r);
cout << "There is an Alphabet in the String which is not in the Array" << endl;
} }

So, the problem I am facing is when I input in data such as 11 or A , the prog will come out the right input. But if I were to put in data such as "11A" , the output coming out will be "ALL ARE DIGITS". The problem which causes this seems to be in the return statement , as once as it finds the first char which is a digit, it will then return 1 and not continue checking the rest of the string. Is there a way I can stop or continue a loop if it has met the condition I stated? What I can do or any other way available for me to check my input?

View 4 Replies View Related

Software :: Fax To Phone Number And Be Able To View The Document Electronically?

Feb 26, 2009

I would like to have someone send me a fax to my phone number and be able to view the document electronically.
Is this possible? and if so what application do you recommend. I guess the concept is similar to eFax (but of course i don't want to pay).

View 1 Replies View Related

Software :: How To Know Nokia Phone Connected Port Number

Jun 22, 2011

I have connected my moblile Nokia 3110c using a data cable to usb to a ubuntu-pc.How can i kanow to which port it is connected and how to confirm this port is using wvdial or not?

View 3 Replies View Related

General :: Perl Script To Replace The Number From Text File?

Jun 21, 2010

on creating a new perl script which replace IP address from the text file. eg. If in a file, we found any word like 11.222.333.44 then it has to be replaced to XX.XXX.333.44

View 8 Replies View Related

Programming :: Mobile Phone Programming Using Linux

Sep 30, 2010

I am trying to work on mobile phone programming in Linux platform using C language. Can somebody guide with this? I tried to search the web but I didnt get appropriate site.Also guide me about the mobile phones compliant with linux platform for programming using C language.

View 5 Replies View Related

Programming :: Socket Programming In Module Perl

Jul 21, 2010

Where is the perl module for programming with sockets?

View 4 Replies View Related

Programming :: Use The Offical Development SDK, Rather Than Hacking The Phone

Dec 10, 2010

recommend a good book to start learning iphone/pad development. I want to use the offical development SDK, rather than hacking the phone.

View 1 Replies View Related

Programming :: Sed To Remove Non-numerics From Phone Numbers?

Jan 26, 2011

Can sed remove non-numerics (apart from an optional leading +) from phone numbers when prefixed with text that must be retained? The need is to make phone numbers exported from an Orage address book to a .ldif file suitable for gnokii to send to a mobile phone. Here are sample lines:

Code:
facsimiletelephonenumber: +91 (123) 1234567
telephoneNumber: +44 (123) 1234567

They have to end up as:

Code:
facsimiletelephonenumber: +911231234567
telephoneNumber: +441231234567

I could do it in awk but am curious to learn if sed can do it.

View 11 Replies View Related

Ubuntu Networking :: USB Tethering To Phone Doesn't Work Unless Phone Is Plugged In During Boot?

Jan 14, 2011

It's installed as a mobile broadband connection. Only works if my phone is plugged in during boot, otherwise plugging in my phone does nothing. For example, I booted my netbook earlier today but my phone wasn't plugged in. Tethering did not work, it just acts as if it isn't present. I rebooted (with my phone still attached) and now tethering magically works.

View 5 Replies View Related

OpenSUSE Hardware :: USB Connection To Phone \ Sometimes The Phone Craches And Needs To Be Rebooted?

May 16, 2010

I have a mobile phone (T68i) attached to my server and everything works fine. But sometimes the phone craches and needs to be rebooted wich is quite annoying.So I want to use a newer phone that is not 10+ years old :-)But when using a K610i or C702 the phone does not appear on /dev/ttyUSB0 as expected.When inserting the usb cable a dmesg gives this:

Code:
[5924924.451033] usb 1-3: new high speed USB device using ehci_hcd and address 19
[5924924.576728] usb 1-3: New USB device found, idVendor=0fce, idProduct=d0d9

[code]....

View 8 Replies View Related

Ubuntu :: Get Offline Web Validation Apps?

Apr 22, 2010

I've just finished my 100% total move from Windows after 2 years of developing on two different systems, one Slackware and one XP. I have come away from Slack because it was just taking too long to maintain the rapid advances in development tools and have now moved onto Ubuntu full time.

The last tool I was using on Windows was Dreamweaver, and not for editing (I had Bluefish for that) but for the HTML validation that worked offline. Thing is, I now can't find anything similar on Ubuntu. I've no idea how to get the W3C Validators working offline and the last two add-ons I tried with Firefox didn't work. Anybody know of any packages with reliable HTML and CSS validation that works offline? An offline link checker would also be useful.

View 1 Replies View Related

General :: NS2 - Some Validation Tests Failed

Jun 11, 2009

After many modifications, I managed to install ns2.28 , but some validation tests failed. I got the following message at the end of validation test:

validate overall report: some tests failed:
./test-all-simple ./test-all-tcp ./test-all-testReno ./test-all-newreno ./test-all-sack ./test-all-tcpOptions ./test-all-sack-full ./test-all-tcpVariants ./test-all-LimTransmit ./test-all-aimd ./test-all-greis ./test-all-rfc2581 ./test-all-sctp ./test-all-tcpHighspeed ./test-all-frto ./test-all-friendly ./test-all-srm ./test-all-realaudio ./test-all-ecn ./test-all-ecn-full ./test-all-quickstart ./test-all-hier-routing ./test-all-lan ./test-all-mcast ./test-all-vc ./test-all-mixmode ./test-all-red ./test-all-adaptive-red ./test-all-red-pd ./test-all-rio ./test-all-vq ./test-all-rem ./test-all-gk ./test-all-pi ./test-all-cbq ./test-all-schedule ./test-all-jobs ./test-all-intserv
to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

Notice that some tests in webcache will fail on freebsd when -O is turned on. This is due to some event reordering, which will disappear when -g is turned on. I tried to run the test individually one after another, but that is too time consuming, it prompts for permission after every test and thus runs many test & opens a lot of xgraph window. The tests I run so far individually, agreed with the reference output. Now I am wondering, should I report a bug about it, or should I hire a kid to run those failed 40 tests( which require hitting the ENTER key 1200 times,maybe ), or what else should I do.

View 14 Replies View Related

Security :: End User Validation Using Squid

May 24, 2009

This question is regarding squid based security. We would like to enforce browser security onto our users and would like to know if anyone has performed this. Our goal is to check a users browser version/plugin level before allowing them to access the internet in our organization. If their browser does not meet a standard compliance level such as patches or if they are using i.e. 5.0 we would redirect them to a page telling them that they need to update their browser before access will be permitted. Has anyone performed any types of checks like these?

View 4 Replies View Related

Programming :: Cannot Install Perl / Tk

May 9, 2010

I just downloaded Tk-804.028 and try to install it (according to the README.linux) but I get:

> perl Makefile.PL
/opt/ActivePerl-5.10/bin/perl-static is installed in /opt/ActivePerl-5.10/lib okay
PPM for perl5.010001
Test Compiling config/perlrx.c
Test Compiling config/pmop.c
Test Compiling config/pregcomp2.c

[code]...

View 5 Replies View Related

Programming :: Perl Tutorial To Use?

May 18, 2011

Any recommendations on what Perl tutorial to use?

View 1 Replies View Related

Programming :: Converting MB/TB To GB In Perl?

Jan 30, 2010

I am taking an input from the user for free and Used capacity in a disk. I wish to convert Input entered in MBTB to GB and this is how i am doing it.

Code:

<some code>
print "Enter Total disk space";
$tot = <STDIN>;
convert($tot);

[code]...

how do i pass the value of conv[0] after conversion back to $tot or $use such that they contain only value which is in GB?

View 3 Replies View Related

Programming :: How To Get Perl Qt4 Working

Jul 24, 2010

I really would like Perl Qt4 bindings. The best I could find is this:[URL]The problem is that the sources would not compile, and the RPMs are for 32-bit machines.Is there really no such thing as good Perl Qt4 bindings?

View 8 Replies View Related

Programming :: MP3 - Tag And Perl Script

Mar 27, 2011

I am a newbie on linux and just searching everything about perl scripting and modules nearly 3-4 days. I need a perl script but one of not easy to find on searching google. Okay now I need a perl script which create or recreate (edit) id3 tags (artist, comment, album, year, cover) of mp3 files stored on my linux centos server. I installed MP3::Tag version 1.13 pearl module to my server. I Searched tutorials about how to use it, finally I get through reading id3 tag of mp3 file but not achieve to modify it or create a new id3tag.

These are the details:
I have a mp3 file called 1.mp3 this script will process that '1.mp3' file read its id3tag if there is one, than modify or create id3tag for it by my fix artist name for example:
'1.mp3' files id3 tag details are like this
Artist: Dj xx
Year:2010
Title:yyyyy
Comment:eerwer
Cover: x.jpg

Now via this perl script which uses MP3::TAG I will change it's
artist as YYY
Title:ttt
Comment:cool
Cover:t.jpg
these are gonna be my fixed values. I mean all '1.mp3' file will have same artist based on script value.

The reason of this script is I will share Dj podcasts on my server and Dj's would have upload their mp3's which has got different id3 tags and cover pics. etc. I want to create more organized podcasts of them by the way I would trigger this perl script via Cronjob.

View 14 Replies View Related

Programming :: How To Generate MD5 / Sha-1 With Perl

Mar 31, 2010

How can I generate a md5 or sha-1 code with perl?

View 2 Replies View Related

Programming :: Make An Online PHP Contact / Phone Book With Simple PHP (no Database)?

Jul 5, 2011

I would like to unzip a simple PHP code files, to have a online PHP contact / phone book. Simply, slow, and not database oriented over complicated setups into settings. I have a PHP / web provider (free), not apache. WITHOUT SQL (like before it may exists) something like this [URL]

View 14 Replies View Related

Fedora :: Regular Expressions And E-mail Validation?

Jan 12, 2010

The * would not have to be because it means everything [az] [0-9 ][$%&!"/()=?'=) but not how to solve[URL]..

ls [0-9a-zA-Z]*[@]*[gmail | yahoo | hotmail]*[.]*[com]
ls [0-9a-zA-Z][.-_][0-9a-zA-Z]*[@]*[gmail | yahoo | hotmail]*[.]*[com]

View 2 Replies View Related

Ubuntu :: Quick Command Line Validation?

Dec 17, 2010

sudo mkdir /etc/adobe=(created a directory in /etc named Adobe)correct?echo "OverrideGPUValidation=true" >~/mms.cfg=(created a text file in my Home directory named mms.cfg which contained the text...OverrideGPUValidation=true...correct?sudo mv ~/mms.cfg /etc/adobe/=(moved from my Home directory to /etc/adobe mms.cfg) correct?These commands were part of a flash tutorial but they did not work.So I cd'd into etc and using sudo tried rm -r /adobe. Basically Iwant to undo what those 3 commands did.Link to tutorial=(Flash in fullscreen is choppy, completely white or crashes)[URL]

View 4 Replies View Related

General :: Validation Failed In NS2.34 In Ubuntu 10.04 64bit

May 11, 2011

I have just installed NS2.34 in my Ubutun 10.04. I have installed it successfully, but I got some failures in validation.

Validate overall report: all portable tests passed but some non-portable tests failed:
./test-all-srm ./test-all-smac-multihop ./test-all-hier-routing ./test-all-algo-routing ./test-all-mcast ./test-all-vc ./test-all-session ./test-all-mixmode ./test-all-webcache ./test-all-mcache ./test-all-plm ./test-all-wireless-tdma

I read the post of [SOLVED] Validation failed in NS2.34 in ubuntu 10.04 remix and followed the steps there. But, the same problem remains. I think the problem may be due to my 64-bit operating system.

View 2 Replies View Related

General :: Validation Failed In NS2.34 In Ubuntu 10.04 Remix

Aug 28, 2010

I have installed Ubuntu 10.04 remix in my new hp mini 110 netbook and I have succeeded in installing NS2.34 after a so many trials but now after running ./validate some of the tests have failed. Is my ns2 installation not successful?

Some non-portable tests also failed:
./test-all-srm ./test-all-smac-multihop ./test-all-hier-routing ./test-all-algo-routing ./test-all-mcast ./test-all-vc ./test-all-session ./test-all-mixmode ./test-all-simultaneous ./test-all-webcache ./test-all-mcache ./test-all-plm ./test-all-wireless-tdma ./test-all-satellite to re-run a specific test, cd tcl/test; ./test-all-TEST-NAME

View 6 Replies View Related

Programming :: Perl - Interpreter For Fib Numbers

Apr 1, 2010

As some of you know that I am new to this forum. I have another problem that I got stuck on. I have this file called "Fib.rbb" and my instructor told us to write an interpreter program by using Fib.rbb.

"You are to write an interpreter in Perl for Rongs Basic Basic (RBB) as explained in class. The BNF description for RBB and a test file called Fib.rbb are part of the RBB.zip file which is available in the Course Documents folder on blackboard. If you call your interpreter myIntp.pl, you would execute the program via perl myIntp.pl Fib.rbb

Code: Print "A few Fibonacci numbers:"

View 3 Replies View Related

Programming :: Unable To Find The Perl

Mar 9, 2011

Just installed Fedora 14. I wanted to try "Hello World" with perl. But where is it?

Code: [user]@user bin]$ ls

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved