Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

smoother way to create an inital array

0 views
Skip to first unread message

ZZT

unread,
Dec 6, 2002, 5:09:42 AM12/6/02
to
Hello,

at this time I create an data-array (for easier looped processing) in
the header of my script like this way:

name[0]="...";
address[0]="...";

name[1]="...";
address[1]="...";

Is there a better way to create such an array?

thanks

Bernard El-Hagin

unread,
Dec 6, 2002, 5:15:08 AM12/6/02
to


I'm not sure what you're trying to do, but perhaps this is what you're
looking for:


@name = ('...') x @name;
@address = ('...') x @address;


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'

Anno Siegel

unread,
Dec 6, 2002, 5:20:36 AM12/6/02
to
According to ZZT <a@b.c>:

> Hello,
>
> at this time I create an data-array (for easier looped processing) in
> the header of my script like this way:
>
> name[0]="...";
> address[0]="...";
>
> name[1]="...";
> address[1]="...";

That is not Perl. Presumably you're doing

$name[ 0] = "...";

etc.

> Is there a better way to create such an array?

Who knows. It depends on how your raw data are given. If you are
setting them from strings in the source, this is an alternative:

@name = ( 'name0', 'name1', ..., 'nameN');
@address = ( 'addr0', 'addr1', ..., 'addrN');


Anno

0 new messages