I am trying to transfer the perl program running in linux to mac lion os, I had a problem in installing DBD::Mysql in mac os but on googling i found many of them with the same issue but one of the solution flueked the issue and it starts showing output. Now when i run the below code.
1 #!/usr/bin/perl 2 use strict; 3 use Data::Dumper; 4 use CGI; 5 use DBI; 6 use Template; 7 8 $| =1; 9 #print "Content-type: text/html\n\n"; 10 print "Content-type:text/html\r\n\r\n"; 11 print "html"; 12 13 my $driver = "mysql"; 14 my $database = "RON"; 15 my $dsn = "DBI:$driver:database=$database"; 16 my $userid = "root"; 17 my $password = "test"; 18 19 20 21 22 my $dbh = DBI->connect($dsn, $userid, $password ) or die $DBI::err +str; 23 my $sth=$dbh->prepare("SELECT * FROM INVOICE"); 24 $sth->execute(); 25 26 my $data = $sth->fetchall_hashref('Invoice_Number'); 27 $sth->finish(); 28 $dbh->disconnect(); 29 30 my %trend = %$data; 31 32 print Dumper(%trend); 33 34 foreach (keys %trend){ 35 36 my $invoice_nu = $trend{'Invoice_Number'}; 37 print "hello<br>\n"; 38 39 40 } 41 foreach (1..10) { 42 print "hello line $_;<br>"; 43 } 44
the above code display the putput properly in terminal but in browser it just fails to print after the DBI->connect. No lines are executed after that. I checked the err log and below is the error code mentioned. anyone please suggest me a solution for the problem.
install_driver(mysql) failed: Can't load '/Library/Perl/5.12/darwin-th +read-multi-2level/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: + dlopen(/Library/Perl/5.12/darwin-thread-multi-2level/auto/DBD/mysql/ +mysql.bundle, 1): Library not loaded: libmysqlclient.18.dylib Referenced from: /Library/Perl/5.12/darwin-thread-multi-2level/auto/ +DBD/mysql/mysql.bundle Reason: image not found at /System/Library/Perl/5.12/darwin-thread-m +ulti-2level/DynaLoader.pm line 204. at (eval 12) line 3 Compilation failed in require at (eval 12) line 3. Perhaps a required shared library or dll isn't installed where expecte +d at /Library/WebServer/CGI-Executables/hello.pl line 22

In reply to DBD::Mysql not working properly in mac OS X by romy_mathew

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.