Felix Geerinckx wrote:

> on Mon, 06 May 2002 08:32:11 GMT, [EMAIL PROTECTED] (Martin A. Hansen)
> wrote:
>
> > im able to generate records of this kind:
> >
> my $records =
>
> > {
> >           'bleh' => {
> >                       'ISHpix' => [],
> >                       'gelpix' => [],
> >                       'base' => [
> >                                   ''
> >                                               ],
> > [...more keys deleted for brevity...]
> >                       'mt' => [
> >                                 'bleh'
> >                               ],
> >                       'band' => [
> >                                   ''
> >                                 ]
> >                     }
> > }
> >
> > how do i print a specific record?
> >
> > i would like to be able to check if a record already exist so i
> > dont overwrite it.
>
> If I understand your datamodel correctly, your first 'bleh' is a
> primary key, and the second-level hash keys are column descriptors.
>
> You can use
>
>     print "key 'bleh' already exists\n"
>         if exists $records->{'bleh'};
> to check whether a record with a specific primary key already exists.
>
> To print out records, you could use the following subroutine:
>
>     print_record($records, 'bleh');
>
>     sub print_record {
>         my $source = shift;
>         my $key = shift;
>
>         return unless exists $source->{$key};
>         print "Contents of record with primary key $key:\n";
>         foreach my $field (sort keys %{$source->{$key}}) {
>             print "\t$field: ";
>             print "[" .
>                   join(", ", @{$source->{$key}{$field}}) .
>                   "]\n" ;
>         }
>            print "\n";
>         return;
>     }
>
> But I have a question: what is the functional difference between
> "[]" and "['']" in your columns?
>
> --
> felix
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to