title: How to limit insert data into mysql from a file using perl
body: <p>I am relatively new to Perl.I have been trying to insert data to database from a text file using a CGI script.I have written code for it and it's working properly.but when i try to impose a limit on the data that is inserted using LIMIT keyword there is a problem.Please check where i am going wrong and what needs to be amended.Thanks for your advice.</p>
  
  <p>here is the code</p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use strict;
  use CGI ':standard';
  use DBI;
  
  if(param())
  {
  my @params=param();
  my $limit=param('limit')||'';
  
  
  my $dbh =DBI-&gt;connect("DBI:mysql:sample","root","");
  my $var="LOAD DATA LOCAL INFILE 'C:/test.txt' INTO TABLE sample2 FIELDS TERMINATED       BY '\n' WHERE LIMIT 0,$limit";
  my $sth = $dbh-&gt;do($var) or die "prepare failed: " . $dbh-&gt;errstr();
  print $sth ."Records inserted";
  
  $sth-&gt;finish();
  $dbh-&gt;disconnect();
  
  print
  header(),
  start_html(
  -title=&gt;'Welcome',
  -text=&gt;'#520063'
  ),
  #h1("Records have been displayed"),
  end_html();
  
  }
  
  else
  {
  print
  header(),
  start_html('A Simple Form'),
  h1('Please enter the limit '),
  start_form(),
  'Limit: ',
  textfield(-name=&gt;'limit'),
  br(),
  #'Phone Number: ',
  #textfield(-name =&gt; 'number'),
  #br(),
  submit(),
  end_form(),
  end_html();
  } 
  </code></pre>