|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Hello,
I am attempting to create a message-board type script. Is there a way a script can save messages (like in a board), without using a database (like mySQL)? Thanks! yoshi http://www.datera.com |
|
#2
|
||||
|
||||
|
Hi,
probably you may save your messages in a flat file.That is the easy way to save the messages with out a database. ------------------ SR - shiju.dreamcenter.net |
|
#3
|
|||
|
|||
|
Thanks.. could you describe to me how placing data into a text file is done, and how to read from it?
yoshi http://www.datera.com |
|
#4
|
||||
|
||||
|
Hello yoshi,
just i write a very small example for flatfile.here i am adding 3 field values in to the database. fields are separated by "|" deliminator. modify this code according to your requirment. #!/usr/bin/perl $firstname="Shiju"; $lastname="Thomas"; $msg="messgae goes here"; $database="database.txt"; #flatfile name #####--- Add a record to the flatfile -### $record=join("|",$firstname,$lastname,$msg); #using join for putting "|" deliminator between the fields. unless(-e $database){ #check whether database is existing or not #if not existing then,create and add a record to it open(DB,">$database") | | die "Error creating database $!n"; #open the database }else{ #database is already their. #append the records to existing database. open(DB,">>$database") | | die "Error opening database $!n"; } print DB "$recordn"; #print the records to the flatfile. close(DB); print "Record Addedn"; ##########- Reading from the flatfile-############# open(DB,$database) | | die "opening the database $!n"; #open database for reading the data from it. while(<DB> ){ #use a while loop for reading whole data from the #database. #assain all record to an array @data=<DB>; } foreach $data(@data){ #read from the array #remove "|" deliminator and separate the field ($firstname,$lastname,$msg)=split(/|/,$data); print "First Name: $firstnamen"; print "Last Name: $lastnamen"; print "Message : $msgn"; } close(DB); tell me if u have any problem with this.. Good Luck!! ------------------ SR - shiju.dreamcenter.net |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > how a message-board is done? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|