Help with manipulating a string.

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default Help with manipulating a string.

    I've got a multiline text box that will feed the ^M at the end of each
    line. I want to capture it into a single line (which is done), but how
    do I get it back? Not knowing how many lines there may be with the ^M
    between them. Currently, I use the old standby:
    >foreach my $rec (@post) {
    > chomp($rec)
    > (Unknown here) = split(/\^M/,$rec);
    > print "whatever I need printed\n";
    >};
    I'm not sure as to how to declare it, or if there is another way?

    In Service,
    Mark Weisman


    -----Original Message-----
    From: Pandey Rajeev-A19514 [mailto:rajeevpandey@motorola.com]
    Sent: Tuesday, December 09, 2003 9:56 PM
    To: 'beginners@perl.org'
    Subject: RE: Help needed on perl wrappers


    Hi,

    I was interested in formatted display on screen.

    I can display ONE text paragraph in any part of the screen with
    Text::wrap. My question was how to adjust MANY such independent
    paragraphs in one screen (exactly in a newspaper format where you have
    8-10 columns of news items on a single page).

    I wanted to know is there something like Text::wrap which can do this.
    Or Text::wrap can handle only one paragraph. If nothing like that exists
    then I might have to give up Text::wrap and use my own logic to adjust
    it.

    Moreover, I also wanted to use Term::Size to adjust the text with
    changing screen size.

    Is there any convenient way to do this ? I was looking for readymade
    stuff. Please suggest.

    Regards
    Rajeev

    -----Original Message-----
    From: Tom Kinzer [mailto:tomkinzer@earthlink.net]
    Sent: Wednesday, December 10, 2003 12:05 PM
    To: [email]beginners@perl.org[/email]
    Subject: RE: Help needed on perl wrappers



    I'm trying to figure out WHY you would ever want to create what you are
    asking for. Why-- is a good question here, because there may be a way
    to get to the real goal instead of creating this. For instance if it's
    just going into an HTML document, a table of course, would be easier.
    Just an example, so WHY are you wanting to do this?

    If this is really want you want, then: Do you really want a ragged left
    on the right column? Do you really want to use tabs? I'm thinking
    spaces would be easier to deal with for this problem and could buy you a
    justified left margin on the right column.

    More info please.

    -Tom Kinzer

    -----Original Message-----
    From: Pandey Rajeev-A19514 [mailto:rajeevpandey@motorola.com]
    Sent: Tuesday, December 09, 2003 8:16 PM
    To: 'beginners@perl.org'
    Subject: Help needed on perl wrappers


    Hi,

    I have a text that I read from a file. I want to display the text on the
    screen in a column in a newspaper style. I do it like this....

    $initial_tab = "\t\t";
    $subsequent_tab = "\t\t";
    print wrap($initial_tab, $subsequent_tab, @text1);
    print fill($initial_tab, $subsequent_tab, @text1);

    It will print like this ...
    I am a boy and I go to school
    everyday. I have to do a lot of
    homework and I dont get time
    to play these days.


    But if I have more than one independent text i.e. @text2, @text3 to be
    displayed in different columns, then what shall i do. I want something
    like this ...

    I am a boy and I go to school She is a girl and
    she
    also goes
    everyday. I have to do a lot of to school. I do
    all
    her homework
    homework and I dont get time and she gets plenty
    of
    time to
    to play these days play.

    Is there any mechanism to achieve this ?

    Best Regards
    Rajeev

    --
    To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    <http://learn.perl.org/> <http://learn.perl.org/first-response>



    --
    To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    <http://learn.perl.org/> <http://learn.perl.org/first-response>


    --
    To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
    For additional commands, e-mail: [email]beginners-help@perl.org[/email]
    <http://learn.perl.org/> <http://learn.perl.org/first-response>


    Mark Weisman Guest

  2. Similar Questions and Discussions

    1. manipulating a XML document
      hello list, I need to be able to "clean" a XML file, creating a version without blank spaces among the tags. So, what I want to do is to create...
    2. Manipulating CSV files with SQL
      Can UPDATES and INSERTS be used on CSV files when using the "cfquery" tag of ColdFusion? I've tried but so far no luck. My thinking is that this is...
    3. Manipulating XML File
      Assume you're working with a vendor that doesn't understand web services and implements their version of a web service solution that only returns...
    4. Manipulating a 3d object
      Hi, I am very new to Director, but I have made a 3d model in 3ds max, and have been able to import it as a new cast member. I want the user to...
    5. Manipulating arrays
      Hello.... Where can I see (web pages) examples of manipulating arrays, calculos with elements of arrays or something like that?, I am writing a...
  3. #2

    Default Re: Help with manipulating a string.

    On Dec 10, 2003, at 1:39 AM, Mark Weisman wrote:
    > I've got a multiline text box that will feed the ^M at the end of each
    > line. I want to capture it into a single line (which is done), but how
    > do I get it back? Not knowing how many lines there may be with the ^M
    > between them. Currently, I use the old standby:
    >
    >> foreach my $rec (@post) {
    >> chomp($rec)
    >> (Unknown here) = split(/\^M/,$rec);
    >> print "whatever I need printed\n";
    >> };
    >
    > I'm not sure as to how to declare it, or if there is another way?
    my @lines = split /\^m/, $rec;

    Is that what you mean? The split just returns a list of the lines, so
    we can stick that in an array.

    James

    James Edward Gray II Guest

  4. #3

    Default RE: Help with manipulating a string.

    I messed something up, for some reason my textarea is not saving the
    text to a single line in the text file. I've got a standard text box
    that users may hit the enter key to establish different paragraphs
    within their post, however, for some reason it carries the CRLF down to
    the variable and the text file I'm posting it all too, I know that this
    is more html than PERL, but how do I remove the CRLF, and just have the
    ^M again? Help.

    In Service,
    Mark


    -----Original Message-----
    From: James Edward Gray II [mailto:james@grayproductions.net]
    Sent: Wednesday, December 10, 2003 5:36 AM
    To: Mark Weisman
    Cc: [email]beginners@perl.org[/email]
    Subject: Re: Help with manipulating a string.


    On Dec 10, 2003, at 1:39 AM, Mark Weisman wrote:
    > I've got a multiline text box that will feed the ^M at the end of each
    > line. I want to capture it into a single line (which is done), but how
    > do I get it back? Not knowing how many lines there may be with the ^M
    > between them. Currently, I use the old standby:
    >
    >> foreach my $rec (@post) {
    >> chomp($rec)
    >> (Unknown here) = split(/\^M/,$rec);
    >> print "whatever I need printed\n";
    >> };
    >
    > I'm not sure as to how to declare it, or if there is another way?
    my @lines = split /\^m/, $rec;

    Is that what you mean? The split just returns a list of the lines, so
    we can stick that in an array.

    James

    Mark Weisman Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139