Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: grab 2 blocks of texts from file

by temporal (Pilgrim)
on Apr 12, 2012 at 15:21 UTC ( #964770=note: print w/ replies, xml ) Need Help??


in reply to grab 2 blocks of texts from file

Your code doesn't do what you've specified. Maybe you didn't post all of it?

It builds a string into the $eval variable containing the first block of text from your file (including your markers).

It then pushes the lines from the second block (including your markers) into @text1.

Then it copies @text1 minus your markers over to @arrBlock.

So in the end, @arrBlock contains your second block and @text1 contains your second block with the markers...

It would probably be more efficient to do an array slice:

@firstblock = @text1[1..($#text1-1)]; # remember the left index of the slice can never be greater than the r +ight... no -1

Not sure what you mean by not being able to do a foreach loop through it:

foreach $value (@arrBlock) { print "$value\n"; }


Comment on Re: grab 2 blocks of texts from file
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2015-07-07 07:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (87 votes), past polls