Dereferencing (?) in Perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Dereferencing (?) in Perl
# 1  
Old 01-06-2010
Dereferencing (?) in Perl

Hi,

i want to print the mail exchange servers for a domain using the code below, the problem is that i just get the memory locations (?) of the elements in the output, instead of the mx servers.

I really tried to find a solution, but i guess that i just don't get it (objects, OOP etc).. Smilie

Code:
#!/usr/bin/perl -w

use strict;
use Net::DNS;

my $resolver    = Net::DNS::Resolver->new;
my @mx          = mx($resolver, "domain.com");

foreach my $rr (@mx){
        print $rr,"\n";
};

Output:

Code:
Net::DNS::RR::MX=HASH(0x3d4216c)
Net::DNS::RR::MX=HASH(0x3d426bc)

# 2  
Old 01-06-2010
your "rr" is an object reference, so you need to know the elements of that object.

something like this:

Code:
print "$rr->preference\n";
print "$rr->exchange\n";

The reference page for this object is here:

Code:
http://search.cpan.org/~olaf/Net-DNS-0.66/lib/Net/DNS/RR/MX.pm]Net::DNS::RR::MX - search.cpan.org

# 3  
Old 01-06-2010
MySQL

Quote:
Originally Posted by quirkasaurus
your "rr" is an object reference, so you need to know the elements of that object.

something like this:

Code:
print "$rr->preference\n";
print "$rr->exchange\n";

The reference page for this object is here:

Code:
http://search.cpan.org/~olaf/Net-DNS-0.66/lib/Net/DNS/RR/MX.pm]Net::DNS::RR::MX - search.cpan.org

Thanks, so simple.. back to the books! Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dereferencing variable inside egrep call

Hi guys I am trying to dereference a variable inside 'egrep -v ' command and getting a 'egrep: syntax error' : $ echo $exclude_list ts584d hf584db for i in `echo $exclude_list`; do egrep -v ${i} my_file done egrep: syntax error egrep: syntax error The syntax of the loop is correct.... (1 Reply)
Discussion started by: aoussenko
1 Replies

2. Shell Programming and Scripting

Dereferencing variable in loop

Hi , I have below code While running above code i am receiving error : bad substitution I need to use the variable s RC_1, RC_2 and their value outside of the loop. Can anybody help me on that (5 Replies)
Discussion started by: sonu_pal
5 Replies

3. Shell Programming and Scripting

perl: dereferencing a hash of hashes

Hi there, I am trying to dereference my hash of hashes but post dereferencing, it seems to lose its structure I am using Data::dumper to help me anaylise. This is the code im using to build the HoH, (data comes from a file). I have also performed a Dumper on the data structure before and after... (1 Reply)
Discussion started by: rethink
1 Replies

4. Programming

Compilation Error: dereferencing pointer to incomplete type

I am getting a dereferencing pointer to incomplete type error when i compile the following code on lines highlighted in red. Can anyone help me in identifying what is wrong in the code? #include<stdio.h> #include<stdlib.h> typedef struct{ int info; struct node* link ; } node; void... (3 Replies)
Discussion started by: sreeharshasn
3 Replies

5. Programming

Dereferencing pointer to a shared memory struct

I have what should be a relatively simple program (fadec.c) that maps a struct from an included header file (fadec.h) to a shared memory region, but I’m struggling accessing members in the struct from the pointer returned by shmat. Ultimately, I want to access members in the shared memory structure... (2 Replies)
Discussion started by: arette
2 Replies

6. Shell Programming and Scripting

Dereferencing in PERL

Hi, This should be a simple one. All I am doing is adding an email address to my email. Example abc@xyz.com I understand that the @ means arrays in PERL. So, I coded the backtick (`) to dereference it. But now I get abc`@`xyz.com Your help is appreciated. Thanks Nurani (2 Replies)
Discussion started by: nurani
2 Replies

7. Programming

Dereferencing pointer to incomplete type

// Hello all, I am having this error "Dereferencing pointer to incomplete type " on these 2 lines: xpoint = my_point->x; ypoint = my_point->y; I am having no clue y this is happening. Any help would be greately appreciated!!!! #include<stdio.h> #include<string.h>... (2 Replies)
Discussion started by: mind@work
2 Replies

8. UNIX for Dummies Questions & Answers

Build Error: error: dereferencing pointer to incomplete type

I'm getting the following Error: prepare_pcap.c: In function `prepare_pkts': prepare_pcap.c:127: error: dereferencing pointer to incomplete type prepare_pcap.c:138: error: dereferencing pointer to incomplete type ==================================== This is the part of the relevant... (8 Replies)
Discussion started by: katwala
8 Replies

9. Shell Programming and Scripting

variables usage without dereferencing

Hi All, I came across a bit of code that seems to work, even though I didn't expect it to (now that's wierd!) #!/bin/sh set -x nn=15 if then echo "is true" fi The above code ends up comparing the string "nn" to number 15, but still evaluates to true. Here's the output when i run it... (1 Reply)
Discussion started by: ag79
1 Replies

10. Programming

Accesing structure member:Error:dereferencing pointer to incomplete type

$ gcc -Wall -Werror struct.c struct.c: In function `main': struct.c:18: error: dereferencing pointer to incomplete type $ cat struct.c #include <stdio.h> #include <stdlib.h> #include <string.h> /*Declaration of structure*/ struct human { char *first; char gender; int age; } man,... (3 Replies)
Discussion started by: amit4g
3 Replies
Login or Register to Ask a Question