For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > June 2005 > how to format a $htmlpage without form feed









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to format a $htmlpage without form feed
Oliver Bleckmann

2005-06-10, 8:57 pm

perhaps a simple question ;-)
how to format a html page without form feeds?
i thougt this would work, but it doesn't...
$htmlpage =~ s/\</\<\n/S;
replace the > of each tag with a > plus form feed
any idea?


John Bokma

2005-06-10, 8:57 pm

Oliver Bleckmann wrote:

> perhaps a simple question ;-)
> how to format a html page without form feeds?
> i thougt this would work, but it doesn't...
> $htmlpage =~ s/\</\<\n/S;
> replace the > of each tag with a > plus form feed
> any idea?


[1] \n is not form feed
[2] what do you want to do? breaking lines? That's an HTML question

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

Oliver Bleckmann

2005-06-10, 8:57 pm

sorry line feed and yes it is a html question if you view it in the browser
but theres is no line feed in raw text at all
"John Bokma" <john@castleamber.com> schrieb im Newsbeitrag
news:Xns9671B70E5AFAcastleamber@130.133.1.4...
> Oliver Bleckmann wrote:
>
>
> [1] \n is not form feed
> [2] what do you want to do? breaking lines? That's an HTML question
>
> --
> John Small Perl scripts: http://johnbokma.com/perl/
> Perl programmer available: http://castleamber.com/
> Happy Customers: http://castleamber.com/testimonials.html
>



Tad McClellan

2005-06-10, 8:57 pm

Oliver Bleckmann <Oliver-Bleckmann@freenet.de> wrote:

> i thougt this would work, but it doesn't...
> $htmlpage =~ s/\</\<\n/S;



Of course not, it does not even compile...


> any idea?



Writing actual Perl code would be a good idea. :-)

You must get it to compile and run before it even has a chance to "work".



Have you seen the Posting Guidelines that are posted here frequently?


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Tad McClellan

2005-06-10, 8:57 pm

Oliver Bleckmann <Oliver-Bleckmann@freenet.de> wrote:

> $htmlpage =~ s/\</\<\n/S;
> replace the > of each tag with a > plus form feed



You have those little >pointy< things going in 2 different
directions there, so which is it?

\n is NOT a "form feed", it is a "line feed".

\f is a "form feed" character.


Whitespace does not matter in HTML, so even if you did make the
change I think you are attempting, it would not change how the
webpage was displayed in a browser.

Do you want to do this just so it is easier to read the raw HTML file,
or do you want to add <br>eaks that the browser will act on?


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Jürgen Exner

2005-06-11, 3:57 am

Oliver Bleckmann wrote:
> perhaps a simple question ;-)
> how to format a html page without form feeds?


You could use newlines instead of form feeds.

Joking aside, are you talking about formatting the HTML source code or about
formatting the rendered result in a browser?

> i thougt this would work, but it doesn't...
> $htmlpage =~ s/\</\<\n/S;
> replace the > of each tag with a > plus form feed


Well, your text doesn't seem to have anything to do with your code fragment
Which one is it?

jue


John Bokma

2005-06-11, 3:57 am

Oliver Bleckmann wrote:

> sorry line feed and yes it is a html question if you view it in the
> browser but theres is no line feed in raw text at all


[1] don't top post
[2] This is a Perl group, not an HTML group.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html

Oliver Bleckmann

2005-06-11, 3:57 am

ok guys,
i see that you don't understand what i mean.
at first: this has nothing to do with html rendering in a browser. italk
about the raw text.
for i am german, my english isn't the best.
i mean a line feet - sorry my fault - which should be used to format a
string without any line feed (the \n thing, you know)
again this has nothing to do with <br>.
the only thing is, that this string consists of html tags. it would be
nice - just for reading - to break a line after every
closed tag - that means after a ">".

a substitution of the ">" by a ">" with following line feet doesn't work
!!!!!!!!!!
ok, this is a shortend version - compiles and works, if you skip the
supstitoution block

use LWP::Simple;
$URL="http://de.finance.yahoo.com/q/cq?s=710000&m=a";
$inh = get($URL);
open (DATEI, ">c:/boerse.htm") or die "Couldn't open for writing:
$!\n";

if ( $inh =~ m/(.+)Tabellenansicht(.+)/s )
{
$inh2 = $2;
}
if ( $inh2 =~ m/(.+)Kursdaten downloaden(.+)/s )
{
$inh3 = $1;
}

if ( $inh3 = s/"\>"/"\>\n"/sgoi)
{
print DATEI $inh3;
}
close (DATEI);

"Oliver Bleckmann" <Oliver-Bleckmann@freenet.de> schrieb im Newsbeitrag
news:d8d48b$kjp$1@newsserver.rz.tu-ilmenau.de...
> perhaps a simple question ;-)
> how to format a html page without form feeds?
> i thougt this would work, but it doesn't...
> $htmlpage =~ s/\</\<\n/S;
> replace the > of each tag with a > plus form feed
> any idea?
>



A. Sinan Unur

2005-06-11, 3:57 am

"Oliver Bleckmann" <Oliver-Bleckmann@freenet.de> wrote in news:d8dbiv$8cs
$1@newsserver.rz.tu-ilmenau.de:

> ok guys,
> i see that you don't understand what i mean.


See <URL: http://www.elektrolurch.com/lyrics/titel/154.html>

*PLONK*

--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(reverse each component and remove .invalid for email address)

comp.lang.perl.misc guidelines on the WWW:
http://mail.augustmail.com/~tadmc/c...guidelines.html
Gunnar Hjalmarsson

2005-06-11, 3:57 am

Oliver Bleckmann wrote:
> it would be nice - just for reading - to break a line after every
> closed tag - that means after a ">".


<snip>

> use LWP::Simple;
> $URL="http://de.finance.yahoo.com/q/cq?s=710000&m=a";
> $inh = get($URL);


$inh =~ s/>/>\n/g;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Oliver Bleckmann

2005-06-11, 8:56 am

damn, that's what i started with - was in the original code paster from tv
parser, another very old project - and now
it works! I must have been too tired yesterday, thanks.

"Gunnar Hjalmarsson" <noreply@gunnar.cc> schrieb im Newsbeitrag
news:3gus09Feas97U1@individual.net...
> Oliver Bleckmann wrote:
>
> <snip>
>
>
> $inh =~ s/>/>\n/g;
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl



Alan J. Flavell

2005-06-11, 8:56 am

On Sat, 11 Jun 2005, Oliver Bleckmann blurted out atop a quote:

> ok guys,
> i see that you don't understand what i mean.


I see that you haven't yet positioned yourself to make effective use
of Usenet.

> for i am german, my english isn't the best.


In meine Erfahrung, erwarten die .de-Gruppen *auch* (koennete sagen
"noch strenger"), dass man die usenet-Regeln ("Netiquette") einhaelt.
http://www.kirchwitz.de/~amk/dni/einleitung und de.newusers.infos
koennte helfen.

Anyway, the key to solving a complex problem (and, based on what
you're posting, this appears to represent a complex problem for you)
is to identify the parts of the problem, and solve each of them *in
their proper place*. If you're having problems with the HTML that
you're generating from a Perl script, then the right place to solve
that is a forum where HTML is on topic, not a Perl programming group.

The only real Perl problem relevance that I've noticed so far in your
posting to this thread is the meaning of \n, which you got wrong at
first and then seem to have reacted inappropriately when it was
pointed out to you. The killfile awaits.
Tad McClellan

2005-06-11, 3:57 pm

Oliver Bleckmann <Oliver-Bleckmann@freenet.de> wrote:

> if ( $inh3 = s/"\>"/"\>\n"/sgoi)



You are requiring a 3-character substring:
double quote
closing angle bracket
double quote

If your angle brackets don't have quote characters, then the
pattern will not match.

If the pattern does not match then s/// does not do anything.

You need to write a pattern that will match rather than fail,
take out the double quotes.

And the backslashes, angle brackets are not special in regexes
nor in strings.

And the s///s option, it does not do anything when there is no
dot (.) in your pattern.

And the s///o option, it does not do anything when there is no
variable part in your pattern.

And the s///i option, it does not do anything when there are no
letters in your pattern.


Do not throw options onto the end willy nilly.

Use the ones you need, don't use the ones you don't need.

To do that, you will need to understand what each does, see the docs.


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com