Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Newbie question

Reply
Thread Tools

Newbie question

 
 
MM
Guest
Posts: n/a
 
      02-14-2008
Hi all,

I am trying to write a perl script to do some simple modifications to a text
file. Amongst other things it has to delete a few lines. Here is a relevant
part of my script:

LINE: while ($line = <OF>) {
if ((/END_ADDRESS_SPACE/) && ($count2 < 3)) {
$count2 += 1;
$line = <OF>;
do {
$line = <OF>;
} until ($line == /ADDRESS_SPACE/);
next LINE;
}
print NF $line;
}

The lines that I am trying to skip contain forward slashes and that seems to
confuse the match in the until statement...

END_ADDRESS_SPACE;

///////////////////////////////////////////////////////////////////////////////
//
// Processor 'ppc405_0' address space
'plb_bram_if_cntlr_1_bram_combined' 0xFFFE8000:0xFFFEFFFF (32 KB).
//
///////////////////////////////////////////////////////////////////////////////

ADDRESS_SPACE plb_bram_if_cntlr_1_bram_combined RAMB16
[0xFFFE8000:0xFFFEFFFF]



Thanks,
/Mikhail


 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      02-14-2008
MM wrote:
> I am trying to write a perl script to do some simple modifications to a text
> file. Amongst other things it has to delete a few lines. Here is a relevant
> part of my script:
>
> LINE: while ($line = <OF>) {
> if ((/END_ADDRESS_SPACE/) && ($count2 < 3)) {


if (($line =~ /END_ADDRESS_SPACE/) && ($count2 < 3)) {
---------^^^^^^^^

> $count2 += 1;
> $line = <OF>;
> do {
> $line = <OF>;
> } until ($line == /ADDRESS_SPACE/);


} until ($line =~ /ADDRESS_SPACE/);
--------------------^

> next LINE;
> }
> print NF $line;
> }
>
> The lines that I am trying to skip contain forward slashes and that seems to
> confuse the match in the until statement...


What makes you think that would have anything to do with it?

You should enable strictures and warnings, which will help you detect
many types of errors.

use strict;
use warnings;

I marked a couple of obvious things above.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
 
Reply With Quote
 
 
 
 
MM
Guest
Posts: n/a
 
      02-14-2008
"Gunnar Hjalmarsson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> I marked a couple of obvious things above.


Thanks a lot. It works as expected now.

/Mikhail


 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      02-14-2008
"MM" <(E-Mail Removed)> wrote:
> } until ($line == /ADDRESS_SPACE/);


Are you absolutely certain that you want to compare the numerical(!) value
of $line with the logical return value of the pattern match against $_ ?
That seems wrong to me.

jue
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VONAGE Newbie w/newbie question New_kid@nowhere.new VOIP 0 08-11-2007 01:40 PM
another newbie question from another newbie.... Lee UK VOIP 4 05-17-2005 04:10 PM
newbie: cisco vlan newbie question No Spam Cisco 3 06-07-2004 10:02 AM
dumb newbie question (or newbie dumb question) Jerry C. Perl Misc 8 11-23-2003 04:11 AM
Newbie! I'm a newbie! What's wrong with this program? Id0x Python 4 07-20-2003 11:40 PM



Advertisments