peppiv has asked for the wisdom of the Perl Monks concerning the following question:
This works in removing parenthesis from $results[15], but how can I catch them in the entire returned array? $results[1..80]? Also, how can I leave the parenthesis if they are placed correctly "(Spain)" not "(Spain"? This problem stems from the fact that some of this data came from user input and it wasn't controlled on the front end to filter them out.#code is stripped to bare bones in effort to save time/space use strict; use DBI; use PDF::Create; my $id = param("id"); my $pdf = new PDF::Create ('filename' => '../html/logs/mypdf.pdf', 'PageMode' => 'UseNone', 'Title' => 'Anything', ); my $root = $pdf->new_page('MediaBox' => [ 0, 0, 612, 792 ]); # Add a page which inherits its attributes from $root my $page = $root->new_page; # Prepare 2 fonts my $f1 = $pdf->font('Subtype' => 'Type1', 'Encoding' => 'WinAnsiEncoding', 'BaseFont' => 'Helvetica'); my $dbh = DBI->connect('DBI:mysql:database=hr_db;host=69.169.169.9','u +srname','password'); my $sth = $dbh->prepare('SELECT * FROM applicant WHERE id = ?'); $sth->execute($id) or die $sth->errstr; while (my @results = $sth->fetchrow_array()) { $results[15] =~ tr/\(/ /g; $results[15] =~ tr/\)/ /g; $page->stringl($f1, 10, 28, 675, "Specific Position(s)"); $page->stringl($f1, 10, 28, 664, "Applied For:"); $page->stringl($f1, 10, 93, 664, "$results[15]"); $page->line(90, 662, 310, 662); $page->stringl($f1, 10, 320, 664, "Date Applied:"); $page->stringl($f1, 10, 393, 664, "$results[20]"); $page->line(390, 662, 587, 662); } $sth->finish(); $dbh->disconnect; # Add the missing PDF objects and a the footer then close the file $pdf->close;
|
---|