Hi folks

I desperately need your help. I was looking all evening for a solution to my problem. I'm using Perl 5.10.1 on a 64Bit Ubuntu.

I wanted to play around with Net::Pcap, so I have installed it the command apt-get install libnet-pcap-perl

For my test, I wanted to use an example shown on the CPAN page of Net::Pcap

#!/usr/bin/perl -w use Net::Pcap; my $err = ''; my $dev = pcap_lookupdev(\$err); # find a device # open the device for live listening my $pcap = pcap_open_live($dev, 1024, 1, 0, \$err); # loop over next 10 packets pcap_loop($pcap, 10, \&process_packet, "just for the demo"); # close the device pcap_close($pcap); sub process_packet { my($user_data, $header, $packet) = @_; # do something ... }

If I try to run that script, I get this Answer: "Undefined subroutine &main::pcap_lib_version called at ./test.pl line 7"

However, if I expand the pcap-commands to e.g my $dev = Net::Pcap::pcap_lookupdev(\$err); I don't get any error. It just does nothing because the script is not finished yet, but that's not the point.

Has anyone an Idea what my problem is?

SOLUTION: The funtions need to be exported by request  use Net::Pcap qw(:funtions); Thank you Corion!


In reply to Can't use moduels by 'use' directive by PN33D0

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.