Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

poj's scratchpad

by poj (Priest)
on Jun 12, 2013 at 17:16 UTC ( #1038520=scratchpad: print w/ replies, xml ) Need Help??

Here's a demo script to show the workings, but you probably just need the filter_addr subroutine in your script. I assume a space is to be treated as a valid character.

#!perl use strict; while (<DATA>){ chomp; my ($name,@addr) = split ';'; print "Name ==> '$name'\n"; for my $n (2..4){ my $addr = $addr[$n-2]; # this is a substitution =~ s/// so you can see # the result of the match inside <> my $res = ($addr =~ s/([^a-zA-Z0-9 ])/<$1>/) ? 'Reject:Non-Alpha' : ($addr =~ s/($name)/<$1>/) ? 'Reject:Match' : 'Accept'; # use this simpler match =~ m// in your script # my $res = ($addr[$n-2] =~ m/[^a-zA-Z0-9 ]/) # ? 'Reject:Non-Alpha' # : ( $addr[$n-2] =~ m/$name/ ) # ? 'Reject:Match' : 'Accept'; print "Col $n ==> '$addr' --> $res\n"; } # you probably just want to add sub-routine my @f = filter_addr($name,@addr); print "-------------------\n"; print join ",",$name,@f; print "\n-------------------\n\n"; } sub filter_addr { my ($name,@addr) = @_; # reject any with non-alpha my @f = grep !/[^a-zA-Z0-9 ]/,@addr; # now reject any that match name @f = grep !/$name/,@f; return @f; } __DATA__ abc;aaaa_bbbb;cccc;ddd abc;abcd aaaa;bbbb;cccc& abc;abc aaaa;aaa aabc bbbb;$cccc abc;abcaaaa;aaa abc bbbb;aabcdef cc,c
======================================================

Unfortunately you can't use a placeholder for table names or partition names. I only have OracleXe so can't test it but I have proved it doesn't work for MySQL. The best I can suggest is this

my $SQL_part = " SELECT CASE WHEN BUSINESS_DAY = 1 THEN CASE WHEN TO_CHAR(DAY,'D') = '2' THEN TO_CHAR(DAY-3,'yyyymmdd') WHEN TO_CHAR(DAY,'D') IN ('3','4','5','6') THEN TO_CHAR(DAY-1,'yyyymmdd') END WHEN BUSINESS_DAY = 0 THEN TO_CHAR(DAY+1,'yyyymmdd') END FROM (SELECT DAY,BUSINESS_DAY FROM CALENDAR_DAY WHERE DAY = TRUNC(SYSDATE-1))"; my ($part) = $dbh->selectrow_array($SQL_part); my $SQL_data = " SELECT COL1, COL2, COL3 FROM TABLE_NAME PARTITION (P_$part) WHERE DATE_CLOSED IS NULL AND ROWNUM < 11"; print "SQL = $SQL_data\n";

=======================================================

Add these lines to your script

#!perl use Cwd qw( realpath ); use File::Basename qw( dirname ); # Look for modules in the same dir as the script. use lib dirname(realpath($0));
=======================================================

You might be able to use section method which wraps the lines for you. It won't wrap onto another page though. Here is a demo

#!perl use strict; use PDF::API2; my $pdf = new PDF::API2(-file => "align.pdf"); $pdf->mediabox(842, 595); #A4 Landscape my $page = $pdf->page(); my $font = $pdf->corefont('helvetica'); my $content = $page->text(); $content->font($font,12); $content->translate(300,300); # set position $content->lead(15); # line spacing 12pt font + 3pt space my $reason = "Reason1|Reason2|Reason3|Reason4"; $reason =~ s{\|}{\n}g; # replace | with newline $content->section($reason,200,500); # text,width,y $pdf->saveas();
======================================================

Some modules include C code which must be compiled specifically for OS and version of perl. I suspect that DBI/DBD and PDF ones are like that. If you have internet connection use cpan command else download tar.gz file, expand and install manually.

What do you get from perl -v and perl -V commands ?

See A Guide to Installing Modules but it can get tricky especially if you have multiple versions of perl on the same machine

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2015-02-01 23:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    On my keyboard, Caps lock is:








    Results (14 votes), past polls