[13656] in Perl-Users-Digest
Perl-Users Digest, Issue: 1066 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 14:57:03 1999
Date: Fri, 15 Oct 1999 11:56:45 -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: <940013804-v9-i1066@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 15 Oct 1999 Volume: 9 Number: 1066
Today's topics:
I need a regex to transform '<' into '<' for example <rodrigo_roman@usa.net>
Re: I need a regex to transform '<' into '<' for exa (Mark Badolato)
Re: I need a regex to transform '<' into '<' for exa (Abigail)
Re: Ignore this, just testing to see if it works. <cox@will.go>
Inputing a scalar while using a string as terminator jtgr8guy@my-deja.com
Re: Inputing a scalar while using a string as terminato <msalter@bestweb.net>
Re: Inputing a scalar while using a string as terminato (Craig Berry)
Re: Inputing a scalar while using a string as terminato (Larry Rosler)
inputting variables into a perlscript from command prom (Russell Parker)
Re: inputting variables into a perlscript from command (Brett W. McCoy)
Re: inputting variables into a perlscript from command (Gordon)
Re: Installing Fly on remote server <nik@cheddarcheese.de>
Re: installing perl WITHOUT a shared library? (Abigail)
IPC::Open2 mystery <occitan@esperanto.org>
Re: Is replace a string possible? (Abigail)
Re: Is replace a string possible? <skilchen@swissonline.ch>
Re: Is replace a string possible? (Anno Siegel)
Re: Is replace a string possible? <ltl@rgsun5.viasystems.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 Oct 1999 22:13:41 GMT
From: Rodrigo <rodrigo_roman@usa.net>
Subject: I need a regex to transform '<' into '<' for example...
Message-Id: <s0clclf8hu236@corp.supernews.com>
To display the content of a field in may database in that has html tags
embeded.
Any help will be apreciated.
I'm a real new perl programmer, tried some regex but I cannot make it
work...
I've tried something like
$txt=~ s/</\<\;/g;
but doesn't work :-(
ATTE RR
------------------ Posted via CNET Help.com ------------------
http://www.help.com/
------------------------------
Date: 14 Oct 1999 22:42:32 GMT
From: mbadolato@quepasa.com (Mark Badolato)
Subject: Re: I need a regex to transform '<' into '<' for example...
Message-Id: <36447.655701753F17mbadolatoquepasacom@4.22.39.123>
On 14 Oct 1999, rodrigo_roman@usa.net (Rodrigo) wrote in
<s0clclf8hu236@corp.supernews.com>:
> To display the content of a field in may database in that has html tags
>embeded.
>
>I've tried something like
>
>$txt=~ s/</\<\;/g;
>
>but doesn't work :-(
>
Works just fine. What is happening when you try?
Also, you may want to look into CGI.pm's autoEscape() function.
--Mark
------------------------------
Date: 14 Oct 1999 22:33:38 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: I need a regex to transform '<' into '<' for example...
Message-Id: <slrn80d842.q8s.abigail@alexandra.delanet.com>
Rodrigo (rodrigo_roman@usa.net) wrote on MMCCXXXV September MCMXCIII in
<URL:news:s0clclf8hu236@corp.supernews.com>:
--
-- I've tried something like
--
-- $txt=~ s/</\<\;/g;
--
-- but doesn't work :-(
Ah, it doesn't work. Very informative.
Try for once not serving seafood.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 14 Oct 1999 11:16:01 GMT
From: "Cox" <cox@will.go>
Subject: Re: Ignore this, just testing to see if it works.
Message-Id: <RXiN3.12059$up3.13687@news21.bellglobal.com>
alt.test
alt.alt.test
quan
CS <@mdo.net> wrote in message
news:9CHK3.1703$eM4.135434@typ11.nn.bcandid.com...
> blah
>
>
------------------------------
Date: Wed, 13 Oct 1999 17:37:40 GMT
From: jtgr8guy@my-deja.com
Subject: Inputing a scalar while using a string as terminator
Message-Id: <7u2g13$1gf$1@nnrp1.deja.com>
Hi there,
I have two questions if anyone feels like they can help me out. Thanx
in advance!
1. I have this text line:
2:30:16 PM MS Works 4.0 Test Passed !
*
I need to store "MS Works 4.0" into a scalar, $app. $app could be a
variety of diff. applications. I also need to store "Passed" or
"Failed" into a scalar, $result. This is what I have so far:
if (m/^\d+\s*:\s*\d+\s*:\s*\d+\s*[A-Z]\s+/){#search for the time
--> #How do I start storing "MS Works 4.0" into $app from this point
#on until "Test", which will be my terminator????
#I will then match "Test" and store either "Passed" or
#"Failed" into $result.
if (m/Test\s+/) {
if (m/(Passed)/s*)
$result=$1;
else if (m/(Failed)/s*)
$result=$1;
}
}
2. Also, would anybody suggest a better loop construct besides using a
bunch of if statements within a while loop with next; at the end of
each if statement. Once I find a condition, I want to skip the rest of
the while loop and go to the next line to recheck all my if statements
again. Would a switch statement be better? I don't seem to find any
docs containing writing switch statement in perl.
Once again, thank you for any and all help :)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Oct 1999 18:41:17 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: Inputing a scalar while using a string as terminator
Message-Id: <Pine.BSF.4.05.9910131447200.3746-100000@monet.bestweb.net>
On Wed, 13 Oct 1999 jtgr8guy@my-deja.com wrote:
>Date: Wed, 13 Oct 1999 17:37:40 GMT
>From: jtgr8guy@my-deja.com
>Newsgroups: comp.lang.perl.misc
>Subject: Inputing a scalar while using a string as terminator
>
>Hi there,
>I have two questions if anyone feels like they can help me out. Thanx
>in advance!
>
>1. I have this text line:
>
>2:30:16 PM MS Works 4.0 Test Passed !
>*
>
>I need to store "MS Works 4.0" into a scalar, $app. $app could be a
>variety of diff. applications. I also need to store "Passed" or
>"Failed" into a scalar, $result. This is what I have so far:
>
>if (m/^\d+\s*:\s*\d+\s*:\s*\d+\s*[A-Z]\s+/){#search for the time
> --> #How do I start storing "MS Works 4.0" into $app from this point
> #on until "Test", which will be my terminator????
>
> #I will then match "Test" and store either "Passed" or
> #"Failed" into $result.
> if (m/Test\s+/) {
> if (m/(Passed)/s*)
> $result=$1;
> else if (m/(Failed)/s*)
> $result=$1;
> }
>}
Try this:
$_ = "2:30:16 PM MS Works 4.0 Test Passed !";
if(/\d+:\d+:\d+\s+[PA]M\s+(.+)Test\s+(\w+)/i) {
$app = $1;
$result = $2;
}
>
>2. Also, would anybody suggest a better loop construct besides using a
>bunch of if statements within a while loop with next; at the end of
>each if statement. Once I find a condition, I want to skip the rest of
>the while loop and go to the next line to recheck all my if statements
>again. Would a switch statement be better? I don't seem to find any
>docs containing writing switch statement in perl.
>Once again, thank you for any and all help :)
>
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.
>
>
------------------------------
Date: Wed, 13 Oct 1999 20:11:57 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Inputing a scalar while using a string as terminator
Message-Id: <s09psd9ubhk6@corp.supernews.com>
jtgr8guy@my-deja.com wrote:
: I have two questions if anyone feels like they can help me out. Thanx
: in advance!
:
: 1. I have this text line:
:
: 2:30:16 PM MS Works 4.0 Test Passed !
:
: I need to store "MS Works 4.0" into a scalar, $app. $app could be a
: variety of diff. applications. I also need to store "Passed" or
: "Failed" into a scalar, $result.
If it always looks just like that -- a chunk of non-whitespace time,
space, AM/PM, more spaces, app name, more spaces, (Passed|Failed), space,
bang -- here's how I'd do it, assuming the line is in $_:
my ($app, $result) = m/^
\S+ # The (h)h:mm:ss part
\s
[AP]M # AM or PM
\s+
(.*?) # App name
\s+
Test
\s+
(Passed|Failed) # Result
\s
!
$/x;
The non-greedy match is needed to keep any spaces beyond 1 following the
app name from being absorbed as part of the app name.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Wed, 13 Oct 1999 12:07:40 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Inputing a scalar while using a string as terminator
Message-Id: <MPG.126e785b8d9bb7a898a08b@nntp.hpl.hp.com>
In article <7u2g13$1gf$1@nnrp1.deja.com> on Wed, 13 Oct 1999 17:37:40
GMT, jtgr8guy@my-deja.com <jtgr8guy@my-deja.com> says...
> I have two questions if anyone feels like they can help me out. Thanx
> in advance!
Two unrelated questions should be ubmitted as separate posts.
> 1. I have this text line:
>
> 2:30:16 PM MS Works 4.0 Test Passed !
> *
>
> I need to store "MS Works 4.0" into a scalar, $app. $app could be a
> variety of diff. applications. I also need to store "Passed" or
> "Failed" into a scalar, $result. This is what I have so far:
>
> if (m/^\d+\s*:\s*\d+\s*:\s*\d+\s*[A-Z]\s+/){#search for the time
^
+
...
#!/usr/local/bin/perl -w
use strict;
$_ = '2:30:16 PM MS Works 4.0 Test Passed !';
my ($app, $result) =
/^\d+\s*:\s*\d+\s*:\s*\d+\s*[A-Z]+\s+(.+?)\s+Test\s+(\S+)/;
print "\$app = |$app| \$result = |$result|\n" if $app;
> 2. Also, would anybody suggest a better loop construct besides using a
> bunch of if statements within a while loop with next; at the end of
> each if statement. Once I find a condition, I want to skip the rest of
> the while loop and go to the next line to recheck all my if statements
> again.
What's wrong with using 'next'? That seems like the normal way to do
it. Another way is to use 'elsif' for all but the first test.
> Would a switch statement be better? I don't seem to find any
> docs containing writing switch statement in perl.
perlfaq7: "How do I create a switch or case statement?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 14 Oct 1999 16:48:05 +0100
From: r@asd.com (Russell Parker)
Subject: inputting variables into a perlscript from command prompt.
Message-Id: <MPG.12700b946f80b2b8989681@news.virgin.net>
I have a script which will run when a specific event occurs on HP
OpenView.
The script name could be event1.pl (for the sake of arguments).
When the event occurs, information is available for displaying or
printing, the amount of data specified by $x, $X, $A, $* etc.
What I am trying to do, is to use this information in a Perl script but
am not sure how to do it.
I understand how to pass arguments through subroutines, but am not sure
if this is the way forward.
I have a DOS batch file that does a similar thing and is basically called
by the event;
event1.bat $x $X $A etc ($x is Date, $X is Time, $A is name of node).
event1.bat puts these values into a text log file.
I would like to do the same with Perl. later, I will want to manipulate
the information further, hence the reason for not sticking to the DOS
version.
Anybody help.
Thanks in advance.
------------------------------
Date: Thu, 14 Oct 1999 16:01:35 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: inputting variables into a perlscript from command prompt.
Message-Id: <slrn80bvr0.ng.bmccoy@moebius.foiservices.com>
Also Sprach Russell Parker <r@asd.com>:
>I have a script which will run when a specific event occurs on HP
>OpenView.
>
>The script name could be event1.pl (for the sake of arguments).
>
>When the event occurs, information is available for displaying or
>printing, the amount of data specified by $x, $X, $A, $* etc.
>
>What I am trying to do, is to use this information in a Perl script but
>am not sure how to do it.
>I understand how to pass arguments through subroutines, but am not sure
>if this is the way forward.
perldoc Getopt::Long
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: 14 Oct 1999 17:43:23 GMT
From: nospam@today.com (Gordon)
Subject: Re: inputting variables into a perlscript from command prompt.
Message-Id: <36447.444900764BC1justooltries@4.22.39.85>
r@asd.com (Russell Parker) wrote in
<MPG.12700b946f80b2b8989681@news.virgin.net>:
>I have a DOS batch file that does a similar thing and is basically called
>by the event;
>
>event1.bat $x $X $A etc ($x is Date, $X is Time, $A is name of node).
>
>event1.bat puts these values into a text log file.
>
>I would like to do the same with Perl. later, I will want to manipulate
>the information further, hence the reason for not sticking to the DOS
>version.
Try playing around with @ARGV
and read perldoc perlvar for many other wonderful variables:)
-- Gordon --
------------------------------
Date: Fri, 15 Oct 1999 17:53:03 +0200
From: Nik Gare <nik@cheddarcheese.de>
Subject: Re: Installing Fly on remote server
Message-Id: <495173d535nik@pop.onlinehome.de>
In article <7tt7n3$ol5@masters0.InterNex.Net>,
ages <ages@stones.com> wrote:
> >Alternatively, is there an 'Installing Fly on webprovider's server for
> >dummies' type page somewhere on the web?
> http://www.unimelb.edu.au/fly/
Oops, forgot to say thanks for the info.
Thanks for the info.
TTFN
Nik
--
nik@cheddarcheese.de
http://www.cheddarcheese.webprovider.com
Occasional interactive software list
* alternative desktop & Pluto sprites
- updated for version 1.13a
------------------------------
Date: 13 Oct 1999 14:41:03 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: installing perl WITHOUT a shared library?
Message-Id: <slrn809o20.nk2.abigail@alexandra.delanet.com>
omar abou deif (aboudeif@pixelpark.com) wrote on MMCCXXXIV September
MCMXCIII in <URL:news:3804B183.C3495544@pixelpark.com>:
{} dear newsgroup,
{}
{} I am new to perl installing. I would like to install perl explicitly
{} without
{} building a shared library (=libperl.so), instead i want a static one
{} (=libperl.a).
{} what is the command line switch for this?
Building a static perl is the default.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 13 Oct 1999 21:05:02 GMT
From: Daniel Pfeiffer <occitan@esperanto.org>
Subject: IPC::Open2 mystery
Message-Id: <7u2s5j$b7e$1@nnrp1.deja.com>
Saluton retanoj!
I am trying to spawn a remote copy of myself in slave mode (hence the -s
option). I want STDIN and STDOUT of these two processes to be coupled
(with a well defined dialogue), i.e. the idea of
open SLAVE, "| rsh $Partner $0 -s |";
Alas I'm not sure I understand the rather skimpy documentation of
IPC::Open2, but I've tried
open2 *STDIN, *STDOUT, 'rsh', $Partner, $0, '-s';
open2 *STDOUT, *STDIN, 'rsh', $Partner, $0, '-s';
open2 '<&STDIN', '>&STDOUT', 'rsh', $Partner, $0, '-s';
My wish is that the programme simply alternate between print and <>
operations, and the remote slave do the same, but starting with a <>.
But while the third open2 doesn't create pipes, the first two both leave
me with an unreadable STDIN. How am I to do this?
Whatever the correct method may be, I have a weirder probably unrelated
problem yet: The child process forked of by open2 seems incapable of
exec`ing rsh! In strace, when exec finally finds the right directory in
$PATH, I see
[pid 19262] execve("/usr/bin/rsh", ["rsh", "trobador",
"/home/pfeiffer/bin/abgleich", "-s"], [/* 64 vars */]) = -1 EPERM
(Operation not permitted)
When I enter /usr/bin/rsh trobador /home/pfeiffer/bin/abgleich -s from
the same shell that starts the skript, it works!
Thanks in advance for any tips!
Daniel
This is SuSE Linux 6.2 (2.2.10, glibc 2.1) on both sides.
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=linux, osvers=2.2.10, archname=i586-linux
uname='linux fatou 2.2.10 #2 smp thu jul 15 15:03:02 mest 1999 i686
unknown '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O2 -pipe', gccversion=egcs-2.91.66
19990314/Linux (egcs-1.1.2 release)
cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
stdchar='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='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under linux
Compiled at Jul 22 1999 21:20:02
@INC:
/usr/lib/perl5/5.00503/i586-linux
/usr/lib/perl5/5.00503
/usr/lib/perl5/site_perl/5.005/i586-linux
/usr/lib/perl5/site_perl/5.005
.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 12 Oct 1999 17:13:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Is replace a string possible?
Message-Id: <slrn807cj9.gep.abigail@alexandra.delanet.com>
Otto van Rijswijk (ovr.nospam@solcon.nl) wrote on MMCCXXXIII September
MCMXCIII in <URL:news:7tvehs$7g1$1@news.solcon.nl>:
\\ Hello,
\\
\\ I have question. I have the line below:
\\
\\ "001:002397","B00:32478","beckman2","solcon.net","US,Montreal,CA","1999-Jun-
\\ 19 12:00:33"
\\
\\ The quoted strings should be 6 different variables.
[ Silly, not working solution snipped ]
\\ Please, please, is there such a command in Perl?
Yes. It's in the FAQ. But here's an alternative solution, using
Parse::RecDescent:
#!/opt/perl/bin/perl -w
use strict;
use Parse::RecDescent;
my $parser = Parse::RecDescent -> new (<<'EOG') or die "Compilation error!\n";
start: <skip: "">
<leftop: value ',' value>
value: /"(?:[^"\\]+|\\.)*"/ {my $str = substr $item [1], 1, -1;
$str =~ s/\\(.)/$1/g; $str}
| /'(?:[^'\\]+|\\.)*'/ {my $str = substr $item [1], 1, -1;
$str =~ s/\\(.)/$1/g; $str}
| /[^,]*/
EOG
while (<DATA>) {
chomp;
print "[ ", join ("\n " => @{$parser -> start ($_)}), "\n]\n";
}
__DATA__
one,two,three
"one",'two', three,"four,five"
one,,,,'two,three',,
"one\"two",three
While will produce:
[ one
two
three
]
[ one
two
three
four,five
]
[ one
two,three
]
[ one"two
three
]
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 13 Oct 1999 06:00:05 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Is replace a string possible?
Message-Id: <FdVM3.23978$m4.87993043@news.magma.ca>
Abigail <abigail@delanet.com> schrieb in im Newsbeitrag:
slrn807cj9.gep.abigail@alexandra.delanet.com...
> Otto van Rijswijk (ovr.nospam@solcon.nl) wrote on MMCCXXXIII September
> MCMXCIII in <URL:news:7tvehs$7g1$1@news.solcon.nl>:
> \\ Hello,
> \\
> \\ I have question. I have the line below:
> \\
> \\ "001:002397","B00:32478","beckman2","solcon.net","US,Montreal,CA",
> \\ "1999-Jun-19 12:00:33"
> \\
> \\ The quoted strings should be 6 different variables.
>
> [ Silly, not working solution snipped ]
>
> \\ Please, please, is there such a command in Perl?
>
> Yes. It's in the FAQ. But here's an alternative solution, using
> Parse::RecDescent:
>
Which is another nice example how to use this module, but its
andvantages compared to the solution in perlfaq4 probably don't justify
the loss of speed.
The module Text::CSV_XS is another alternative if the data format
corresponds to a commonly used definition of the CSV format. An example
of Text::CSV_XS in action:
#!/wherever/perl -w
use strict;
use Text::CSV_XS;
my $csv = Text::CSV_XS->new({ binary => 1 });
my $buffer = "";
my $status = undef;
my $rec_count = 0;
while(<DATA>) {
$buffer .= $_;
$status = $csv->parse($buffer);
if ($status) {
display_record(++$rec_count, $csv->fields());
$buffer = "";
}
}
if (not $status) {
my $err = $csv->error_input();
print "parse CSV failed at:\n", $err, "\n";
}
sub display_record {
my $rec_count = shift;
my @fields = @_;
my $field_count = 0;
print "Record: $rec_count [\n";
foreach my $field (@fields) {
print "Field: ", ++$field_count, " = ", $field, "\n";
}
print "] $rec_count\n";
}
__DATA__
one,two,three
"one",'two', three,"four,five"
one,,,,'two,three',,
"one""two",three
"one""
two",three four, five
six,"seven, eight",
"001:002397","B00:32478","beckman2","solcon.net","US,Montreal,CA","1999-
Jun-19 12:00:33"
------------------------------
Date: 13 Oct 1999 11:15:39 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is replace a string possible?
Message-Id: <7u1pkr$akl$1@lublin.zrz.tu-berlin.de>
Alex Rhomberg <rhomberg@ife.ee.ethz.ch> wrote in comp.lang.perl.misc:
>Otto van Rijswijk wrote:
>>
>> Hello,
>>
>> I have question. I have the line below:
>>
>> "001:002397","B00:32478","beckman2","solcon.net","US,Montreal,CA","1999-Jun-
>> 19 12:00:33"
>>
>> The quoted strings should be 6 different variables. I solved it by deleting
>> character " by:
>> tr/"//d
>> The second step is:
>> tr/,/#/
>> The third and last step is:
>> (...$var...) = split /#/, $line
>
>Your best off with reading perlfaq4.
>You'll find the general answer with
>perldoc -q split
>
>In your special case, you could also split on ",":
>@fields = split /","/ $line
>split splits on a regular expression. You need to read the documentation
>of split and in perlre
Even if the suggested split would work (see below) you'd need to explain
how it would help in Otto's case. I don't see how.
>> I'm searching for something like:
>>
>> tr/","/#/
>
>The command
>s/","/#/ does this. but it is not needed in your case. See perlop for
>s///
Yes, please see perlop for s///. And *test* your replies before posting
them.
The tr/// operator is quite adequate, but the quotes around the comma
are superfluous and will make it do more than required (making it
translate double-quotes to hashmarks as well.
They are equally superfluous in your regex, only making it do less
than required. Get rid of them, and add the /g option to make it
work like tr/,/#/.
Please *think* a bit about your suggestions. What you posted is
absolutely useless. Worse, it needs cleaning up after it.
Anno
------------------------------
Date: 13 Oct 1999 15:28:51 GMT
From: lt lindley <ltl@rgsun5.viasystems.com>
Subject: Re: Is replace a string possible?
Message-Id: <7u28fj$12a$1@rguxd.viasystems.com>
Samuel Kilchenmann <skilchen@swissonline.ch> wrote:
:>Abigail <abigail@delanet.com> schrieb in im Newsbeitrag:
:>> Yes. It's in the FAQ. But here's an alternative solution, using
:>> Parse::RecDescent:
:>>
:>Which is another nice example how to use this module, but its
:>andvantages compared to the solution in perlfaq4 probably don't justify
:>the loss of speed.
Unless you appreciate elegance.
:>The module Text::CSV_XS is another alternative if the data format
:>corresponds to a commonly used definition of the CSV format. An example
:>of Text::CSV_XS in action:
Ruthless efficiency.
Hmm. Torn between two desires.
Meanwhile, the files I read are not too big and I'm lazy so I just
use Text::ParseWords and don't worry about it much.
--
// Lee.Lindley /// I used to think that being right was everything.
// @bigfoot.com /// Then I matured into the realization that getting
//////////////////// along was more important. Except on usenet.
------------------------------
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 1066
**************************************