[17262] in Perl-Users-Digest
Perl-Users Digest, Issue: 4684 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 21 14:05:23 2000
Date: Sat, 21 Oct 2000 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972151508-v9-i4684@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 21 Oct 2000 Volume: 9 Number: 4684
Today's topics:
Re: Dynamic Regex building? <godzilla@stomp.stomp.tokyo>
Re: EOF character in middle of file? <flavell@mail.cern.ch>
Re: EOF character in middle of file? <mjcarman@home.com>
help printing variable in table <erin@emmweb.com>
Re: Help with array concatenation <Jodyman@usa.net>
Re: Help with array concatenation <ren.maddox@tivoli.com>
here and filehandle <adalessandro@odione.com>
Re: here and filehandle (Clay Irving)
Re: here and filehandle <lr@hpl.hp.com>
Re: here and filehandle <adalessandro@odione.com>
Re: here and filehandle <adalessandro@odione.com>
Re: here and filehandle <wescott@conterra.com>
Re: here and filehandle <lr@hpl.hp.com>
Re: Perl objects: functions for getting and setting has <bruce_phipps@my-deja.com>
Re: Perl objects: functions for getting and setting has <uri@sysarch.com>
Re: Removing line breaks from a string - HELP! <andy@andyuk.net>
Re: Removing line breaks from a string - HELP! <godzilla@stomp.stomp.tokyo>
Re: Removing line breaks from a string - HELP! <harrisr@bignet.net>
Re: Removing line breaks from a string - HELP! <godzilla@stomp.stomp.tokyo>
Re: Removing line breaks from a string - HELP! (Clay Irving)
Re: Removing line breaks from a string - HELP! <godzilla@stomp.stomp.tokyo>
Re: Removing line breaks from a string - HELP! <lr@hpl.hp.com>
Re: Removing line breaks from a string - HELP! <harrisr@bignet.net>
Re: SSI and Perl <mbudash@sonic.net>
Re: Syndicator Script NEED SERIOUS HELP ! (Maggert)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 21 Oct 2000 09:55:25 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Dynamic Regex building?
Message-Id: <39F1CA7D.401D261E@stomp.stomp.tokyo>
Michael Hoffman wrote:
(snipped verbal diarrhea)
> Godzilla! wrote:
> > (snipped 3,591,274 lines of unrelated comments and code)
> > $in=~ s/$orig/$repl/; # SOMETHING WRONG HERE!! BUT WHAT???
> > Why don't you print each of those variables before
> > your substitution and find out what is wrong?
> > print " IN: $in\n ORIG: $orig\n REPL: $repl\n\n";
> > Of course this code snippet is extremely complex
> > and difficult to understand. Nonetheless, I am
> > certain you will figure out how to use this code.
> As to your "answer", did you even bother to read the end of the post?
> Obviously not, or else you would have seen the following:
> > Lets say I want to add 3 new fields between the 2nd and 3rd field.
> > $orig = ^([^\|]*)\|([^\|]*)\|([^\|]*)\|$
> > $repl = $1|$2||||$3|
> > Given Data like: Hi|Hello|Howdy|
> > I am returned: $1|$2||||$3|
> I believe that is what your "print" statement would provide, no?
his initial article:
"How do I get Perl to recognize the $repl string as a Regex?
Before you suggest using "/e", I did that already with no
change in results."
Yes, I read this along with 3,591,274 lines of unrelated
comments and code posted by you with an intent of annoying
people to a point of reaction. You now have a reaction.
However, you chose a wrong person to troll and from whom
to elicit a reaction.
My decision is and was, you were to confirm, by duplicity,
you are aware, precisely aware, of what is your code problem,
although there is no such problem; a reasonable person would
and could infer this based upon your malice intent displayed
via your initial fake article with a faked problem evidenced
by a variety of simple code testing, which I performed,
of course. Your regex yields the same results, regardless
if it tested as a direct regex or otherwise.
I elected to mentally manipulate you into confirming, twice,
you could have posted your problem and example with a small
handful of lines, no more than a dozen lines, rather than
posting 3,591,274 lines of unrelated comments and code,
with malice intent evidenced by a completely fake problem.
Nasty little creatures those Mind Maggots, yes Frank?
Godzilla!
------------------------------
Date: Sat, 21 Oct 2000 16:45:20 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: EOF character in middle of file?
Message-Id: <Pine.GHP.4.21.0010211641390.15210-100000@hpplus03.cern.ch>
On Sun, 22 Oct 2000, Martien Verbruggen wrote:
> On Sat, 21 Oct 2000 15:06:19 +0200,
> Alan J. Flavell <flavell@mail.cern.ch> wrote:
> > The point of a binary file is that it has no semantics as regards
> > record structure, and it would (speaking in general terms) be abnormal
> > to want to read it in a record-oriented fashion. If you want to read
> > text records then (other things being equal) text mode would be the
> > appropriate way of doing it.
> I don't think you mean it to sound quite as strict as you make it sound.
Your point is well-taken...
> It is true that binary files have no
> _inherent_ record structure, like a text file does have, but that does
> not preclude the programmer from organising a binary file based on
> records. Of course, normally those records would be of fixed length, but
> even that isn't necessary. One could write a length specifier in the
> file before a record of variable length.
Sure...
> But yes, and I think this is what you meant to say, the programmer is
> totally responsible for making a binary file structured.
Indeed, that's an enlightening way of expressing the point that I was
trying to make. Thanks.
[other good points elided]
cheers
------------------------------
Date: Sat, 21 Oct 2000 16:17:14 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: EOF character in middle of file?
Message-Id: <39F1C2CF.3B938EE9@home.com>
erion3457@my-deja.com wrote:
>
> Then I made a big mistake ... I tried to figure out what was going on.
Egads, man! Are you mad? :)
> I assumed that, since we're reading the file in binary mode, the input
> record separator would be "\015\012" [to match the actual physical
> contents of the file]. However, that doesn't appear to be the case.
Perl does it's best to DWYM, but it isn't clairvoyant. Reading a file in
binary mode means "give me the raw data." It doesn't change $/.
> If it were, chomp should take off the "\015\012" and it doesn't.
As Philip said, set $/ = "\015\012" and it will do what you want. I
would local()ize the change to a block, though, lest you screw up
processing of other (non-corrupted, non-binmode) files later on.
> A pointer to some documentation that would explain where my
> thinking process has gone wrong would be most appreciated.
I'd suggest the following:
perldoc -f binmode
perldoc perlvar (look for $/)
perldoc perlport (go to the section on newlines)
Further, I'd suggest reading the 5.6 documentation, because the
binmode() entry is much better there. If you don't have 5.6, you can
look at its docs online at www.activestate.com.
Still, you have to read between the lines a little. Here's what I can
make out of it. (Someone please enlighten me if I'm mistaken.)
By default, $/ = \n, which is effectively LF under *nix and CRLF under
DOS. (Let's leave out the Mac for now.) I say effectively, because
there's some magic that happens when you read/write a file in text mode.
DOSish Perls covert CRLF <-> LF during file IO. What this means is that
inside your script, \n is really LF, not CRLF, even under DOS! Normally
you can ignore this subtlety, but when you use binmode() on a text file
you've bypassed this little bit of magic and it becomes important.
-mjc
------------------------------
Date: Sat, 21 Oct 2000 12:13:36 -0500
From: "Erin M. McDaniel" <erin@emmweb.com>
Subject: help printing variable in table
Message-Id: <39F1CEC0.9F48A370@emmweb.com>
I have a variable, $comments, which is a long text field stored in a
mysql database. When I try to print that variable's value in a table, it
won't work. If I use:
print $comments;
it works fine.
If I print other variables which are only a word or two long, in a table
that works fine. But trying to print $comments in a table is not
working. Here's that portion of my code:
print "<table width='200' border='0' cellpadding='0' cellspacing='0'>"
print "<tr><td>";
print $comments;
print "</td></tr></table>";
Any help would be greatly appreciated! - Erin
------------------------------
Date: Sat, 21 Oct 2000 12:40:58 -0400
From: "Jody Fedor" <Jodyman@usa.net>
Subject: Re: Help with array concatenation
Message-Id: <8ssh62$d75$1@plonk.apk.net>
Uri Guttman wrote in message ...
>>>>>> "JF" == Jody Fedor <Jodyman@usa.net> writes:
>
<snip>
>-w is good. why no use strict?
>
I'm a lazy programmer! :-)
>
> JF> $yr = "2000"; # Hard code for testing
> JF> @days = (31,28,31,30,31,30,31,31,30,31,30,31);
> JF> if ($yr%4 == 0) {$days[1] = 29} else {$days[1] = 28};
>
>DUH!! that code is seriously broken. it will fail in 2100, 2200,
>etc. you are lucky that 2000 is divisible by 400 or it would have failed
>this year.
This I know, once again, I'll be dead in 2100 so I won't have to worry
about it!
>and why reassign 28 when it is 28 by default?
Stupidity, Redundancy.... take your pick. :-)
> JF> @clines = split(/\n/,$calendar);
>
> JF> foreach $cline(@clines)
> JF> {
> JF> @dates = unpack(A3 x ((length($cline)/3)+1), $cline);
>
>put quotes around A3.
Will do.
>also since cal is a fixed format, why not just use 7 for the multiplier?
Yes, a wierd fixed format. If you look at it though, not so easy:
(_ = space)
__1__2__3__4__5__6__7\n Line length is 20 instead of 21!
>check this out:
>perl -e 'for (`cal`) {@d = unpack "A3" x 7, $_; print join( "|", @d),
"\n"}'
>|Oct|obe|r 2|000||
> S| M|Tu| W|Th| F| S
> 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||||
>||||||
>
>you should shift off the first 2 lines and pop the last before doing
>that.
Thank you for the direction, it will help. I'm not familiar with join and
I'll
read up on it in perldoc.
>as for blanks, just run it thru map and replace and non-numeric values
>with what ever you want.
I'm not familiar with map, I'll look that one up too.
>uri
Thanks Uri!
------------------------------
Date: 21 Oct 2000 10:28:41 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Help with array concatenation
Message-Id: <m366mmw6vq.fsf@dhcp11-177.support.tivoli.com>
"Jody Fedor" <Jodyman@usa.net> writes:
[snip]
> Any help would be appreciated.
Uri already gave you some great information that should get you going,
but I thought I would point out the specific problem you are hitting...
> @dates = unpack(A3 x ((length($cline)/3)+1), $cline);
This lines replaces the value of @dates every time it executes. You
probably want something like:
push @dates, unpack...
--
Ren Maddox
ren@tivoli.com
------------------------------
Date: Fri, 20 Oct 2000 22:40:29 -0400
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: here and filehandle
Message-Id: <sv3il8ocmpf0a8@corp.supernews.com>
I am trying to print to a filehandle using the HERE document type, it is not
working, any ideas on how to accomplish this task?
open (SMB_CONF,">>$SMB_CONF_FILE");
print SMB_CONF <<EOF;
....
.....
EOF
------------------------------
Date: 21 Oct 2000 17:07:48 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: here and filehandle
Message-Id: <slrn8v3jb4.785.clay@panix2.panix.com>
On Fri, 20 Oct 2000 22:40:29 -0400, Arthur Dalessandro
<adalessandro@odione.com> wrote:
>I am trying to print to a filehandle using the HERE document type, it is not
>working, any ideas on how to accomplish this task?
> open (SMB_CONF,">>$SMB_CONF_FILE");
> print SMB_CONF <<EOF;
>....
>.....
>EOF
Try another here document marker:
#!/usr/local/bin/perl -w
open FOO, ">>foo.txt" or die "Can't open foo.txt: $!\n";
print FOO <<HERE_MARKER
This is a line
This is another line
This is the last line
HERE_MARKER
--
Clay Irving <clay@panix.com>
There was never a genius without a tincture of madness.
- Aristotle
------------------------------
Date: Sat, 21 Oct 2000 10:28:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: here and filehandle
Message-Id: <MPG.145b7209a82ede8d98ae54@nntp.hpl.hp.com>
In article <sv3il8ocmpf0a8@corp.supernews.com>, adalessandro@odione.com
says...
> I am trying to print to a filehandle using the HERE document type, it is not
> working, any ideas on how to accomplish this task?
> open (SMB_CONF,">>$SMB_CONF_FILE");
> print SMB_CONF <<EOF;
> ....
> .....
> EOF
1. Make sure the open succeeded, by adding a diagnostic:
open (SMB_CONF,">>$SMB_CONF_FILE") or die
"Couldn't open '$SMB_CONF_FILE'. $!\n";
2. Read perlfaq4: "Why don't my <<HERE documents work?"
3. Make sure there is really a newline after your terminator, by adding
a blank line if this is at the end of the file.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 21 Oct 2000 13:43:10 -0400
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: Re: here and filehandle
Message-Id: <sv3ldnv2j5idc@corp.supernews.com>
Here is my current code example:
# Writes out an SMB conf file, and dates.
$SMB_CONF_FILE = '/tmp/artd.testing';
open SMB_CONF,">${SMB_CONF_FILE}" or die "Can't create
$SMB_CONF_FILE\n";
print SMB_CONF <<END_OF_FILEHANDLE; # line 67 **
# Odione Technology Group
# Samba config file created by addcompay.pl script
# Creation Date: $date
#
# Global parameters
[global]
# Server configuration parameters
netbios name = files
server string = Samba %v on (${companyid})
#
workgroup = ${companyid}
min passwd length = 6
announce version = 5.0
invalid users =
root,bin,daemon,adm,sync,shutdown,halt,mail,news,uucp,operator,gopher
valid users = +${companyid}
security = user
encrypt passwords = no
interfaces = ${ip}/${netmask}
bind interfaces only = yes
max mux = 50
lock dir = /san1/smb/store/${companyid}/lock
#
#Debug Logging
log level = 1
log file = /san1/smb/samba/log/${companyid}.log
max log size = 500
#
#WINS Resolution
wins support = no
name resolve order = wins
#
#Browsing Election Options
os level = 34
local master = no
preferred master = no
domain master = no
guest account = smbd
guest ok = no
max disk size = 100
#
[homes]
# Home Directories for users
writeable = yes
browseable = no
create mask = 0700
directory mask = 0700
#
[common]
comment = ${companyname} Common Share
path = /san1/smb/store/${companyid}/common
read only = no
browseable = yes
writeable = yes
create mask = 0760
directory mask = 0770
#
[users]
comment = Users
path = /san1/smb/store/${companyid}/users
read only = no
browseable = yes
writable = yes
create mask = 0700
directory mask = 0700
END_OF_FILEHANDLE
close (SMB_FILE);
It produces this error:
Use of uninitialized value at ./artd.test.escalateaddcompany.pl line 67.
Use of uninitialized value at ./artd.test.escalateaddcompany.pl line 67.
Any help would be greatly appreciated.. Thanks.
-art
"Larry Rosler" <lr@hpl.hp.com> wrote in message
news:MPG.145b7209a82ede8d98ae54@nntp.hpl.hp.com...
> In article <sv3il8ocmpf0a8@corp.supernews.com>, adalessandro@odione.com
> says...
> > I am trying to print to a filehandle using the HERE document type, it is
not
> > working, any ideas on how to accomplish this task?
> > open (SMB_CONF,">>$SMB_CONF_FILE");
> > print SMB_CONF <<EOF;
> > ....
> > .....
> > EOF
>
> 1. Make sure the open succeeded, by adding a diagnostic:
>
> open (SMB_CONF,">>$SMB_CONF_FILE") or die
> "Couldn't open '$SMB_CONF_FILE'. $!\n";
>
> 2. Read perlfaq4: "Why don't my <<HERE documents work?"
>
> 3. Make sure there is really a newline after your terminator, by adding
> a blank line if this is at the end of the file.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: Sat, 21 Oct 2000 13:44:36 -0400
From: "Arthur Dalessandro" <adalessandro@odione.com>
Subject: Re: here and filehandle
Message-Id: <sv3lgce97ftqfa@corp.supernews.com>
Sorry for the convusion, the script works, its just giving me that
information error, which I'd like to troubleshoot.
"Larry Rosler" <lr@hpl.hp.com> wrote in message
news:MPG.145b7209a82ede8d98ae54@nntp.hpl.hp.com...
> In article <sv3il8ocmpf0a8@corp.supernews.com>, adalessandro@odione.com
> says...
> > I am trying to print to a filehandle using the HERE document type, it is
not
> > working, any ideas on how to accomplish this task?
> > open (SMB_CONF,">>$SMB_CONF_FILE");
> > print SMB_CONF <<EOF;
> > ....
> > .....
> > EOF
>
> 1. Make sure the open succeeded, by adding a diagnostic:
>
> open (SMB_CONF,">>$SMB_CONF_FILE") or die
> "Couldn't open '$SMB_CONF_FILE'. $!\n";
>
> 2. Read perlfaq4: "Why don't my <<HERE documents work?"
>
> 3. Make sure there is really a newline after your terminator, by adding
> a blank line if this is at the end of the file.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
------------------------------
Date: Sat, 21 Oct 2000 17:53:22 GMT
From: Mike Wescott <wescott@conterra.com>
Subject: Re: here and filehandle
Message-Id: <oszojy2i8r.fsf@eriadne.sc.rr.com>
"Arthur Dalessandro" <adalessandro@odione.com> writes:
> I am trying to print to a filehandle using the HERE document type, it is not
> working, any ideas on how to accomplish this task?
> open (SMB_CONF,">>$SMB_CONF_FILE");
> print SMB_CONF <<EOF;
> ....
> .....
> EOF
In what way is it not working? Upon setting $SMB_CONF_FILE to a reasonble
value it works as I expect it would:
$ perl -w
$SMB_CONF_FILE = "/tmp/xxx";
open (SMB_CONF,">>$SMB_CONF_FILE");
print SMB_CONF <<EOF;
....
.....
EOF
$ cat /tmp/xxx
....
.....
$
--
Mike Wescott
wescott@conterra.com
------------------------------
Date: Sat, 21 Oct 2000 10:45:43 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: here and filehandle
Message-Id: <MPG.145b761c8439b44e98ae56@nntp.hpl.hp.com>
In article <slrn8v3jb4.785.clay@panix2.panix.com>, clay@panix.com
says...
> On Fri, 20 Oct 2000 22:40:29 -0400, Arthur Dalessandro
> <adalessandro@odione.com> wrote:
>
> >I am trying to print to a filehandle using the HERE document type, it is not
> >working, any ideas on how to accomplish this task?
> > open (SMB_CONF,">>$SMB_CONF_FILE");
> > print SMB_CONF <<EOF;
> >....
> >.....
> >EOF
>
> Try another here document marker:
Why do you think that will make a difference?
> #!/usr/local/bin/perl -w
>
> open FOO, ">>foo.txt" or die "Can't open foo.txt: $!\n";
> print FOO <<HERE_MARKER
Needs a semicolon.
> This is a line
> This is another line
> This is the last line
> HERE_MARKER
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 21 Oct 2000 16:35:46 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Re: Perl objects: functions for getting and setting hash values
Message-Id: <8ssd5t$78c$1@sshuraab-i-1.production.compuserve.com>
>you grab the hash ref and dereference it.<
I need more details on this!
Bruce
------------------------------
Date: Sat, 21 Oct 2000 16:48:09 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl objects: functions for getting and setting hash values
Message-Id: <x7snpqp2d2.fsf@home.sysarch.com>
>>>>> "BP" == Bruce Phipps <bruce_phipps@my-deja.com> writes:
>> you grab the hash ref and dereference it.<
BP> I need more details on this!
i need a clearer question. read these docs and you will learn much more
than posting here:
perlref
perllol
perldsc
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 21 Oct 2000 16:43:26 +0100
From: "AndyUK" <andy@andyuk.net>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <wHiI5.2510$Ms3.123283@stones>
That doesn't work with what i want to do...
at the moment i have a form which submits a <textarea> field to a text file.
I want the line breaks that are make in the <textarea> field to be converted
to <br> tags. (Which i can then put into a HTML page).
If i submit this...
--------------
Line 1
Line 2
-------------------
I get this returned:
--------------------
Line 1
<br>
Line 2
<br>
-------------------
This is what i would like to get returned....
------------
Line 1<br>Line 2<br>
-----------------------
Hope you can see what i am trying to do.
Thanks,
Andy
------------------------------
Date: Sat, 21 Oct 2000 09:11:57 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <39F1C04D.1B84173@stomp.stomp.tokyo>
AndyUK wrote:
previous article:
>I have tried several things like:
>$mystring=~s/\n/<br>/g;
>but this doesn't work.
this article:
> That doesn't work with what i want to do...
> at the moment i have a form which submits a <textarea> field to a text file.
> I want the line breaks that are make in the <textarea> field to be converted
> to <br> tags. (Which i can then put into a HTML page).
> If i submit this...
> --------------
> Line 1
> Line 2
> -------------------
> I get this returned:
> --------------------
> Line 1
> <br>
> Line 2
> <br>
> Hope you can see what i am trying to do.
Others don't see what you are trying to do.
However, I am not easily fooled.
Godzilla!
--
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-type: text/plain\n\n";
$input = "Line 1
Line 2
";
print "INPUT:\n\n$input";
$input =~ s/\n/<BR>/g;
print "\n\n\nOUTPUT:\n\n$input";
exit;
PRINTED RESULTS:
________________
INPUT:
Line 1
Line 2
OUTPUT:
Line 1<BR><BR>Line 2<BR>
------------------------------
Date: Sat, 21 Oct 2000 12:50:22 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <sv3i9afsg8bm3a@corp.supernews.com>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:39F1C04D.1B84173@stomp.stomp.tokyo...
> AndyUK wrote:
>
> >I have tried several things like:
>
> >$mystring=~s/\n/<br>/g;
>
> >but this doesn't work.
>
[snip]
Let's see... OP says this doesn't work.
>
> Others don't see what you are trying to do.
> However, I am not easily fooled.
>
> Godzilla!
> --
>
[snip]
>
> $input =~ s/\n/<BR>/g;
>
[snip]
Godzilla is not easily fooled, however. She comes up with this much
improved solution. Now I can understand why she finds it necessary to
repeatedly remind everyone else on this NG how stupid they are.
If my sarcasm offends anyone other than Godzilla, please accept my
apology.
Randy Harris
------------------------------
Date: Sat, 21 Oct 2000 10:04:50 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <39F1CCB2.C63A2EDA@stomp.stomp.tokyo>
Randy Harris lacking spunk to be randy, drooled:
> Godzilla! wrote:
> > AndyUK wrote:
> > >I have tried several things like:
> > >$mystring=~s/\n/<br>/g;
> > >but this doesn't work.
> [snip]
> Let's see... OP says this doesn't work.
> [snip]
> > Others don't see what you are trying to do.
> > However, I am not easily fooled.
> > $input =~ s/\n/<BR>/g;
> [snip]
> Godzilla is not easily fooled, however. She comes up with this much
> improved solution. Now I can understand why she finds it necessary to
> repeatedly remind everyone else on this NG how stupid they are.
Your inherent ignorance beguiles your own malice intent
and significant degree of illiteracy, consistently.
Mine is not a solution but rather a demonstration,
using this author's previous statements and givens,
to clearly show, you as the original author, are nothing
more than an ignorant illiterate troll using myriad
fake names with psychotic malice intent.
* sprinkles a few more seeds *
Godzilla!
------------------------------
Date: 21 Oct 2000 17:11:30 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <slrn8v3ji2.785.clay@panix2.panix.com>
On Sat, 21 Oct 2000 16:43:26 +0100, AndyUK <andy@andyuk.net> wrote:
>That doesn't work with what i want to do...
>
>at the moment i have a form which submits a <textarea> field to a text file.
>I want the line breaks that are make in the <textarea> field to be converted
>to <br> tags. (Which i can then put into a HTML page).
>
>If i submit this...
>
>--------------
>Line 1
>
>Line 2
>
>-------------------
>I get this returned:
>--------------------
>Line 1
><br>
>Line 2
><br>
>-------------------
>This is what i would like to get returned....
>------------
>Line 1<br>Line 2<br>
>-----------------------
>
>Hope you can see what i am trying to do.
So... you want to ignore blank lines.
#!/usr/local/bin/perl -w
while (<DATA>) {
if (!/^\n/) {
s/\n/<br>/;
print;
}
}
__DATA__
Line 1
Line 2
Result:
Line 1<br>Line 2<br>[
--
Clay Irving <clay@panix.com>
MESMERISM, n. Hypnotism before it wore good clothes, kept a carriage and
asked Incredulity to dinner.
- Ambrose Bierce
------------------------------
Date: Sat, 21 Oct 2000 10:24:40 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <39F1D158.8C041CF5@stomp.stomp.tokyo>
Clay Irving wrote:
> AndyUK wrote:
(snippage)
> > If i submit this...
> > Line 1
> > Line 2
> > I get this returned:
> > Line 1
> > <br>
> > Line 2
> > <br>
> So... you want to ignore blank lines.
> #!/usr/local/bin/perl -w
> while (<DATA>) {
> if (!/^\n/) {
> s/\n/<br>/;
> print;
> }
> }
> __DATA__
> Line 1
>
> Line 2
> Result:
> Line 1<br>Line 2<br>[
* laughs *
Godzilla!
--
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-type: text/plain\n\n";
while (<DATA>) {
if (!/^\n/) {
s/\n/<br>/;
print;
}
}
__DATA__
Line 1
Line 2
PRINTED RESULTS:
________________
Line 1<br> <br> Line 2<br>
------------------------------
Date: Sat, 21 Oct 2000 10:40:19 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <MPG.145b74dc22a18be98ae55@nntp.hpl.hp.com>
[Reearranged to put the response after the question. Failure to do
so, and complete quoting with signature, is a reliable bogosity
indicator.]
In article <8ss9er$6m3$1@nnrp1.deja.com>, mtaylorlrim@my-deja.com
says...
> In article <dlhI5.2297$Ms3.120581@stones>,
> "AndyUK" <andy@andyuk.net> wrote:
> > How to i remove a line break from a string and replace it with a <br>
> > tag?
> >
> > I have tried several things like:
> >
> > $mystring=~s/\n/<br>/g;
> >
> > but this doesn't work.
>
> Have you tried..
>
> $mystring =~ s/\n/\<BR\>/g;
>
>
> Just a thought...someone else will probably give you something better.
Perhaps, but you have given him nothing better, because except for the
upper-case substitution, it is the same thing. The characters you
backslashed have no special meaning in that context.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Sat, 21 Oct 2000 13:58:07 -0400
From: "Randy Harris" <harrisr@bignet.net>
Subject: Re: Removing line breaks from a string - HELP!
Message-Id: <sv3m8bf6ksq9fc@corp.supernews.com>
Godzilla! <godzilla@stomp.stomp.tokyo> wrote in message
news:39F1D158.8C041CF5@stomp.stomp.tokyo...
> Clay Irving wrote:
>
> > So... you want to ignore blank lines.
[snip]
>
> * laughs *
>
> Godzilla!
> --
>
> TEST SCRIPT:
> ____________
>
>
> #!/usr/local/bin/perl
>
> print "Content-type: text/plain\n\n";
>
> while (<DATA>) {
> if (!/^\n/) {
> s/\n/<br>/;
> print;
> }
> }
>
> __DATA__
> Line 1
>
> Line 2
>
>
> PRINTED RESULTS:
> ________________
>
> Line 1<br> <br> Line 2<br>
Either you invented your PRINTED RESULTS or you didn't run the code
posted by Clay. Not malice, just fact.
Randy Harris
------------------------------
Date: Sat, 21 Oct 2000 08:46:24 -0700
From: Michael Budash <mbudash@sonic.net>
Subject: Re: SSI and Perl
Message-Id: <mbudash-186D4E.08462421102000@news.pacbell.net>
In article <8ss3mq$l9j$1@gxsn.com>, "David Scally"
<david.scally@scallynet.co.uk> wrote:
> In article <slrn8v1mj3.13e.efflandt@efflandt.xnet.com>,
> efflandt@xnet.com wrote:
>
> > On Fri, 20 Oct 2000, David Scally <david.scally@scallynet.co.uk> wrote:
> > >
> > >Is it possible to create a Server Side Include using a Perl
> > >subroutine?
> > >
> > >I want to include a global include file (A header that appears all
> > >over
> > >the site) that needs to be included on the news database at:
> > >www.mancity.net
> >
> > If it is a static file, you don't need Perl for that at all. Just see
> > the docs about how to include a file for your webserver.
> >
> > If it is dynamic data, you could include it by using mod_perl if your
> > server supports it (but I am not familiar with it) or by including a
> > CGI
> > (which could be Perl or anything else).
> >
> > And if you want to include anything in a CGI, you simply open and print
> > it wherever you want it inserted.
> mmm, I see what you mean about just printing it in Perl, but it doesn't
> work:
> print qq| <include virtual="header.inc"> |;
>
> Isn't there some sort of script that processes SSI into a Perl
> subroutine???
>
> Scall
>
you've missed the point... what mr. efflandt meant (i think) is
something like this:
my $include = 'header.inc';
open (H, $include)
or die("Can't open $include: $!"); # prolly shouldn't die!
my @include = <H>;
close (H);
print @include;
of course, there ae plenty of variants on this code, including those
where you undef the $/ var first, so you can slurp the whole file into a
scalar instead of an array, but the point is that you do in perl what
was being done by the ssi...
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Sat, 21 Oct 2000 16:15:41 GMT
From: mag@ionet.net (Maggert)
Subject: Re: Syndicator Script NEED SERIOUS HELP !
Message-Id: <39f1bf08.247754061@news.ionet.net>
On Sat, 21 Oct 2000 12:31:50 GMT, "Peter Jan de Werk - CGN"
<pj.dewerk@colorguard.org> wrote:
>
>> Hey,
>>
>> Who knows of a (free) syndicator script to let my sites visitors place my
>> content on their site ? Who can help ?
>>
>> Peter
Just create a RSS file on your site and use the free scripts
available from webreference.com/perl/ to give to your users. The only
drawback is that your users will need to install some modules for it
to work possibly.
http://webreference.com/perl/tutorial/8/
>>
>> --
>> Color Guard Nederland
>> www.colorguard.org
>>
>> WGI European Regional
>> www.wgieurope.org
>>
>>
>>
>>
>>
>>
>>
>>
>>
>
>
MP
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 4684
**************************************