Page 14 of the new Pickaxe book says (amongst other things):
"Note that we didn't have to declare the variable 'result'; it sprang into
existence when we assigned to it."
This was my understanding, but I keep seeing this sort of thing:
../duprop:136:in `find_pcap_offset': undefined local variable or method
`offset' for #<Pcap_entry:0x40280794> (NameError)
when I run this:
offset=line.split()[1].to_i
Its easily fixed: I assign 0 to offset earlier in the method:
def find_pcap_offset # Find the offset to the pcap entry for printer_name
found=false
offset=0 # <- This fixes things.
begin
pcap_file=File.open(@pcap_fname)
rescue IOError
print("can't open pcap file #{@pcap_fname}\n")
exit(BAD_PCAP_FILE)
end
# OK, now find the pcap entry
pcap_file.each_line() do |line|
if line.match(@printer_name)
print("Found printer #{@printer_name} in [#{line}]\n") if $debug
found=true
offset=line.split()[1].to_i
break
Now I hate to do this - partly at least 'cause its clear evidence I don't
understand something!
Any help appreciated.
Graham Nicholls
···
--
With Linux the answer's always "Yes".
Now, whats the question?
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---