Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: writing each array element to a unique file

by vladdrak (Monk)
on Dec 15, 2006 at 00:05 UTC ( [id://589942]=note: print w/replies, xml ) Need Help??


in reply to writing each array element to a unique file

First, an array is declared like so:
@myArr = ( 1,2,3,4,5,6,7,8,9,10,11 );
You can write each of these to a new files like this:
@myArr = ( 1,2,3,4,5,6,7,8,9,10,11 ); for my $item (@myArr) { open(ITEM ">$item") or die "could not open $item: $!\n"; print ITEM $item; close ITEM; }

Replies are listed 'Best First'.
Re^2: writing each array element to a unique file
by webfiend (Vicar) on Dec 15, 2006 at 00:14 UTC

    Except that an array is declared like so:

    my @myArr = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11);

    :)

    You were thinking of an array ref, maybe?

    my $myArr = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ];
      duh, yeah. fixed.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://589942]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-24 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found