was [TriLUG] perl programming question. now more useless info/commentary
John F Davis
johndavi at us.ibm.com
Thu Mar 21 11:02:40 EST 2002
Hello
Err, I appreciate the help, but:
the parens were a mistake. I didn't copy this code I typed it from memory.
That's why
the parens slipped into the picture. Sorry to throw you off. For what its
worth,
I did get it to work via my other post. I couldn't however get it to work
using just one line. ie.,
$partHash{$drive$i}. If this syntax does indeed work for you, please let
me know.
I would like to know how/why it works for you and not for me.
Thanks for the my $i for loop style - that is cool and concise. Also might
help
with the job protection goal. heh
Speaking of bad memory. The other day I asked about lilo on RedHat not
working
for my buddy. It turns out I had used the wrong syntax altogether.
Instead of :
other=/dev/sda
label=nt
disk=/dev/sda
bios=0x80
disk=/dev/hda
bios=0x81
it should have been:
other=/dev/sda
map-drive=0x80
to=0x81
map-drive=0x81
to=0x80
I did a man lilo.conf and did a search on 0x80. I didn't expect to see
0x80 come up twice.
The wrong syntax shows up first. So redhat 7.2 would have worked. It was
just operator
error.
With that said, I've heard there is a tool for examinging linux filesystems
on Windows.
If I had such a tool, I could have examined my /etc/lilo.conf file from my
windows boot.
I was lazy and didn't want to reboot into linux to see the correct
lilo.conf settings. if you
know of such a tool and its free please let me know.
And just one more perl question:
using a bash script, I can do something like this:
sfdisk /dev/hde << EOF
0,174,6,-
174,174,83, *
348,173,83, -
EOF
That way, I can partition my microdrive in a script without creating a
temporary file
and doing:
sfdisk /dev/hde < drivelayout.txt.
Now, I am writing a similar script in perl and I need to do this same
thing.
I have the table read to build. That;s where the $drive$i question came
up.
Is there some way in perl to do a similar thing as the first example? maybe
`sfdisk /dev/hde << EOF ...`?
(If people hung out in #trilug, I could talk to you wonderful people in
real time.)
JD
Andrew Perrin <andrew_perrin at unc.edu>@trilug.org on 03/21/2002 10:01:51 AM
Please respond to trilug at trilug.org
Sent by: trilug-admin at trilug.org
To: trilug at trilug.org
cc:
Subject: Re: [TriLUG] perl programming question
Hey, cool, a question I can answer :)
On Thu, 21 Mar 2002, John F Davis wrote:
> [snip]
> for ($i=0, $i < $numOfPartitions; $i++) {
> #cylinder info is manipulated and not needed for this example
> print "$begCyl, $endCyl, $partHash("$drive$i"), $boot
\n";
^^ ^^
Two problems here:
1.) the parens should be braces; and
2.) you're doubling up double-quotes (one set in the print command, the
other set around the $drive$i). You don't need them in the $drive$i
section; hash lookups interpolate automatically.
print "$begCyl, $endCyl, $partHash{$drive$i}, $boot \n";
By the way, the for() loop is ugly although functional; this is prettier:
for my $i (0..$numOfPartitions) {
Best,
Andy
----------------------------------------------------------------------
Andrew J Perrin - andrew_perrin at unc.edu - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
269 Hamilton Hall, CB#3210, Chapel Hill, NC 27599-3210 USA
_______________________________________________
TriLUG mailing list
http://www.trilug.org/mailman/listinfo/trilug
TriLUG Organizational FAQ:
http://www.trilug.org/~lovelace/faq/TriLUG-faq.html
More information about the TriLUG
mailing list