adam_blackice has asked for the wisdom of the Perl Monks concerning the following question:

hello all i just want to give thanx for all forums that i taught alot from it :) and here are two scripts that are simple but i felt i done something i want to show it to you :)
#!/usr/bin/perl use warnings; use strict; use DBI; #step1 - create connection object my $dsn = 'DBI:mysql:khalid'; my $user = 'adam'; my $password = 'secret'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +" . DBI->errstr; open HAN, "It" || die "No file"; my @newrecords = <HAN>; foreach (@newrecords) { my @col = split; my $first_name = $col[0]; my $last_name = $col[1]; my $job = $col[2]; #step2 - insert/update/delete queries. $conn->do("INSERT INTO khalid(first_name,last_name,job)VALUES('$first_ +name','$last_name','$job')") || die "Error preparing query" . $conn- +>errstr; }
#!/usr/bin/perl use warnings; use strict; use DBI; #step1 - create connection object my $dsn = 'DBI:mysql:firstDB'; my $dsn2 = 'DBI:mysql:fruit'; my $user = 'adam'; my $password = 'secret'; my $conn = DBI->connect($dsn,$user,$password) || die "Error connecting +" . DBI->errstr; my $conn2 = DBI->connect($dsn2,$user,$password) || die "Error connecti +ng" . DBI->errstr; #step2 - define query my $query = $conn->prepare('SELECT * FROM guests') || die "Error prep +aring query" . $conn->errstr; my $query2 = $conn2->prepare('SELECT * FROM fruits') || die "Error pr +eparing query" . $conn->errstr; #step3 - execute query $query->execute || die "Error executing query". $query->errstr; $query2->execute || die "Error executing query". $query2->errstr; #step4 - return results my @results; my @results2; while (@results = $query->fetchrow_array()) { my $autoID = $results[0]; my $first_name = $results[1]; my $last_name = $results[2]; my $age = $results[3]; my $comments = $results[4]; my $date_entered = $results[5]; print "autoID is : $autoID \n first_name is : $first_name \n last_name + is : $last_name \n comments are : $comments \n date_entered = $date_ +entered \n "; } while (@results2 = $query2->fetchrow_array()) { my $name = $results2[0]; my $colour = $results2[1]; print "the name of fruit is : $name \n the colour of the fruit : $colo +ur\n" } if ($conn->rows == 0) { print "No Records!"; } if ($conn2->rows == 0) { print "No Records!"; }
so i want know to figure out my way i made a post before about the webmin and how to make a subset of it and i want agood and simple book that i can start with to help me in that issue ..... THANKS FOR ALL AGAIN :)

Replies are listed 'Best First'.
Re: thanx for this great forums :)
by strat (Canon) on Apr 02, 2007 at 08:37 UTC
    open HAN, "It" || die "No file";

    this means:

    open HAN, ( "It" || die "No file" );

    so this will never fail as long as the string "IT" is true. If you really want to use ||, use parantheses around:

    open( HAN, "It" ) || die "No file";

    or use "or" instead (which is IMHO better readable:

    open( HAN, "It" ) or die "No file";

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      thanx for your help ...., but what about the cgi what recommended to start with that will help me in the subset of the webmin issue ?......
        I don't see that you've actually asked a question about Webmin...Perhaps ask again with some specific question? (I work with Webmin code every day. I can probably help.)