Hi, I'm in the process of re-vamping my site, and am having a wee bit of trouble. I use a template on my site, and simply grab the data to display out of a .inc file, using PHP. I want to transfer this all over to a perl site, kinda like perlmonks. I really like the idea, plus I'm much, MUCH, better at perl, than PHP. My folders are layed out like so: kylesdesktop.com ./cgi-bin/ ./public_html/ ./content/ ./other_stuff move.pl is in the cgi-bin, and all the *.inc's are in the content folder. My problem is that my script goes into an infinite loop, or just hangs. This messed me up, becuase it hangs with the MySQL connection open, and I can't connect more than X times to my server. This means my website goes down when it runs. Here's the code to transfer script. Sorry for obvius mistakes, I'm tired and grumpy. Wrote it late last night, and haven't slept since, thanx to a fire call (I'm a firefighter).
#!/usr/bin/perl #INCLUDE LIBRARIES AND MODULES AS NEEDED #use strict; use CGI::Carp qw(fatalsToBrowser); use CGI; use DBI; #assign values $DBuser = "not"; $DBpass = "telling"; $DBtable= "the"; $DBhost = "world"; #connect to Database $dbh = DBI->connect("DBI:mysql:$DBtable:$DBhost", "$DBuser", "$DBpass" +, { PrintError => 0, RaiseError => 1 } ) || die "Error connecting: $D +BI::errstr!"; print "Content-type: text/html\n\n"; #grab files into @files opendir(DIR,"/home/kyleyankan/public_html/content/") || die "Can' open + dir: $!"; @files = readdir(DIR); close(DIR); #@files = glob("../public_html/content/*.inc"); #run loop, to transfer each file while (@files) { #print filename print $_ . "\n"; #grab file contents open(FILE,"/home/kyleyankan/public_html/content/$_"); @content = <FILE>; close(FILE); while (@content) { $stuff .= $_; } #remove .inc from file $_ =~ s/.inc//; #dump into DB $sth = $dbh->prepare(qq~ INSERT INTO quadrants (title, author, content) VALUES ("$_","KyleYankan","$stuff")~) || die "Can't insert values: $!"; $sth->execute || die "Can't insert values: $!"; } #leave that mysql alone $dbh->disconnect();

In reply to Script being caught up, somewhere. Causing infinite loop. by KyleYankan

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.