Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Formatting Text as HTML (was: regular expression)

by tsvika_t (Initiate)
on Jan 16, 2001 at 14:44 UTC ( #52206=perlquestion: print w/replies, xml ) Need Help??

tsvika_t has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.
  • Comment on Formatting Text as HTML (was: regular expression)

Replies are listed 'Best First'.
Re: regular expression
by OeufMayo (Curate) on Jan 16, 2001 at 15:00 UTC

    Hey!

    First, you really should post some piece of code showing what you tried to do.

    Secondly, maybe another title for the subject would more appropriate, as you can easily solve your problem without regular expressions.

    A simple string concatenation while looping over your file could do the trick:

    perl -pi.bak -e "chomp;$_ .= qq/<br>\n/" your_file.txt # Win32 perl -pi.bak -e 'chomp;$_ .= "<br>\n" your_file.txt # *nix
    <kbd>--
    PerlMonger::Paris(http => 'paris.pm.org');</kbd>
Re: regular expression
by ChOas (Curate) on Jan 16, 2001 at 14:58 UTC
    while (<>) { chomp; print "$_<BR>"; # (Optional: print "$_<BR>\n"; for readability) };

    Or....(Imagine your own file opening, etc. here..)
    my @File=<INPUT>; close INPUT; chomp(@File) { local $"="<BR>"; # (Optional: local $"="<BR>\n"; for readability) print "@File<BR>"; #(Optional: print "@File<BR>\n"; for readability) };

    probably faster than a regex, problem is I don't
    know how/where you are gonna use it....So with
    the information you gave... See above

    GreetZ!,
      ChOas

    print "profeth still\n" if /bird|devil/;
Re: regular expression
by jeroenes (Priest) on Jan 16, 2001 at 15:00 UTC
    Hmmm.. I kind of think you have asked this question before. Most easy way to code it is something like:
    #!/usr/bin/perl -p chop; $_.="<br>\n";
    Hope this helps.

    Jeroen
    "We are not alone"(FZ)

      Thanks for all the answers
      But I should have ask it differently,
      and I will put in a piece of code
      in order to be more specific.
      I have this code:

      #!/usr/local/bin/perl

      use DBI;
      use strict;

      my $field;
      my $temp;
      my $i;
      my $query;
      my $name;
      my $value;
      my $glossary_id;
      my $inbuf;
      my %Form;
      my $pair;
      read(STDIN,$inbuf,$ENV{'CONTENT_LENGTH'});
      my @pairs = split(/&/,$inbuf);
      foreach $pair (@pairs) {
      ($name,$value)=split(/=/,$pair);
      $value=~tr/+/ /;
      $value=~s/%(a-fA-F0-9a-fA-F0-9)/pack("C", hex($1))/eg;
      $Form{$name}=$value;
      }
      $ENV{INFORMIXSERVER} = "develop_remote";
      my $database = "test";
      my $dbh = DBI->connect("dbi:Informix:$database");
      if ($Form{field}=~/editor_comment/){
      $query = "update glossary_develop set($Form{field}) = (\"$Form{value}\") where glossary_id=$Form{glossary_id}";
      }
      else {
      $query = "update glossary_develop set($Form{field}) = ($Form{value}) where glossary_id=$Form{glossary_id}";
      }
      my $rows_affected = $dbh->do($query);

      and the query is no good if it breakes in to few
      line in the middle of the value: ($Form{value})

      Hope I am more specific now and hope you can help me
      again.
      Thanks.
      Tsvika.

        BAD - BAD - BAD

        Your really should consider using CGI.pm module instead of rolling your own. This issue has been discussed over and over at perlmonks.

        Not only that it will make your scipt clearer, but it will also avoid you a lot of troubles (from Perl and from the monks) :-)

        <kbd>--
        PerlMonger::Paris(http => 'paris.pm.org');</kbd>
          A reply falls below the community's threshold of quality. You may see it by logging in.
        Hey man - In order to make your posts more readable, use the <CODE> Code Tags</CODE>

        Check out the writeup formatting tips on the preview pages.

        You'll agree, that
        #!usr/bin/perl print "bunch of stuff"; print "and some more";
        Looks better than

        >#!usr/bin/perl print "bunch of stuff"; print "and some more";

        Cheers,
        ML
        if ($mr_leisure) { bow; }
        this is still not finished

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://52206]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2021-10-26 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?