in reply to problem with multi-line

I have been trying to scan a file and perform an 'if' using a multi-line m option, but unfortunately i am unable to get the result I want.

Here is the code I have written

#!/usr/local/bin/perl -w # analyse_map.perl # Open map files (map_merc and rom.dld) open(MAP, ") { if( ($titi, $toto) = /^\.(\w+).*$\t+\.\w+\W+(\w+).*$/m) { print($titi, $toto, "\n"); } } close(MAP);
What I want to do is find a line that starts with a '.' and put the alphanumeric in the scalar $titi, than scan the next line to match the alphanumeric and put it in scalar $toto. But it is generating an error and cannot use it. This is just a rial code I wrote for the actual program, but as this part isn't functioning right I cannot add it to the other code. Thanking you for your help.

S. Navalkar

--
Casey

Replies are listed 'Best First'.
RE: Re: REPOST problem with multi-line
by cwest (Friar) on Aug 25, 2000 at 16:48 UTC
    /^\.(\w+).*$\t+\.\w+\W+(\w+).*$/m
    So you're looking for something like this, I think:
    .somewords any amount of garbage till a suposed end of line [some number of tabs].nomatchwords matchedwords garbage to eol
    I'm going on this assumption since I have NO real example of your test data.
    #!/usr/local/bin/perl -w use strict; $|++; $/="\n."; while ( <DATA> ) { print join ' ', /^\.?(\w+).+\n\t+\.\w+\W+(\w+)/; print "\n"; } __DATA__ .this is a line .and this is another line .again, a line. .Yet another line
    I hope this helps.
    --
    Casey
    
RE: Re: REPOST problem with multi-line
by Jouke (Curate) on Aug 25, 2000 at 16:51 UTC
    Can you give a piece of example-contents of the file you want to scan and the result you want? I don't completely understand what you're trying to do... Jouke Visser, Perl 'Adept'