In this case, you treat /proc/pci per line. Perhaps you would like to read the file by records, like:
# example of a full record
Bus 0, device 0, function 0:
Host bridge: Intel Unknown device (rev 3).
Vendor id=8086. Device id=7190.
Medium devsel. Master Capable. Latency=64.
Prefetchable 32 bit memory at 0xe6000000 [0xe6000008].
If so, you only need to make a slight modification to MZSanford code:
use strict;
my @devices;
undef $/;
foreach (split /\n\s\s\b/, <DATA>) {
# you now have the whole record in $_
# do with it as you please
}
<snip>
- Good luck
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|