Posts Tagged ‘perl’

Running perl scripts in background of unix terminal

May 7th, 2009

Script getting too long to load and run? Too many outputs to see?

Try the following;

nohup perl <filename>.pl &

 

This will create a file called nohup.out in the existing directory and & means it runs in the background(i.e. you can close the terminal safely and it still runs)

 

Best part is.. its allows the script to run super super fast.. =) i remembered i tried running this script that gave about 500k mysql entry and output lots of info on my screen.. it took a few hours.. when i did this command… it took like less than 10mins.. =)

 

and im done with my exams.. Time to build up my homepage..

 

Stay tuned.. =)

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Perl and International Calling Codes

April 23rd, 2009

Suppose you have a bunch of numbers and you wanna see which countries its from. It could be the first digit, second or even the third. Well.. you dunt look for country codes which is wrong in this aspect. You have to based on international calling codes which can be found on wiki

yes. i dunt see any modules by perl on international calling codes. only found those on country codes. well. you could do a screen scrap from a website doing a reverse look up on international calling codes, or you could have a file / database containing these info.

Well, i did up a list on a txt file as shown below using wiki:

listofcountries

hopefully it’ll be useful to someone as its formated from wiki to get pure countries<space>calling codes.

Whats next you might say.

you have to do a split in the number. search the first digit thru the db(which is imported from the txt-still need to convert to csv) or open file and search. If digit is not found get 2 digit->search and so on till the 3rd digit

and then if you cant get a match, just do a if else statement to say that the country cannot be found.

Maybe i’ll post the code another time in a .pm file

Well, thats all for now. let me know if i miss out something. =)

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Updates: freeTTS with emotions, perl scripting

April 9th, 2009

Nearly Done with what i want for my FYP CA2. Its more of the top layer being uncovered and many more layers to go. But i did add a few features and im pretty pleased with my result. Shall post an applet once im done.

Implementing machine learning? Possible using weighted phrases and sentences? Still puzzling but I do believe i’ll get it soon enough..

On the other hand, i was implementing a perl script to parse a log file into mysql database. So far seems pretty easy, left with implementing the correct data type for some of the variables.  

Busy busy busy. and im still puzzled with ms robotics studio.

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare

Searching within String in Perl

November 10th, 2008

was working on improving a current script in perl and was trying to search through a particular string to get some variables.

For example, an instance in the loop, a string has already been set as $_ = <hkugmdi name=”myname” folder=”myfolder” title=”mytitle> and i want to obtain the name “myname” in every instance of the loop. the below is an if statement which can get the desired input.

if (( $_ =~ m/name\=\”(\w+)/) || ( $_ =~ m/name\=(\w+)/) )

$_ => current string

m => match

name\=\” || name= => match name=” or name= in the string

(\w+) => first word

some other useful syntax

$& => current value

$` => before the string is matched

$’ => after the string is matched

$1 => first grouping

so for the above example,

when i do a print “before value $`, current value $& and after value $’ to get the string desired $1″

i get

before value <hkugmd, current value name=” and after value ” folder=”myfolder” title=”mytitle> to get the string desired myname

VN:F [1.9.6_1107]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.6_1107]
Rating: 0 (from 0 votes)
DiggTwitterTechnorati FavoritesRedditNewsVineFacebookShare
Get Adobe Flash playerPlugin by wpburn.com wordpress themes