I have a very basic question on deleting/printing from/to a file.
My input file is something like this:
A1:This is the first line
A2:Welcome to the first line
A3:haaaaaaaaaaaaaaaaaaaaa
A1:This is the first line
A2:Welcome to the second line
A3:heeeeeeeeeeeeeeeeeeeee
I want to first...
I changed my code a little bit. I am moving selective contents of the array into files (A1 and A2). I now want to process these files. But when i run the code, the control never goes to the while loop although i am able to see these files created. I am unable to understand this behaviour. Please...
I did not get you. I am trying this code in the elsif, but when i try to print the contents of array2, i see blank lines. Am i missing something?
My Code:
elsif($array[$num] =~ /Search string 2/)
{
for my $tnum(0)
{
print "$array[$num+$tnum]\n";
push...
I have modified your code to print based on two search parameters. To continue, i want to move 4 lines of code which are retrieved in the first part of the if statement to array1 and 1 line of code retrieved in the second part of the elsif statement to array2.
Code:
open(f1,"input.log")...
It works. Now i want to do additional processing on these 6 lines of code extracted. So i want to move these 6 lines again to a seperate array and somehow keep an index for these 6 lines so that when iam done with the first search, the pointer should again move to the first line of the next 6 lines.
I would like to copy an entire file in an array and search for a keyword "Search". When this keyword is found, i then want to copy next 6 lines from this keyword. This task needs to be repeated for the entire file. Can somebody guide me how to go about this?
Thanks.
My task involves me to check for a particular string in a file and capture some part in a variable. I then have to use this variable value and search for the remainder part of the file. If it is found, i have to do some processing.
It is much like any sorting example. So, i guess i cannot...
I have foll code:
while (<G1>) {
if ($_ =~ /Some/)
{
{
do something;
} -----> End first loop
if ($_ =~ /More/)
{
do something;
}
} -----> End second loop
} ----> End of while...
The query on the other forum is similar to mine. But it seems to be pure coincidental to me. To answer again, this is not part of any school work, i am a working professional who is bent to learn perl to make life easier. I have nothing more to say. If you beleive me, please help me with my query.
I have not posted my query on any other forum. I do not know if some-one else has a similar question.
As for me, i want to learn Perl and use it in my day-to-day work. It is not part of any school/class work.
Thanks.
Thanks for the reply. I got it.
I have one more doubt. i am trying to search for a string in a file which is defined as
`define ABCD `AB.BC.DA
I want to grep for the string ABCD in the file and if this is found, then the script should print AB+BC+DA
Can you please help me on this?
i have a very basic question. Since i am new to Perl, i am unable to resolve this myself. Any help will be greatly appreciated.
I am browsing through a file and searching for a string. If the string matches, i want to pick the next line. Somehow i am not able to move my file handler to the next...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.