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

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


    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
    PerlMonger::Paris(http => '');</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


    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.

    "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:


      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;
      my @pairs = split(/&/,$inbuf);
      foreach $pair (@pairs) {
      $value=~tr/+/ /;
      $value=~s/%(a-fA-F0-9a-fA-F0-9)/pack("C", hex($1))/eg;
      $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

        BAD - BAD - BAD

        Your really should consider using 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) :-)

        PerlMonger::Paris(http => '');</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";

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

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://52206]
Approved by root
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
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (90 votes). Check out past polls.