>I am trying to figure out how I can parse a row, character by 
>character, that I have retrieved from a database. 

You could try something like this:

  while ($row) { # while there are still characters left to look at
    ($char) = $row =~ s/(\w)//; # Removes the first word character of
                                # $row and puts it in $char

This will destroy the contents of $row, so you might want to make a copy of
it first if you're going to need it later.

>I would like to format output based on characters from the row.  For 
>example I may have retrieved 250 character string from a database and 
>I want to print that character string, BUT I want to print only 50 
>characters a line or less.   How might I do this if I have a variable 
>called @row??

Hopefully you mean a variable called $row. @row would be an array (a list of
(possibly) many variables). Anyway, building on above:

  while ($row) {
    for (1..50) { # Repeat 50 times
      ($char) = $row =~ s/(\w)//;
        $output .= $char; # Add $char to $output
    }
    $output .= "\n"; # Add a newline to $output
  }

This will probably produce lots of warnings if $row doesn't have a multiple
of 50 characters in it (you are using the -w switch I hope). But it should
work more or less.

Cheers

Mark C
-- 
------------------------------------------------------------------------
Dr Mark Crowe                           John Innes Centre
                                                Norwich Research Park
Tel/Fax: +44 (1603) 450012              Colney          
mailto:[EMAIL PROTECTED]           Norwich
                                                NR4 7UH

Reply via email to