in reply to Re: Wrapping Strings
in thread wrapping a pair of lines; what if different lengths?

thanks for the help! I am writing this to do a cgi and am having problems embedding the html into your code.
print STDOUT join ("font face=\"courier\"><p>" substr ($strings[$_], $ +x, $line_length), $/ for (0..2)) "</font><p>";
Can you see where my syntax is bad?? thanks again

Replies are listed 'Best First'.
Re: Re: Re: Wrapping Strings
by aging acolyte (Pilgrim) on Jan 17, 2003 at 11:53 UTC
    hi

    If you are doing cgi then I suggest that you check out Ovid's "Web Programming Using Perl" Course which is a pretty good intro to CGI programming.

    Might I also point you to Bioperl which is a bioinformatics perl site where lots of common sequence manipulations etc. have already been solved.

    A.A.

Re: Wrapping Strings
by tadman (Prior) on Jan 17, 2003 at 13:44 UTC
    You might not have noticed, but the print command can take a list of things to print, which means that join() is really not required. The syntax error is that after your first string where you establish the font, you don't use the period to concatenate, or a comma to make a proper list.
    foreach (0..2) { print '<font face="courier"><p>', substr($strings[$_], $x, $line_length), '</p></font>', $/; }
    I moved the for-loop into a more obvious location. Before you were losing it in the print statement. I've also take then liberty of opening your <FONT> tag properly, as well as using single quotes to avoid having to escape the quotation marks in your HTML.

    As another note, print sends to STDOUT by default, so there's no real need to specify that.