in reply to Passing Array to Function for search and Replace

First, you want eq, not ==. eq is used for string comparisons, == is used for numeric comparisons.

Second, strictly speaking, you aren't removing characters for JPY and GBP. You're replacing the character with a space. Do you intend to do that, or do you intend to remove it?

Third, you probably want to put the characters in brackets ([]):

s/[â¬]//g;
I'm not sure if you intend the comma to be a character to remove. Note that there is a huge difference here - what you had only removed the characters when they appeared exactly as-is, in order, one after another. This one will remove all occurences of any character in brackets.

Next, move the close(PDF); to after the print <PDF>. You can't read from a closed filehandle.

Maybe what you really want is:

open my $pdf, "<", "LeasevsBuy.pdf" or handleError($!); # you probab +ly want to print out an error page instead of just dying. binmode $pdf; $output = do { local $/; <$pdf> }; close $pdf; print "Content-Type: application/pdf\n"; print "Content-Length: " .length($output) . "\n\n"; print $output;
Just guessing here.

Hope that helps.

Replies are listed 'Best First'.
Re^2: Passing Array to Function for search and Replace
by ikkon (Monk) on Jan 08, 2007 at 19:01 UTC
    thanks for the explination it makes sense, I am sure I am missing something important here, but even when using your updated version for the second part all i get is encrypted gumble, instead of the file opening in the browser, what am I doing wrong?