Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Assigning multiple lines into first element of array

by tybalt89 (Prior)
on Feb 29, 2020 at 22:42 UTC ( #11113588=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    #!/usr/bin/perl
    
    ...
    open my $handle, '<', $filename or die "$! opening $filename";
    my @array = map s/>\z//r =~ s/^(?!>)/>/r, do { local $/ ="\n>"; <$hand
    +le> };
    use Data::Dumper; print Dumper \@array;
    
  2. or download this
    #!/usr/bin/perl
    
    ...
    open my $handle, '<', $filename or die "$! opening $filename";
    my @array = split /(?=>)/, do { local $/; <$handle> };
    use Data::Dumper; print Dumper \@array;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2021-10-25 14:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (89 votes). Check out past polls.

    Notices?