Last updated February 19, 2008. Created on January 20, 2004.
Edited by ax. Log in to edit this page.

[note from ax to cheryl: this code triggers "suspicious input" because it of "data=". had to escape this with "data=". i also wrapped the lines ("my $template=") at 80 chars to make this look better here - hope i didn't introduce any bugs]

#!/usr/bin/perl -w

use strict;

use DBI;
use Carp;

my $server = 'localhost';
my $database = 'drupal';
my $username = 'me';
my $password = 'password';
my $verbose;

my $dbh = DBI->connect("dbi:mysql:$database:$server", $username, $password )
    or croak "Can't connect to database";
$dbh->{RaiseError} = 1;

# difference between ezp user id and drupal uid (see @uid in migrate.sql)
my $iddifference = 1;

my $template='a:13:{s:16:"profile_realname";s:%d:"%s";s:15:"profile_address";\

my $select = $dbh->prepare( q/select ID, FirstName, LastName from ezp.eZUser_User/ );
my $update = $dbh->prepare( q/update users set data=? where uid=?/ );

while ((my $id, my $first, my $last) = $select->fetchrow) {
    my $name = ($first || '') . ($first && $last ? ' ' : '') . ($last || '');

    my $profile = sprintf( $template, length( $name ), $name );
    $update->execute( $profile, $id+$iddifference );

Looking for support? Visit the forums, or join #drupal-support in IRC.