http://qs321.pair.com?node_id=939270


in reply to losing html in print calling function.

Here are a few more pointers:

To explore your original problem, I refactored your code into the style that I would write (except that I would go further to use some template module). I include it below, in case anyone finds it useful.

#!/usr/bin/env perl use strict; use warnings; use Carp; my $prestring = '???'; $prestring = '.'; # Overridden for PerlMonks testing my $wanted_string = 'apple'; # really take from param 'sitem'; my $index_dir = $prestring; my @book_indexes_titles = ( [ '1800.txt' , '1800: Mechanical Movements, Powers and Devices, +1911' ], [ '507.txt' , '507: Five Hundred and Seven Mechanical Movements +. 1893' ], [ '970.txt' , '970: Mechanical Appliances, Mechanical Movements + and Novelties of Construction. 1904' ], [ 'ACAM.txt' , 'ACAM: Appletons Cyclopedia of Applied Mechanics, + 1880 ' ], [ '???.txt' , 'Audels Carpenters and Builders Guide I' ], [ '???.txt' , 'Audels Carpenters and Builders Guide II' ], [ '???.txt' , 'Audels Carpenters and Builders Guide III' ], [ '???.txt' , 'Audels Carpenters and Builders Guide IV' ], [ 'AMOM.txt' , 'AMOM: A Manual of Mending and Repairing. 1907' ] +, [ '???.txt' , 'Farm Blacksmithing (1901)' ], [ 'FCOA.txt' , 'FCOA: Farmers Cyclopedia of Agriculture. 1911' ] +, [ 'FCOLS.txt' , 'FCOLS: Farmers Cyclopedia of Live Stock. 1908' ] +, [ 'FDAD.txt' , 'FDAD: Furniture Design and Draughting. 1900' ], [ '???.txt' , 'ICS Reference 14' ], [ '???.txt' , 'Pottery for /artists, Craftsmen, and Teachers (1 +930)' ], [ '???.txt' , 'Practical Poultry Production (1910)' ], [ 'TJCB.txt' , 'TJCB: Thomas Jeffersons Cook Book. 1937' ], [ 'TMOL.txt' , 'TMOL: The Making of Leather. 1914' ], [ 'TPSD.txt' , 'TPSD: The Practical Stock Doctor. 1912' ], [ 'TSC.txt' , 'TSC: The Settlement Cookbook. 1903' ], [ 'TSI.txt' , 'TSI: The Shoe Industry. 1916' ], [ '???.txt' , 'Univeral Household Assistant (1884)' ], [ 'VIRG.txt' , 'VIRG: Virginia Housewife or Methodical Cook. 189 +9' ], [ 'WBH.txt' , 'WBH: Window Blinds. 1907. (Hasluck)' ], [ '???.txt' , 'Wood Finishing, 1903' ], [ 'WHCB.txt' , 'WHCB: White House Cook Book. 1887' ], [ 'WWM.txt' , 'Windmills and Wind Motors, 1910' ], [ 'YCMI.htm' , 'YCMI: You Can Make It. 1929-1931' ], [ 'YOUNGS.htm' , 'YOUNGS: Youngs Demonstrative Translation of Scie +ntific Secrets. 1861' ], ); sub search_the_file { croak("Wrong number of arguments") if @_ != 2; my ( $fh, $search_string ) = @_; my $search_qm = quotemeta $search_string; my $search_re = qr{$search_qm}i; # i for insensitive-to-case my @found; while (<$fh>) { chomp; push @found, $_ if uc($_) =~ /$search_re/; } return @found; } my $separator_line = '<center><img border="0" src="/article_separator.png"></center>< +br>' . "\n"; $separator_line = "---\n"; # Overridden for PerlMonks testing my $count_total = 0; BOOK: for my $book_aref (@book_indexes_titles) { my ( $index_file, $book_title ) = @{$book_aref}; print $separator_line; open my $fh, '<', "$index_dir/$index_file" or do { print "<center>ATOCI not found for book <b>$book_title</b></ce +nter><br>\n"; next BOOK; }; my @lines = search_the_file( $fh, $wanted_string ); close $fh; $count_total += scalar @lines; print "<center><b>$book_title</b></center><br>\n"; for my $line (@lines) { print "<center>$line</center><br>\n"; } } print $separator_line; print "$count_total records found.<br>\n"; print $separator_line;

Replies are listed 'Best First'.
Re^2: losing html in print calling function.
by Librum (Initiate) on Dec 03, 2011 at 03:53 UTC

    Thanks for all the responses.

    All good points.

    And a found another, and pass it on for what it may be worth. I had two bang statements, one for localhost and one for server, with the unused one double hashed to comment out. The double hash does not comment it out.

    It works fine now, in localhost. Now I am awaiting the host provider to fix a configuration problem and that should be that.

    Thanks again.