Last updated 25 June 2016. Created on 20 January 2004.
Edited by tulvit, 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.