Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: writing each array element to a unique file

by vladdrak (Monk)
on Dec 15, 2006 at 00:05 UTC ( #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? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2023-02-07 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (40 votes). Check out past polls.

    Notices?