| | |
Trouble Expanding a bus in PERL
![]() |
•
•
Join Date: Sep 2005
Posts: 11
Reputation:
Solved Threads: 0
Hi all,
I am trying to list out a bus as individual names.
For instance - When I come across a section in a file that lists a bus like this:
<busname>[0:2]
I would like to print out this:
<busname>[0]
<busname>[1]
<busname>[2]
Here is what I have - It goes into an endless loop and I can't seem to solve it.
#! /usr/intel/bin/perl -w
my $block = $ARGV[0];
my $RTL_pin = "$block.test.v";
open (RTL, "$RTL_pin") or die "could not open file $RTL_pin\n";
system ("touch newtest2");
open( NEWFILE2, "> newtest2" ) or die "Can't open file: newtest2 $!";
system (" grep -E '[input]|[ouput]|[inout]' $RTL_pin > $RTL_pin.hold");
system (" cp -p $RTL_pin.hold $RTL_pin");
while (<RTL>)
{
chomp;
s/;/ /g;
if ($_ =~ /(.*\s+)\[(\d+)
\d+)\]/)
{
$bn = $1; #busname
$h = $2; #high number
$l = $3; #low number
$i = 0;
# print NEWFILE2 "\n$l\n$h\n$bn\n";
for ($i = $l; $h; $i++)
{
print "$bn[$i]";
}
}
}
Thanks for any help.
I am trying to list out a bus as individual names.
For instance - When I come across a section in a file that lists a bus like this:
<busname>[0:2]
I would like to print out this:
<busname>[0]
<busname>[1]
<busname>[2]
Here is what I have - It goes into an endless loop and I can't seem to solve it.
#! /usr/intel/bin/perl -w
my $block = $ARGV[0];
my $RTL_pin = "$block.test.v";
open (RTL, "$RTL_pin") or die "could not open file $RTL_pin\n";
system ("touch newtest2");
open( NEWFILE2, "> newtest2" ) or die "Can't open file: newtest2 $!";
system (" grep -E '[input]|[ouput]|[inout]' $RTL_pin > $RTL_pin.hold");
system (" cp -p $RTL_pin.hold $RTL_pin");
while (<RTL>)
{
chomp;
s/;/ /g;
if ($_ =~ /(.*\s+)\[(\d+)
\d+)\]/){
$bn = $1; #busname
$h = $2; #high number
$l = $3; #low number
$i = 0;
# print NEWFILE2 "\n$l\n$h\n$bn\n";
for ($i = $l; $h; $i++)
{
print "$bn[$i]";
}
}
}
Thanks for any help.
Please put your code in [CODE] and [CODE] tags in the future, on any forum.
This loop will terminate when the middle expression evaluates to a false value. You seem to want $i <= $h, not $h. ($h will just return something like 2 or 3 (whatever its value is), every time, and those are true values, causing the loop to run infinitely.)
This loop will terminate when the middle expression evaluates to a false value. You seem to want $i <= $h, not $h. ($h will just return something like 2 or 3 (whatever its value is), every time, and those are true values, causing the loop to run infinitely.)
All my posts may be redistributed under the GNU Free Documentation License.
![]() |
Similar Threads
- Humble Scottish Gamer (Community Introductions)
- expanding site content with css (HTML and CSS)
- Help with Perl script to verify IP addresses (Perl)
- Expanding iFrame Help (JavaScript / DHTML / AJAX)
- A simple perl script (Perl)
- Having trouble with usb driver (Windows 95 / 98 / Me)
- OptiPerl - Perl IDE (Perl)
Other Threads in the Perl Forum
- Previous Thread: A simple perl script
- Next Thread: Fields in HTML Form
| Thread Tools | Search this Thread |






