[13394] in Perl-Users-Digest
Perl-Users Digest, Issue: 804 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 15 12:27:14 1999
Date: Wed, 15 Sep 1999 09:20:38 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 15 Sep 1999 Volume: 9 Number: 804
Today's topics:
Replace new lines with <BR> in TEXTAREA <butterfingers1@my-deja.com>
Re: Replace new lines with <BR> in TEXTAREA <karl@bofh.com.au>
s/// and tr/// functions makau@multimania.com
Re: s/// and tr/// functions (Larry Rosler)
Re: s/// and tr/// functions (Kragen Sitaker)
Sco OpenServer 5.05 <renez@csnet.nl>
script to dynamically produce standard calender <mark@artdigital.co.uk>
Re: script to dynamically produce standard calender (Matthew Bafford)
Re: script to dynamically produce standard calender <mark@artdigital.co.uk>
Stock quote URL strings <Michael_Kraizman@excite.com>
Subroutnes definitions with explicit declarations <krajzewicz@inx.de>
Re: Templates <rootbeer@redcat.com>
Re: Templates (Kragen Sitaker)
Re: trimming spaces from a string (hoz)
Re: trimming spaces from a string (Matthew Bafford)
Re: trimming spaces from a string (Gabor)
Re: trimming spaces from a string (Larry Rosler)
Re: trimming spaces from a string (Larry Rosler)
Re: trimming spaces from a string (Matthew Bafford)
Re: trimming spaces from a string (Gabor)
Re: Unix and Perl script <rhomberg@ife.ee.ethz.ch>
Use of uninitialized value at... <picaza@chsi.com>
Re: XML as database ? (Eric Bohlman)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 15 Sep 1999 05:23:27 GMT
From: Graham W. Boyes <butterfingers1@my-deja.com>
Subject: Replace new lines with <BR> in TEXTAREA
Message-Id: <7rnag8$ono$1@nnrp1.deja.com>
Hello,
I've got a form with a TEXTAREA on it. I've written a script that
takes the data from the textarea and puts it into the variable
$TheText, and outputs it on the screen. But if I have two paragraphs
in the textarea, the whole thing appears as one big long line, because
of course new lines are not recognized with HTML.
How do I replace the new lines with the <BR> tag?
Thanks,
Graham W. Boyes
--
"The One and Only"
me AT toao DOT net ~ http://www.toao.net
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 15 Sep 1999 15:45:45 +1000
From: Karl Hanmore <karl@bofh.com.au>
Subject: Re: Replace new lines with <BR> in TEXTAREA
Message-Id: <37DF3289.23D90550@bofh.com.au>
"Graham W. Boyes" wrote:
> Hello,
> I've got a form with a TEXTAREA on it. I've written a script that
> takes the data from the textarea and puts it into the variable
> $TheText, and outputs it on the screen. But if I have two paragraphs
> in the textarea, the whole thing appears as one big long line, because
> of course new lines are not recognized with HTML.
>
> How do I replace the new lines with the <BR> tag?
>
> <snip>
$TheText =~ s/\n/<BR>/g;
I believe will give you what you require.
Regards,
Karl
------------------------------
Date: Wed, 15 Sep 1999 12:47:49 GMT
From: makau@multimania.com
Subject: s/// and tr/// functions
Message-Id: <7ro4hh$aqf$1@nnrp1.deja.com>
is it possible to do :
s/\ \;/ /g;
s/<BR>/\n/g;
in one line?
Thanks for your help!
Makau.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 15 Sep 1999 06:49:18 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: s/// and tr/// functions
Message-Id: <MPG.124943b6e7e0c1de989f67@nntp.hpl.hp.com>
In article <7ro4hh$aqf$1@nnrp1.deja.com> on Wed, 15 Sep 1999 12:47:49
GMT, makau@multimania.com <makau@multimania.com> says...
> is it possible to do :
>
> s/\ \;/ /g;
> s/<BR>/\n/g;
>
> in one line?
Sure it is.
s/ / /g, s/<BR>/\n/g;
:-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 15 Sep 1999 13:59:35 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: s/// and tr/// functions
Message-Id: <bDND3.12480$N77.928200@typ11.nn.bcandid.com>
In article <7ro4hh$aqf$1@nnrp1.deja.com>, <makau@multimania.com> wrote:
>s/\ \;/ /g;
>s/<BR>/\n/g;
>in one line?
You could
s/\ \;/ /g; s/<BR>/\n/g;
Or you could
s/(\ \;|<BR>)/${{' ' => ' ', '<BR>' => "\n"}}{$1}/eg;
This program demonstrates:
#!/usr/bin/perl -w
use strict;
$_ = 'this is a follicle<BR>it is great<BR>';
s/(\ \;|<BR>)/${{' ' => ' ', '<BR>' => "\n"}}{$1}/eg;
print;
Myself, I think the separate substitutions are easier to read.
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 15 Sep 1999 11:30:03 GMT
From: "news.csnet.nl" <renez@csnet.nl>
Subject: Sco OpenServer 5.05
Message-Id: <7rnvvr$it4@news3.euro.net>
First of all sorry that this is a long posting. I have tried to give as much
detail as needed
The problem:
I compiled and installed perl5.005.03. as per sco.sh (sh
configure -Dcc=gcc -Dusenm)
But installing modules like Storage 6.04 with make test I get:
Can't load 'blib/arch/auto/Storable/Storable.so' for module
Storable:
dynamic linker: /usr/bin/perl: invalid relocation type 3 at
0x804c840c
at /usr/local/lib/perl5/5.00503/i386-sco/DynaLoader.pm
The load line for Storage.so is:
RUN_PATH="" ld -o
blib/arch/auto/Storable/Storable.so -G -L/usr/local/lib Storable.o
when I change the dynamic loadline to be::
RUN_PATH="" ld -o blib/arch/auto/Storable/Storable.so -G -z defs \
-L/usr/local/lib Storable.o
../perl5.005_03/libperl.a -lnsl -lsocket -lcrypt -lm -lc
Everything goes oke and the problem disapears.
Why do I have to include al these things and is there an easy way to do this
in de configure file(s)?
Or do I need to product a libperl.so on SCO so that everything can be
resolved
Thanks Rene
-------Details-------------
I'm running a SCO open Server details:
System = SCO_SV
Node = cse3
Release = 3.2v5.0.5
KernelID = 98/07/02
Machine = PentII(D)
BusType = ISA
Serial = 4CF021320
Users = 15-user
OEM# = 0
Origin# = 1
NumCPU = 1
I compiled perl 5.005.03 with dynamic loading which is fine if you use
sh Confiugre -Dcc=gcc -Dusenm (as per documentation in the hints/sco.sh)
perl -V gives
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=sco, osvers=3.2v5.0.5, archname=i386-sco
uname='sco_sv cse3 3.2 5.0.5 i386 '
hint=previous, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='gcc', optimize='-O2', gccversion=2.8.1
cppflags='-U M_XENIX -D PERL_SCO -D
PERL_SCO5 -melf -I/usr/local/include'
ccflags ='-U M_XENIX -D PERL_SCO -D
PERL_SCO5 -melf -I/usr/local/include'
stdchar='unsigned char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=4, ptrsize=4, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
alignbytes=4, usemymalloc=n, prototype=define
Linker and Libraries:
ld='ld', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /shlib /lib /usr/lib /usr/ccs/lib
libs=-lintl -lsocket -lnsl -lndbm -lgdbm -ldbm -lld -lm -lc -lcrypt -lPW -lx
libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef,
ccdlflags='-Xlinker -Bexport -L/usr/local/lib'
cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under sco
Compiled at Sep 15 1999 11:00:31
@INC:
/usr/local/lib/perl5/5.00503/i386-sco
/usr/local/lib/perl5/5.00503
/usr/local/lib/perl5/site_perl/5.005/i386-sco
/usr/local/lib/perl5/site_perl/5.005
.
But installing modules like Storage 6.04 i get
Can't load 'blib/arch/auto/Storable/Storable.so' for module Storable:
dynamic linker: /usr/bin/perl: invalid relocation type 3 at 0x804c840c at
/usr/local/lib/perl5/5.00503/i386-sco/DynaLoader.pm
de dynamic loader command is
LD_RUN_PATH="" ld -o
blib/arch/auto/Storable/Storable.so -G -L/usr/local/lib Storable.o
if I change it to be
LD_RUN_PATH="" ld -o blib/arch/auto/Storable/Storable.so -G -z
defs -L/usr/local/lib Storable.o
I get:
Undefined first referenced
symbol in file
__lstat32 Storable.o
Perl_sv_upgrade Storable.o
Perl_sv_2io Storable.o
Perl_newSV Storable.o
Perl_safemalloc Storable.o
Perl_sv_newmortal Storable.o
Perl_sv_magic Storable.o
htonl Storable.o
Perl_hv_iterinit Storable.o
Perl_newXS Storable.o
cast_iv Storable.o
Perl_hv_store Storable.o
Perl_sv_2iv Storable.o
Perl_av_len Storable.o
PL_sv_undef Storable.o
fputc Storable.o
Perl_sv_setpv Storable.o
Perl_av_push Storable.o
Perl_av_store Storable.o
__stat32 Storable.o
Perl_sv_2pv Storable.o
PL_sv_yes Storable.o
Perl_hv_iternext Storable.o
PL_markstack_ptr Storable.o
Perl_hv_fetch_ent Storable.o
Perl_sv_2nv Storable.o
__filbuf Storable.o
Perl_hv_fetch Storable.o
PL_sv_no Storable.o
Perl_av_fetch Storable.o
Perl_sv_taint Storable.o
Perl_newSVpv Storable.o
Perl_sv_setiv Storable.o
Perl_warn Storable.o
Perl_hv_undef Storable.o
strcmp Storable.o
Perl_form Storable.o
Perl_newSVnv Storable.o
Perl_sv_cmp Storable.o
Perl_sv_grow Storable.o
fread Storable.o
qsort Storable.o
Perl_sv_bless Storable.o
Perl_hv_iternextsv Storable.o
Perl_sv_2bool Storable.o
Perl_sv_2mortal Storable.o
PL_stack_sp Storable.o
Perl_av_extend Storable.o
Perl_newSViv Storable.o
__statlstat32 Storable.o
__fstat32 Storable.o
Perl_newHV Storable.o
Perl_av_undef Storable.o
PL_stack_base Storable.o
Perl_croak Storable.o
perl_get_sv Storable.o
ntohl Storable.o
Perl_gv_stashpv Storable.o
PL_tainting Storable.o
Perl_hv_iterkeysv Storable.o
Perl_newSVsv Storable.o
Perl_hv_iterkey Storable.o
Perl_av_shift Storable.o
Perl_sv_reftype Storable.o
sprintf Storable.o
Perl_newRV_noinc Storable.o
Perl_sv_free Storable.o
bcopy Storable.o
PL_tainted Storable.o
Perl_mg_find Storable.o
fwrite Storable.o
Perl_newAV Storable.o
Perl_saferealloc Storable.o
when I change the dynamic loadline to be::
RUN_PATH="" ld -o blib/arch/auto/Storable/Storable.so -G -z defs \
-L/usr/local/lib Storable.o
../perl5.005_03/libperl.a -lnsl -lsocket -lcrypt -lm -lc
Everything goes oke and the problem disapears.
Why do I have to include al these things and is there an easy way to do this
in de configure file(s)?
Or do I need to product a libperl.so on SCO so that everything can be
resolved
Thanks Rene
------------------------------
Date: Wed, 15 Sep 1999 12:30:34 +0100
From: "Mark Hamlin" <mark@artdigital.co.uk>
Subject: script to dynamically produce standard calender
Message-Id: <7ro019$cq6$1@pheidippides.axion.bt.co.uk>
Hi,
I'm after a script to dynamically produce calendar output, i.e. a small
table for each month (text only) with 7 columns - one for each day, and the
days represented by the number (bog standard calendar - you know what I
mean). If you have something suitable handy or know where such a thing is
available on-line or even a book that it is in, I'd really appreciate it if
you could send me an email me (and tell me about it, not just gloat!).
Cheers & Thanks,
Mark Hamlin
------------------------------
Date: Wed, 15 Sep 1999 12:11:57 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: script to dynamically produce standard calender
Message-Id: <slrn7tv1oc.1pj.*@dragons.duesouth.net>
Wed, 15 Sep 1999 12:30:34 +0100, a great smashing of the head occured
against Mark Hamlin" <mark@artdigital.co.uk>'s keyboard, causing
comp.lang.perl.misc to receive this:
: I'm after a script to dynamically produce calendar output, i.e. a small
Wheel, meet Mark.
Look for `cal'. It is not a Perl script, but it works quite well.
Oh, and it has been done in Perl.
http://language.perl.com/ppt/
: Cheers & Thanks,
HTH,
: Mark Hamlin
--Matthew
------------------------------
Date: Wed, 15 Sep 1999 14:08:09 +0100
From: "Mark Hamlin" <mark@artdigital.co.uk>
Subject: Re: script to dynamically produce standard calender
Message-Id: <7ro5o8$fvs$1@pheidippides.axion.bt.co.uk>
Hey Mark guess what I found,
http://www.genome.wi.mit.edu/WWW/examples/Ch9/calendar5.pl
perl cgi script. Takes year as input and produces calendar. Quite nifty!
Next time have a better look through your own bookmarks before you go
filling the usenet with unnecessary crap! Oh yeah, have fun!!!!!
PP
Mark Hamlin <mark@artdigital.co.uk> wrote in message
news:7ro019$cq6$1@pheidippides.axion.bt.co.uk...
> Hi,
>
> I'm after a script to dynamically produce calendar output, i.e. a small
> table for each month (text only) with 7 columns - one for each day, and
the
> days represented by the number (bog standard calendar - you know what I
> mean). If you have something suitable handy or know where such a thing is
> available on-line or even a book that it is in, I'd really appreciate it
if
> you could send me an email me (and tell me about it, not just gloat!).
>
> Cheers & Thanks,
> Mark Hamlin
>
>
>
------------------------------
Date: Wed, 15 Sep 1999 10:12:36 -0400
From: "Michael Kraizman" <Michael_Kraizman@excite.com>
Subject: Stock quote URL strings
Message-Id: <7ro97s$6t2$1@news2.tor.accglobal.net>
SSdtIHdyaXRpbmcgYSBQRVJMIG1vZHVsZSB0byByZXRyaWV2ZSBzdG9jayBxdW90ZXMgZnJvbSB0
aGUgdmFyaW91cyANCnF1b3RlIGVuZ2luZXMgb24gdGhlIHdlYi4gSSd2ZSBtYW5hZ2VkIHRvIGZp
bmQgb25lIFVSTCB0aGF0IHdpbGwgDQpyZXR1cm4gYSBzdG9jayBxdW90ZSBmcm9tIHRoZSBZYWhv
byBzZXJ2ZXIgaW4gY29tbWEgc2VwYXJhdGVkDQp2YWx1ZSBmb3JtYXQgKCJodHRwOi8vcXVvdGUu
eWFob28uY29tL2QvcXVvdGVzLmNzdj9zPSRzeW1ib2wmZj1zbDFkMXQxYzFvaGd2ajFwcDJvd2Vy
biZlPS5jc3YiKSANCkRvZXMgYW55Ym9keSBrbm93IG9mIGFueSBvdGhlciBVUkxzIHRoYXQgd2ls
bCBkbyB0aGUgc2FtZSwgbGlrZSANCmZvciBleGNpdGUsIG9yIEluZm9zZWVrIG9yIG90aGVycz8N
Cg==
------------------------------
Date: Wed, 15 Sep 1999 11:07:52 +0200
From: Daniel Krajzewicz <krajzewicz@inx.de>
To: Daniel Krajzewicz <krajzewicz@inx.de>
Subject: Subroutnes definitions with explicit declarations
Message-Id: <37DF61E8.CC35F335@inx.de>
Hello !!!
I want to write subprocedures in modules which I can use in this way :
$variable = my_proc($attr1)
When setting up the module, I do export the procedures name only :
@EXPORT = qw(my_proc);
Further
--
__________________________
< Daniel Krajzewicz >
>------------------------<
< krajzewicz@inx.de >
>------------------------<
< http://www.art-so-far.de >
>------------------------<
<__________________________>
------------------------------
Date: Wed, 15 Sep 1999 05:32:38 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Templates
Message-Id: <Pine.GSO.4.10.9909150527130.25903-100000@user2.teleport.com>
On Sun, 12 Sep 1999, Marc wrote:
> I'm having problems with my template subroutine I created. It doesn't parse
> anything.
> $text =~ s{ $begin_tag\s*if\s*(.+)?\s*$end_tag/s*(.+)/s*
> $begin\s*endif\s*$end }
> Maybe it's my regex match (wouldn't suprise me since I don't use regex too
> much beyond basics).
Looks likely. Remember that whitespace is significant in patterns. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 15 Sep 1999 13:52:53 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Templates
Message-Id: <VwND3.12469$N77.927352@typ11.nn.bcandid.com>
In article <7rggsi$rrb$1@winter.news.rcn.net>,
Marc <marc@infinityinternet.com> wrote:
> $text =~ s{ $begin_tag\s*if\s*(.+)?\s*$end_tag/s*(.+)/s*
>$begin\s*endif\s*$end }
> exists $fillings->{$1} ?
> "$2" :
> "" ;
> }gsi;
Several things. you have a newline in your regex (at least as posted)
and so it won't match strings without a newline at that position. You
have whitespace at the beginning and end of the regex; so it needs
whitespace to match. (You can turn these off with the x modifier.) You
have no opening delimiter for the replacement; perl should barf when
you try to run this script. (Or maybe it should decide that 'e' is the
delimiter. I'm too lazy to try it at the moment.) And you need the
'e' modifier for the replacement to be interpreted as an expression
instead of a string.
Your problem may be something else entirely; I haven't read the regex
thoroughly. Oh, you're trying to match /s in a few places; maybe you
mean \s?
Kragen
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 15 Sep 1999 17:29:34 GMT
From: hoz@rocketmail.com (hoz)
Subject: Re: trimming spaces from a string
Message-Id: <37dfd6e4.6215925@news.netvision.net.il>
to trim spaces from a string try:
$string =~ s/\s//g;
-hoz
------------------------------
Date: Wed, 15 Sep 1999 12:11:26 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: trimming spaces from a string
Message-Id: <slrn7tv1d2.1pj.*@dragons.duesouth.net>
On Wed, 15 Sep 1999 17:29:34 GMT, hoz@rocketmail.com (hoz) spewed forth:
: to trim spaces from a string try:
: $string =~ s/\s//g;
This is, in the current regex implementation, less efficient than
necessary. A simple change:
s/\s+//g
does wonders.
The fastest solution is, by far, using tr:
tr[ \n\r\f\b][]d;
but that relies on you remembering exactly what \s stands for (more than
what I listed, IIRC).
I tend to use s///g for that reason. Also, I worry about optimizations
AFTER my code is written. More often than not, I find s////g vs tr///
optimizations don't matter. When they do, I use tr///.
HTH,
: -hoz
--Matthew
------------------------------
Date: 15 Sep 1999 08:44:59 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: trimming spaces from a string
Message-Id: <slrn7tv56a.g1t.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote :
# #Given:
#
# $s=' aa bcdef ';
# $t='aa bcdef';
if($s =~ /^\s*$t\s*$/ || $t =~ /^\s*$s\s*$/) {
print "match\n";
}
# # I'd like them to match.
# # That is, I want to match as though leading and and trailing spaces were
# removed.
# # For example:
#
# if ( $s eq $t) { # This of course needs help
# print "They match.\n";
# }else{
# print "They don't match.\n";
# }
------------------------------
Date: Wed, 15 Sep 1999 05:55:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: trimming spaces from a string
Message-Id: <MPG.1249371fba61d95a989f65@nntp.hpl.hp.com>
In article <slrn7tv1d2.1pj.*@dragons.duesouth.net> on Wed, 15 Sep 1999
12:11:26 GMT, Matthew Bafford <*@dragons.duesouth.net> says...
...
> The fastest solution is, by far, using tr:
>
> tr[ \n\r\f\b][]d;
>
> but that relies on you remembering exactly what \s stands for (more than
> what I listed, IIRC).
Not more; more and less.
tr[ \n\r\f\t][]d;
Tab is (obviously) a white-space character. Backspace is (less
obviously?) not.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 15 Sep 1999 06:31:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: trimming spaces from a string
Message-Id: <MPG.12493fa21faab6ef989f66@nntp.hpl.hp.com>
In article <slrn7tv56a.g1t.gabor@vnode.vmunix.com> on 15 Sep 1999
08:44:59 -0400, Gabor <gabor@vmunix.com> says...
> In comp.lang.perl.misc, Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote :
> # #Given:
> #
> # $s=' aa bcdef ';
> # $t='aa bcdef';
>
> if($s =~ /^\s*$t\s*$/ || $t =~ /^\s*$s\s*$/) {
> print "match\n";
> }
This is wrong in several ways. It fails if $s and $t each have leading
or trailing white-space, or if either of them includes a regex
metacharacter. Think twice before substituting a variable into a regex
without surrounding it with \Q and \E.
my ($s0, $t0) = ($s =~ /^\s*((?:.*\S)?)/s, $t =~ /^\s*((?:.*\S)?)/s);
if ($s0 eq $t0) { print "match\n" }
(The elaborate stuff is to handle strings of white-space only. I'd be
glad to see a cleaner way to do it in one regex.)
Here it is all in one 'line', using another list-context trick:
print "match\n" if
($s =~ /^\s*((?:.*\S)?)/s)[0] eq ($t =~ /^\s*((?:.*\S)?)/s)[0];
> # # I'd like them to match.
> # # That is, I want to match as though leading and and trailing spaces were
> # removed.
The two sample strings won't match, because the interior spaces don't
match. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 15 Sep 1999 14:43:59 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: trimming spaces from a string
Message-Id: <slrn7tva2g.283.*@dragons.duesouth.net>
On Wed, 15 Sep 1999 05:55:50 -0700, Larry Rosler) cut a telephone line,
and tapped the following to comp.lang.perl.misc using only his tongue:
: > tr[ \n\r\f\b][]d;
:
: tr[ \n\r\f\t][]d;
:
: Tab is (obviously) a white-space character. Backspace is (less
: obviously?) not.
And thus Larry proves my point. ;-)
--Matthew
------------------------------
Date: 15 Sep 1999 11:44:06 -0400
From: gabor@vmunix.com (Gabor)
Subject: Re: trimming spaces from a string
Message-Id: <slrn7tvfm6.gtr.gabor@vnode.vmunix.com>
In comp.lang.perl.misc, Larry Rosler <lr@hpl.hp.com> wrote :
# In article <slrn7tv56a.g1t.gabor@vnode.vmunix.com> on 15 Sep 1999
# 08:44:59 -0400, Gabor <gabor@vmunix.com> says...
# > In comp.lang.perl.misc, Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote :
# > # #Given:
# > #
# > # $s=' aa bcdef ';
# > # $t='aa bcdef';
# >
# > if($s =~ /^\s*$t\s*$/ || $t =~ /^\s*$s\s*$/) {
# > print "match\n";
# > }
#
# This is wrong in several ways. It fails if $s and $t each have leading
# or trailing white-space, or if either of them includes a regex
# metacharacter. Think twice before substituting a variable into a regex
# without surrounding it with \Q and \E.
I wasn't trying to give a fool-proof solution but a start. ;)
------------------------------
Date: Wed, 15 Sep 1999 12:07:17 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: Unix and Perl script
Message-Id: <37DF6FD5.F03A7ED1@ife.ee.ethz.ch>
Jonel Rienton wrote:
> i don't know what exactly you're trying to accomplish, the way i understand
> it, here's a one-liner.
>
> perl -wle '@_=qx(ls /usr/bin);open(A,">files.lst");foreach(@_){chomp;print
> A};close(A)'
Fascinating, Mr. Jeopardist. Does it do about the same as
ls /usr/bin | cat >files.lst ?
> Trevor Osatchuk <fybar@junctionnet.com> wrote in message
> news:37dee0b6.441742882@news.telusplanet.net...
> > I am trying to write a backup script for a Unix machine using Perl as
> > I can only pass a finite number of filenames to a tar at a time.
Computers are Finite State Machines. By definition, you cannot use an
infinite number of anything in a computer.
> > The
> > Unix command that I want to use is:
> >
> > find ./usr -name "bin" -print > files.list
This looks below $PWD/usr for all files or directories named "bin". Is
this what you want?
> > The best I can come up with is this:
> >
> > open (FILES_LIST,"|find ./usr -name "bin" -print >files.list");
Why open a file? find is not interested in stdin, so piping stuff to it
is no use.
I suggest you read the documentation to find, tar and perl and come back
with a Perl question
- Alex
------------------------------
Date: Wed, 15 Sep 1999 07:42:21 -0400
From: "Peter Icaza" <picaza@chsi.com>
Subject: Use of uninitialized value at...
Message-Id: <7ro0m4$4r1c$1@pike.uhc.com>
hi,
i reading a file into a string and then extract the different sections using
the following code. however i cant seem to rid myself of the error msg "Use
of uninitialized value at... " at the first attempt to match once all
sections are parsed and split has nothing to put in to $Section. the two
commented if stmts are some attempts at correcting the situation which dont
work. i ask two things 1) how can i correct the code to get rid of the
error msg and 2) why dont the "defined" and/or "ne" work properly while the
print stmt works ok?
use strict;
...
while (($Stars, $Section, $remainder) = split(/\n/, $remainder, 3))
{
print "junk= <$Stars> section= <$Section>\n\r";
# if (defined ($Section))
# if ($Section ne "")
{
if ($Section =~ m/one ?/) # error occurs here
{...}
elsif ($Section =~ m/two ?/)
{...}
elsif ($Section =~ m/three ?/)
{...}
elsif ($Section =~ m/four ?/)
{...}
}
}
the print gives me:
junk= < > section= <one>
junk= < > section= <two>
junk= < > section= <three>
junk= < > section= <four>
junk= < > section= <>
------------------------------
Date: 15 Sep 1999 08:52:30 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: XML as database ?
Message-Id: <7rnmoe$ho2@dfw-ixnews19.ix.netcom.com>
lrkwz (luca.orlandi@inferentia.it) wrote:
: I which to write a script which gets input from a form via $cgi->param
: (I've plaied with CGI::XMLForm and seems to do his job fine) and write
: into an XML file appending news nodes.
:
: XML::DOM seems quite hard to deal with ... any suggestions?
XML::DOM is, imho, overkill for simply tacking some new elements on to the
"end" (it can't really be the end, as well-formed XML has only one "outer"
element per document) of an XML document. The way I'd do it would be to
open a new file for output, create an XML::Parser object with only the
default() and end() handlers set, and parse the original file. The
default() handler would simply invoke the Expat object's original_string()
method to grab the string in its original encoding and print it to the
new file. The end() handler would check to see if it had gotten the
ending tag for the "outer" element. If so, it would print out the new
piece of XML. In any case, it would also print out the result of
original_string. I would strongly *not* recommend simply reading through
the original file and doing a string compare or regex match for the end
tag of the outer element; that introduces a bunch of subtle dependencies
that you don't need.
All that said, you should question *why* you want to use XML as a storage
format here. Are you going to be processing the entire file using
XML-oriented tools? If not, consider using a conventional database and
storing the XML fragments as snippets. XML is a great way of
transporting data between programs, but it's a mediocre-to-very-bad way
of storing large volumes of data.
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
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 804
*************************************