Re: Array Handling

2002-09-24 Thread Felix Geerinckx

on Tue, 24 Sep 2002 13:46:32 GMT, Rohit Mishra-R53658 wrote:

> Is there any way to open a "handle" to an array as we open a handle
> to a file??  The condition being we can use that "array handle"
> everywhere we can use a file handle

http://search.cpan.org/author/ERYQ/IO-stringy-2.108/lib/IO/ScalarArray.pm


-- 
felix

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




Re: Array Handling

2002-09-24 Thread david

Rohit Mishra-R53658 wrote:

> Hi all,
> 
> Is there any way to open a "handle" to an array as we open a handle to a
> file??  The condition being we can use that "array handle" everywhere we
> can use a file handle
> 

why would you want to do that? to save yourself not having to move the whole 
array around in function calls? if that's your case, make a reference to 
the array and use it everywhere:

#-- big array
my @array = (1..100);

#-- reference it
my $ref = \@array;

#-- now use it everywhere without copying the whole array
sub1($ref);
sub2($ref);

... etc

david

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




Re: Array Handling

2002-09-24 Thread James Edward Gray II

I think you're looking for:

push @array, $elements, $to, $add;

On Tuesday, September 24, 2002, at 08:34  AM, Rohit Mishra-R53658 wrote:

> Hi all,
>
> Is there any way to open a "handle" to an array as we open a handle to 
> a
> file??  The condition being we can use that "array handle" everywhere 
> we can
> use a file handle
>
> Like if we do:
>
> $fh = new FileHandle "file.txt", O_APPEND;
> print $fh "Written!\n";
>
> it will add a line to the file file.txt.
>
> Now is there any way to do:
>
> $ah = new ArrayHandle @array, O_APPEND;
> print $ah "Written!\n";
>
> it should add a line to the array @array.
>
> I realize that the tie function could help. But I'm not able to 
> implement it.
>
> TIA
> -Rohit
>
>
>
> -- 
> 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]




Array Handling

2002-09-24 Thread Rohit Mishra-R53658

Hi all,

Is there any way to open a "handle" to an array as we open a handle to a
file??  The condition being we can use that "array handle" everywhere we can
use a file handle

Like if we do:

$fh = new FileHandle "file.txt", O_APPEND;
print $fh "Written!\n";

it will add a line to the file file.txt.

Now is there any way to do:

$ah = new ArrayHandle @array, O_APPEND;
print $ah "Written!\n";

it should add a line to the array @array.

I realize that the tie function could help. But I'm not able to implement it.

TIA
-Rohit



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