if you say 'unique' you probably want to concider an autonumber field in
your db for the primary key
it's *always* unique...

you can even do a query on the db to give you the current_id for a table (so
the one you want to insert would be current_id + 1 )

depending on what db you use, the sql is differnt tho, so take a look at
that

otoh, if that's too much of a hassle, just do this:

open I, "counter.txt";
my $num = <I>;
close I;

### do your stuff here ###
{ .... }

### when you're done, increment the counter ###

open O, ">counter.txt";
print O ++$num;
close O;

####

the last bit is not the 'elegant way' and is surely a hassle when the script
runs on more then one machine, but maybe that's all you need...

hth,

Jos Boumans


> List,
>
> Interesting problem that I think proves just how much I really don't know
> about Perl.
>
> I have copyied most of this variable from the internet...
>
> my $unique_id  = time && 0xFFFFF && $$;
>
>  ALL I know is that this uses Unix time and some sort of process ID and
also
> adds some other magic stuff to it.  My question is is... I use this exact
> same variable in another script that inserts $unique_id into a row on a
> database.  As I mentioned the variable is used in two scripts and inserts
> the variable value into the same table in the database. Will this varibale
> ever be the same? (STUPID QUESTION)? The column where this unique_id is
> inserted is also the primary key so I will never have to worry about this
> being the same in the database.  But if it is the unique_id will not be
> inserted in the database and therefore the entire INSERT will not work.
>
> HOPE THIS MAKES SENSE...
>
> Regards,
>
> Daniel Falkenberg
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to