Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert flatfile to mysql using perl

Status
Not open for further replies.

opigrsajklhbfdsvopa

Technical User
Jul 19, 2005
1
US
Need expert help! I have a number of scripts written in perl for a flatfile database. I already know how to access the MySQL database through DBI. At least I got that far.

Example of a sub is below. User.pl is a private file created for each member. Members also have a public file for their posts.

What should perl syntax below look like for MySQL? Any help is appreciated.

sub admin_delete {

$user_file = "$as{'user_id'}.pl";
$match = 0;

open(USER_FILE, "$cgi_path/users/$user_file");
flock(USER_FILE,2) if ($flock == 1);
while (<USER_FILE>)
{
$user_posts = $_;
chop $user_posts;
@user_post_fields = split(/\|/,$user_posts);

if ($user_post_fields[0] == $as{'post_id'} && ($user_post_fields[1] == 2)) {
$match = 1;
last;
}


} # end of while
close(USER_FILE);

&error_admin_post_not_found if ($match == 0);

exit;

} # end of sub admin_delete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top