I have made a GUI application using Ruby\FXRuby and i would like to be able to connect it to a database to save the data that is entered in the application. It's a simple application that saves a person's contacts (name, address, email, etc.). I'm trying to use SQLite3 but i have not been able...
hello, i'm new to ruby and i'm trying a to write a simple greeting program that accepts input from the user (user's name) but its not completely working the way i would like it to. It doesn't print out the goodbye messages and doesn't work when nothing is typed in (Hello World should print out)...
i'm trying to learn prolog and one of the problems that i am trying to do is the following:
Write a Prolog program that takes the total number of flags of each color and some initial arrangement
of flags. The initial arrangement may be empty, or it may specify that certain positions in the line...
ok, i made the change from [i+2..-1] to [i+2..$#line] and it is now working correctly but isn't -1 and $#line stating the same thing, to go from i+2 to the end of the list?
Oh, ok. i get it. thanks franco but one minor problem. when i ran the code for format 3 the address field did not print to the outfile but the other fields did and in the correct order.
instead of printing to outfile:
23573456 Mary Beth Davis 000 (541) 555-4321 234 Bridge St. Abc, OR. 24356
it...
franco, could you explain your code for format 3, i don't fully understand how it works:
for(my$i=1;$i<@line;$i++){
if($line[$i]=~/^\(\d{3}\)$/){
$phone=join' ',@line[$i..$i+1];
$name=join' ',@line[0..$i-1];
$address=join' ',@line[$i+2..-1];
last;
}
}
how did you determine...
thanks franco for your help.
i got the second format to work.
elsif(length($line) == 150){
$name = substr($line,0,50);
$account = substr($line,50,10);
$phone = substr($line,60,14);
$status = substr($line,74,3);
$address = substr($line,77,73)...
Here is what the code looks like so far:
#!/usr/bin/perl
open(INFILE, "input.txt");
open(OUTFILE, ">output.txt");
open(ERRORFILE, ">errorfile.txt");
#performs data cleanup and formatting functions on a semi-structured input
#file.
#name = [A-Za-z\s-']+
#phone number =...
These are the fields that make up a data record:
Name: Customer names may contain any alphabet letter, spaces, hyphens, and apostrophes.
Address: May contain any letter or number, spaces, and the following symbols: # , ' :. - /
Phone Number: Will always be in format (###) ###-####
Status: 3...
here is an example of how the input data could look in the text file:
Joe Smith, 1 Uni Dr. Camarillo, CA. 93012., (805) 555-1234, AW87124356, 001
Joe Smith AW87124356(805) 555-12340011 Uni Dr. Camarillo, CA. 93012...
...($name,$address,$phone,$status,$account) = @line;
if(lenght($name) < 50)
{
$pad_len = 50 - length($name);
$padded = sprintf outfile "%-*s", $pad_len, $name";
}
...repeat process for other fields
}
but looking at this, it seems that it will print each of the fields one at a time...
what about for a pattern of three?
i tried just simply adding another variable :
occurs([X,Y,Z|_],X,Y,Z).
occurs([_|L],X,Y,Z) :- occurs(L,X,Y,Z).
but this does not work at all.
any suggestions?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.