text manipulating

Let`s say I have a script that haves  the following code:

$str=<<'fH';
 some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla
jalla jalla
jalla
fH


Now, I wana grab the stuff between
filename="test.zip"
and ---some more jalla
and store it in a $jalla2
And the filename, and the jalla before filename  will change so I wanna have a code that takes all the code after filename* (that takes the code on the next line)

Hope u understand what I ment.
 
govinjeAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

thoellriCommented:
$str=<<'fH';
 some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla
jalla jalla
jalla
fH
($filename,$jalla2)=($1,$2) if($str =~ /filename="([^\"]+)".(.*).--some more jalla/ms);
print "Filename is: $filename\nJalla2 is: $jalla2\n";

???
  Tobias
0
govinjeAuthor Commented:
Tnx! IT worked almoast perfect!!
But it didn`t work 100 %.
I tried with this code:
$str=<<'fH';
 some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla
jalla jalla
jalla

some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla
jalla jalla
jalla

fH


And then it printed out to times.
now I just wanna print out the first thing..  I don`t care about the stuff below the first --some more jalla
Is it possible to to this?


Tnx
0
ozoCommented:
/filename="([^"]+)".(.*?).--some more jalla/ms);
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

thoellriCommented:
Ozo's solution is correct. Change it in the script above (well, you actually just need to change the greediness of the .*) and you should be set.

0
govinjeAuthor Commented:
Wow the code is nearly perfect now..
But if the stuff is written like this:

$str=<<'fH';
 some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla THIS STUFF CHANGES
jalla jalla
jalla

fH
It don`t grab the cool stuff, because the line ---some more jalla changes..
I mean, it would be great if I had a code that took from between filename*
next line, until it found ---some more*
So it didn`t care about what it found after the ---some more jalla.
I tried with ---some more jalla*/ms
but it did not work as expected...

0
ozoCommented:
/filename="([^"]+)".(.*?)\n--some more/s
0
govinjeAuthor Commented:
Sorry ozo, am I very bad when I say it`s not perfect yet..
Sorry!
But if the stuff  is this:
$str=<<'fH';
 some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla THIS STUFF CHANGES
jalla jalla
jalla

---some more jalla THIS STUFF CHANGES
fH

Then it prints out the cool stuff and the ---some more jallaa THIS STUFF CHANGES
and jalla jalla jalla.

And I want it to stop at the first ---some more jalla

Tnx for u`re patient`s!

0
ozoCommented:
/filename="([^"]+)".(.*?)\n---some more/s
0
govinjeAuthor Commented:
Eh.. I have noticed that it was missing one - but that was not the problem..
It prints out until the next ---some more jalla
U see?
0
ozoCommented:
$str=<<'fH';
 some jalla
some jalla filename="test.zip"
Here is
the
Cool stuff
that I wanna grab

---some more jalla THIS STUFF CHANGES
jalla jalla
jalla

---some more jalla THIS STUFF CHANGES
fH
($filename,$jalla2)=($1,$2) if( $str=~/filename="([^"]+)".(.*?)\n---some more/s );
print "Filename is: $filename\nJalla2 is: $jalla2\n";

prints:
Filename is: test.zip
Jalla2 is:
Here is
the
Cool stuff
that I wanna grab

0
govinjeAuthor Commented:
Sorry Ozo, the stuff u posted worked with that code..
I tried to change it like this..
And I thought it could work..

$str=<<'fH';
some jalla
some jalla filename=test.zip begin
Here is
the
Cool stuff
that I wanna grab

---some more jalla THIS STUFF CHANGES
jalla jalla
jalla

---some more jalla THIS STUFF CHANGES


fH

 
($filename,$jalla2)=($1,$2) if( $str=~/begin([^"]+).(.*?)\n---some more/s );
print "Filename is: $filename\nJalla2 is: $jalla2\n";

Why does not this work???
I only removed the "" at the filename-thing. I just wanna have a general code that I can use notmather what the text are..
Tnx again!

0
ozoCommented:
($filename,$jalla2)=($1,$2) if( $str=~/filename=(.+?).begin.(.*?)\n---some more/s );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.