[23284] in Perl-Users-Digest
Perl-Users Digest, Issue: 5504 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 15 09:05:46 2003
Date: Mon, 15 Sep 2003 06:05:13 -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 Mon, 15 Sep 2003 Volume: 10 Number: 5504
Today's topics:
Re: closed filehandle <samj@austarmetro.com.au>
Re: closed filehandle <me@privacy.net>
Re: closed filehandle (Anno Siegel)
Re: closed filehandle <jurgenex@hotmail.com>
Re: Converting pdf to text (Chandramohan Neelakantan)
Re: dbm problem HELP! <tom@nosleep.net>
Forking Server (SRam)
Re: Modifying a HP/GL2 output file using Perl (Anno Siegel)
Need help on split-function <mijn_postbak@msn.com>
Re: Need help on split-function <usenet@NOSPAM.matthewb.org>
Re: Need help on split-function <mijn_postbak@msn.com>
Re: Need help on split-function <thens@NOSPAMti.com>
Re: Need help on split-function <jurgenex@hotmail.com>
Re: Need help on split-function <mijn_postbak@msn.com>
Re: Need help on split-function (Helgi Briem)
Problem with xml parser (debraj)
Re: readline() on closed fielhandle? <geoff.cox@blueyonder.co.uk>
Re: readline() on closed fielhandle? <geoff.cox@blueyonder.co.uk>
Regular expressions and parenthesis in match text <oh-god-please-dont-spam-me@hotmail.com>
Re: Regular expressions and parenthesis in match text <me@privacy.net>
Re: Regular expressions and parenthesis in match text <oh-god-please-dont-spam-me@hotmail.com>
Re: Send email using Perl <bzhaoa@yahoo.com.cn>
Re: Send email using Perl (Sam Holden)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 15 Sep 2003 07:23:13 GMT
From: "Sam" <samj@austarmetro.com.au>
Subject: Re: closed filehandle
Message-Id: <3f6568df$1@news.comindico.com.au>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:tcc9b.9890$1D5.4139@nwrddc02.gnilink.net...
> Sam wrote:
> > the file name is avg and it is located at /home/<username>/data
> > directory
>
> Then why are you trying to open
> home/user/data/avg
> instead of
> /home/user/data/avg
>
> Or did you make sure that your CWD is the root directory?
> At least I didn't see any code for that anywhere in your previous code
> samples.
>
> jue
>
>
I really need help to understand this. as I have been reading, you need a
file handler (DATA) attach to it the file name and pass that to the sub open
inorder to read the file's line by line in the variable $_. what I am
missing?
------------------------------
Date: Mon, 15 Sep 2003 20:44:20 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: closed filehandle
Message-Id: <bk3u2l$n3ch2$1@ID-172104.news.uni-berlin.de>
"Sam" <samj@austarmetro.com.au> wrote in message
news:3f6568df$1@news.comindico.com.au...
>
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:tcc9b.9890$1D5.4139@nwrddc02.gnilink.net...
> > Sam wrote:
> > > the file name is avg and it is located at /home/<username>/data
> > > directory
> >
> > Then why are you trying to open
> > home/user/data/avg
> > instead of
> > /home/user/data/avg
> >
> > Or did you make sure that your CWD is the root directory?
> > At least I didn't see any code for that anywhere in your previous code
> > samples.
> >
> > jue
> >
> >
>
> I really need help to understand this. as I have been reading, you need a
> file handler (DATA) attach to it the file name and pass that to the sub
open
> inorder to read the file's line by line in the variable $_. what I am
> missing?
The correct path to the file.
------------------------------
Date: 15 Sep 2003 09:20:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: closed filehandle
Message-Id: <bk409e$hg2$1@mamenchi.zrz.TU-Berlin.DE>
Tintin <me@privacy.net> wrote in comp.lang.perl.misc:
>
> "Sam" <samj@austarmetro.com.au> wrote in message
> news:3f6568df$1@news.comindico.com.au...
> >
> > "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> > news:tcc9b.9890$1D5.4139@nwrddc02.gnilink.net...
> > > Sam wrote:
> > > > the file name is avg and it is located at /home/<username>/data
> > > > directory
> > >
> > > Then why are you trying to open
> > > home/user/data/avg
> > > instead of
> > > /home/user/data/avg
> > >
> > > Or did you make sure that your CWD is the root directory?
> > > At least I didn't see any code for that anywhere in your previous code
> > > samples.
> > >
> > > jue
> > >
> > >
> >
> > I really need help to understand this. as I have been reading, you need a
> > file handler (DATA) attach to it the file name and pass that to the sub
> open
> > inorder to read the file's line by line in the variable $_. what I am
> > missing?
>
> The correct path to the file.
The poster is missing a lot more than that. Let's look at his last
sentence:
"... you need a file handler (DATA)"
The term is "filehandle", not "file handler"
"attach to it the file name and pass that to the sub open"
The attachment doesn't happen before you pass it to "open", it's the
call to "open" that does the attachment. And "open" isn't a sub, it
is a built-in function.
"inorder to read the file's line by line in the variable $_."
The file's what?
The reading you do doesn't happen in "open". Whether you read it
line-by-line or any other way, and whether you read it in the variable
$_ or another variable is determined later.
This is how the sentence might have read:
"... you need a filehandle (DATA) which you attach to the file name
by passing both to "open" in order to read the files content in any
way you please."
Anno
------------------------------
Date: Mon, 15 Sep 2003 10:12:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: closed filehandle
Message-Id: <tgg9b.27522$pd5.2584@nwrddc03.gnilink.net>
Sam wrote:
> "Jürgen Exner" <jurgenex@hotmail.com> wrote in message
> news:tcc9b.9890$1D5.4139@nwrddc02.gnilink.net...
>> Sam wrote:
>>> the file name is avg and it is located at /home/<username>/data
>>> directory
>>
>> Then why are you trying to open
>> home/user/data/avg
>> instead of
>> /home/user/data/avg
>>
>> Or did you make sure that your CWD is the root directory?
>> At least I didn't see any code for that anywhere in your previous
>> code samples.
>
> I really need help to understand this. as I have been reading, you
> need a file handler (DATA) attach to it the file name and pass that
> to the sub open inorder to read the file's line by line in the
> variable $_. what I am missing?
You are missing the bloody leading slash in your file name!
If (for the sake of argument) your current working directory is
/my/own/directory then you are trying to open
/my/own/directory/home/user/data/avg which of course doesn't exist (or if it
exists by chance then it would not be the file that you want).
And yes, of course open() takes another argument which is a file handle (not
a handler!), but that has nothing to do with your problem.
jue
------------------------------
Date: 15 Sep 2003 00:42:36 -0700
From: knchandramohan@yahoo.com (Chandramohan Neelakantan)
Subject: Re: Converting pdf to text
Message-Id: <69d11688.0309142342.3e5abaa@posting.google.com>
Many thanks for the tips.
-CM
Vlad Tepes <minceme@start.no> wrote in message news:<bjokeh$fat$1@troll.powertech.no>...
> Chandramohan Neelakantan <knchandramohan@yahoo.com> wrote:
>
> > Hello all,
> >
> > Need to extract text information from a pdf file , write the text
> > to a file for a hardware project .
>
> You could try using the command line utility pdftotext from the xpdf
> distribution. I've got better experience with that tool than with using
> pdf2ascii (comes with ghostscript).
>
> Just my two cents,
------------------------------
Date: Mon, 15 Sep 2003 00:51:07 -0700
From: "Tom" <tom@nosleep.net>
Subject: Re: dbm problem HELP!
Message-Id: <3f656eaf$1@nntp0.pdx.net>
when I just try to assign a sub hash to the top, it never gets assigned
regardless of which run, by the way.
"Tom" <tom@nosleep.net> wrote in message news:3f6548dc$1@nntp0.pdx.net...
> I can write to, close aand reopen a dbm file with hashes of hasjed of
hashes
> and everything is OK.
> Data I write is read back just fine.
> However, when I run the program again later on and use the same exact code
> to reopen the dbm, al the data is gone.
>
> Here is a snippet of what I am doing:
>
> dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";
>
> $stk = "ABC";
> $datecode = "20030914";
> $druntime = "700";
> $data = "12345";
>
> $nd{$stk}{$datecode}{$druntime}{Data} = $data;
>
> dbmclose (%nd) || die "Can't dbmclose $ndbfile: $!";
>
> dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";
> print "Data: $nd{$stk}{$datecode}{$druntime}{Data}\n";
> dbmclose (%nd) || die "Can't dbmclose $ndbfile: $!";
>
> -------
> Data: 12345
> -------
>
> However, if I rerun the script with just the following, I get this:
>
> $stk = "ABC";
> $datecode = "20030914";
> $druntime = "700";
> $data = "12345";
>
> dbmopen (%nd,$ndbfile,0666) || die "Can't dbmopen $ndbfile: $!";
> print "Data: $nd{$stk}{$datecode}{$druntime}{Data}\n";
> dbmclose (%nd) || die "Can't dbmclose $ndbfile: $!";
>
> Use of unitialized value in concatenation (.) at C: blah, blah, blah
> Date:
>
> Apparently, there is a problem accessing the dbm file, though it is there.
> Any help would be greatly appreciated, thanks,
> Tom
>
>
>
>
------------------------------
Date: 15 Sep 2003 00:51:03 -0700
From: aksivaram2k2@yahoo.com (SRam)
Subject: Forking Server
Message-Id: <20ffa179.0309142351.1dee07c8@posting.google.com>
I a writing Forking Server for a Small application..
This is code for multiplexing
my $listen = IO::Socket::INET->new(Proto => 'tcp',LocalPort => 2323,
Listen => 1, Reuse => 1)
or die $!;
$listen->autoflush(1);
my $readable_handles = new IO::Select();
$readable_handles->add($listen);
while (1)
{
$listen->autoflush(1);
($new_readable) = IO::Select->select($readable_handles, undef,
undef, 0);
foreach $sock (@$new_readable)
{
if ($sock == $listen)
{
my $new_sock = $sock->accept();
$readable_handles->add($new_sock);
$count++;
$flag = 0;
print $new_sock->fileno . ": connected\n";
}
else
{
$sock->recv($line,300);
print "Received Message\n";
print "Message = $line\n";
......operations....
}
}
}
I also got code for Forking Server from advanced perl programming
# Forking server
use IO::Socket;
$SIG{CHLD} = sub {wait ()};
$main_sock = new IO::Socket::INET (LocalHost => 'goldengate',
LocalPort => 1200,
Listen => 5,
Proto => 'tcp',
Reuse => 1,
);
die "Socket could not be created. Reason: $!\n" unless ($sock);
while ($new_sock = $main_sock->accept()) {
$pid = fork();
die "Cannot fork: $!" unless defined($pid);
if ($pid == 0) {
# Child process
while (defined ($buf = <$new_sock>)) {
# do something with $buf ....
print $new_sock "You said: $buf\n";
}
exit(0); # Child process exits when it is done.
} # else 'tis the parent process, which goes back to accept()
}
close ($main_sock);
I need to convert the multipexing one of first to forking..I don't
know exactly where to modify...Can Anyone help me get me the exact
code...
------------------------------
Date: 15 Sep 2003 11:12:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Modifying a HP/GL2 output file using Perl
Message-Id: <bk46qs$lt4$1@mamenchi.zrz.TU-Berlin.DE>
Steve Hemond <shemond@hotmail.com> wrote in comp.lang.perl.misc:
> Hi gurus,
>
> I read some docs about Perl and I think it would be the best language to
> suit my acutal need.
>
> I have to change plotter pen widths from an HP/GL2 output file with specific
> widths. An HP/GL2 is a plain-text file filled with plotter commands. The
> one I need to check are :
> PSx (where x = pen number) = PEN SELECT
> PWx (where x = width) = PEN WIDTH
>
> In that kind of file, you will see PS1 followed by a bunch of coordinates
> and stuff. From there you can see that every command after the PS1 is for
> the PEN NUMBER ONE. I have to check where the PW is, and affect a new width
> right after it. I have to do this to all pens. I already know which width
> goes for each pen. My problem is that the number of caracters between each
> PSx and PWx are different from time to time.
>
> Unless anyone has a better idea it would probably need to read the file byte
> per byte, and when a PSx is read, the program will remember the current
> pen, and when reaching the next PWx, it will affect the corresponding width
> for the current pen.
>
> Is there an quick and effective way to do such kind of things with Perl?
> From what I've read, I can make a Perl script read a file LINE by LINE but
> I don't know about reading byte per byte.
Bob Walton has suggested slurping the file, and that looks indeed
attractive because the content of one line can influence what happens
many lines later.
However, the problem can be dealt with line-wise too.
If you work through the file and pick up a new line, split the
line into parts where a "PSx" is found. Then in each part all
"PWx" must be changed in a uniform way. The width for the first
part will be the one that has been used for the last part of the
last line. The width of the other parts is determined by the "PSx"
statement they begin with. You will have to keep the last width
used for the next line you pick up. So a function to deal with a
line would take a line to change and the initial width for arguments,
and return the changed line and the new width:
sub deal_with_line {
my ( $line, $width) = @_;
my @parts = split /(?=PS\d+)/, $line; # note zero width pattern
for ( @parts ) {
$width = $width{ $1} if /^PS(\d+)/;
next unless defined $width; # may happen before the first "PSx"
s/PW\d+/PW$width/g;
}
( join( '', @parts), $width);
}
The main program becomes:
my $width;
while ( <DATA> ) {
( $_, $width) = deal_with_line( $_, $width);
print;
}
Anno
------------------------------
Date: Mon, 15 Sep 2003 11:17:25 +0200
From: "Arjen" <mijn_postbak@msn.com>
Subject: Need help on split-function
Message-Id: <3f6588a7$0$193$e4fe514c@dreader3.news.xs4all.nl>
Hi All,
What I want to is using a string as PATTERN in a split function. This makes
it possible for me to change the PATTERN on one place in my script...
For example:
$separator = ";";
$line = "field1;value1";
local($field, $value) = split(/$separator/, $line);
How can I make this work ?
Arjen
------------------------------
Date: Mon, 15 Sep 2003 11:16:29 +0100
From: "Matthew Browning" <usenet@NOSPAM.matthewb.org>
Subject: Re: Need help on split-function
Message-Id: <pan.2003.09.15.10.16.29.11643@NOSPAM.matthewb.org>
On Mon, 15 Sep 2003 11:17:25 +0200, Arjen wrote:
>
> For example:
> $separator = ";";
> $line = "field1;value1";
> local($field, $value) = split(/$separator/, $line);
>
> How can I make this work ?
In what sense exactly does that not work?
Matthew Browning
------------------------------
Date: Mon, 15 Sep 2003 12:22:47 +0200
From: "Arjen" <mijn_postbak@msn.com>
Subject: Re: Need help on split-function
Message-Id: <3f6592f8$0$132$e4fe514c@dreader4.news.xs4all.nl>
Hi Matthew,
You are right. I will give an example:
Code:
$line = "field1|value1";
$separator = "|";
local($field, $value) = split(/$separator/, $line);
Gives back:
$field = f
$value= v
Code:
$line = "field1^value1";
$separator = "^";
local($field, $value) = split(/$separator/, $line);
Gives back:
$field = field1^value1
$value=
Code:
$line = "field1;value1";
$separator = ";";
local($field, $value) = split(/$separator/, $line);
Gives back:
$field = field1
$value= value1
The last example is working right. The others are not. Even not when i'm
using "\|" instead of "|" for the seperator.
Arjen
"Matthew Browning" <usenet@NOSPAM.matthewb.org> wrote in message
news:pan.2003.09.15.10.16.29.11643@NOSPAM.matthewb.org...
> On Mon, 15 Sep 2003 11:17:25 +0200, Arjen wrote:
> >
> > For example:
> > $separator = ";";
> > $line = "field1;value1";
> > local($field, $value) = split(/$separator/, $line);
> >
> > How can I make this work ?
>
>
> In what sense exactly does that not work?
>
>
> Matthew Browning
------------------------------
Date: Mon, 15 Sep 2003 15:51:10 +0530
From: Thens <thens@NOSPAMti.com>
Subject: Re: Need help on split-function
Message-Id: <20030915155110.7518f357.thens@NOSPAMti.com>
On Mon, 15 Sep 2003 11:17:25 +0200
"Arjen" <mijn_postbak@msn.com> wrote:
# Hi All,
#
# What I want to is using a string as PATTERN in a split function. This makes
# it possible for me to change the PATTERN on one place in my script...
#
# For example:
# $separator = ";";
# $line = "field1;value1";
# local($field, $value) = split(/$separator/, $line);
I dont know why this will fail. But you can also quote the
meta-characters in your PATTERN using \Q and \E if they have any.
$separator = "++";
$line = "field1++value1";
local($field, $value) = split(/\Q$separator\E/, $line);
Regards,
Thens.
------------------------------
Date: Mon, 15 Sep 2003 10:48:06 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Need help on split-function
Message-Id: <GNg9b.10187$1D5.5127@nwrddc02.gnilink.net>
Arjen wrote:
[snipped]
You won't believe it but a namesake of yours just posted exactly the same
question in CLP where I just happened to answer it.
You may want to check there.
And you also may want to read the nettiquette why multiposting will put you
on the fast path into many killfiles.
jue
------------------------------
Date: Mon, 15 Sep 2003 12:56:47 +0200
From: "Arjen" <mijn_postbak@msn.com>
Subject: Re: Need help on split-function
Message-Id: <3f659af0$0$138$e4fe514c@dreader4.news.xs4all.nl>
> You won't believe it but a namesake of yours just posted exactly the same
> question in CLP where I just happened to answer it.
> You may want to check there.
>
> And you also may want to read the nettiquette why multiposting will put
you
> on the fast path into many killfiles.
>
> jue
I'm really sorry, I didn't know that I should not post this message in more
then one newsgroup. Or is it because comp.lang.perl and comp.lang.perl.misc
are related that I shouldn't post in both ?!
Arjen
------------------------------
Date: Mon, 15 Sep 2003 12:30:54 GMT
From: f_baggins80@hotmail.com (Helgi Briem)
Subject: Re: Need help on split-function
Message-Id: <3f65b01c.852193088@News.CIS.DFN.DE>
On Mon, 15 Sep 2003 12:56:47 +0200, "Arjen" <mijn_postbak@msn.com>
wrote:
>I'm really sorry, I didn't know that I should not post this message
>in more ten one newsgroup. Or is it because comp.lang.perl and
>omp.lang.perl.misc are related that I shouldn't post in both ?!
Comp.lang.perl is extinct. It doesn't exist except on
misconfigured servers. You should never ever post
to it.
Cross-posting is OK, but in moderation and only
with very good cause. Multi-posting is a definite
no-no.
--
Helgi Briem hbriem AT simnet DOT is
Excuses the munged address. My last
e-mail address was killed by spammers.
------------------------------
Date: 15 Sep 2003 00:24:11 -0700
From: debhatta@hotmail.com (debraj)
Subject: Problem with xml parser
Message-Id: <f9f243e.0309142324.31bad6f0@posting.google.com>
Hi All,
While trying to get a script to diff two xml files, I stumbled upon
XML::SemanticDiff and the example alongwith it .
But while running the script I am getting the following error :
Couldn't open encmap windows-1252.enc:
No such file or directory
at /lib/perl5/site_perl/5.8.0/sun4-solaris-thread-multi/XML/Parser.pm
line 185
Can anyone suggest, why I am getting this ?The path to the above
Parser.pm exists .
Or IF there is any better solution to diff two xml files (obviously
using perl)from the command line ?
Thanx
Debhatta
------------------------------
Date: Mon, 15 Sep 2003 07:19:23 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: readline() on closed fielhandle?
Message-Id: <bspamvsfeln3hrri7lanl4fk4rt84glqq6@4ax.com>
On Sat, 13 Sep 2003 17:04:05 -0500, tadmc@augustmail.com (Tad
McClellan) wrote:
>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>
>> would you recommend any program which automates the
>> formatting?
>
>
>vi or emacs
thanks
Geoff
------------------------------
Date: Mon, 15 Sep 2003 07:20:18 GMT
From: Geoff Cox <geoff.cox@blueyonder.co.uk>
Subject: Re: readline() on closed fielhandle?
Message-Id: <1upamvgmva3j7ag2g0pscfk9i5jdlnksk7@4ax.com>
On Sat, 13 Sep 2003 22:42:36 GMT, tiltonj@erols.com (Jay Tilton)
wrote:
>Geoff Cox <geoff.cox@blueyonder.co.uk> wrote:
>
>: On Sat, 13 Sep 2003 20:51:28 GMT, tiltonj@erols.com (Jay Tilton)
>: wrote:
>
>: >Win98 will also say "Permission denied" when your program tries to open
>: >a directory as if it is a file.
>:
>: the email addresses are in files which are in a folder with no
>: sub-folders so it cannot be this, can it?
>
>Instead of asking me, ask your program to give you that information.
>
> find ( sub {
> if( -d $_ ) {
> warn "'$_' is a subdirectory.\n";
> return;
> }
> # rest of subroutine goes here
> }, $dir);
ok !
Geoff
------------------------------
Date: Mon, 15 Sep 2003 11:54:05 +0200
From: Carl Cunningham <oh-god-please-dont-spam-me@hotmail.com>
Subject: Regular expressions and parenthesis in match text
Message-Id: <BB8B58DD.ACC%oh-god-please-dont-spam-me@hotmail.com>
Hi folks,
I'm going bonkers with what should be a simple problem. I'm trying to change
this text (don't worry about <ul> & </ul>, I've got that taken care of):
<p>Bla bla</p>
<p>- dis dat (hjkhjk) </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
into:
<p> Bla bla</p>
<li>- dis dat </li>
<li>- DIS DAT</li>
<p> Bla bla</p>
This script seems to work fine (keep an eye on the parenthesis):
-------------------------------------
$text = "<p>Bla bla</p>
<p>- dis dat </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
" ;
@a = ($text =~ m/(<p>-.*?<\/p>)/sg) ;
foreach $temp (@a) {
$temp2 = $temp ;
$temp =~ s/p>-|p>/li>/g ;
$text =~ s"$temp2"$temp" ;
}
print $text ;
-------------------------------------
But if the text to be matched contains parenthesis:
$text = "<p>Bla bla</p>
<p>- dis dat (hjkhjk) </p>
<p>- DIS DAT</p>
<p>Bla bla</p>
" ;
The "m/expression/" matches the desired lines, but the s/// operator doesn't
match the line containing the parenthesis.
Could somebody puh-leaze help me on this?
----------------------------------------------------------------------------
Carl K. Cunningham
Roberts´ interactive GmbH
E-Mail: initials of first and last name, at 'roberts' dot 'de'
----------------------------------------------------------------------------
------------------------------
Date: Mon, 15 Sep 2003 13:40:20 +0300
From: Patrick de Palma <me@privacy.net>
Subject: Re: Regular expressions and parenthesis in match text
Message-Id: <bk44ul$p8ai3$1@ID-206748.news.uni-berlin.de>
Carl Cunningham wrote:
> Hi folks,
<SNIP>
> This script seems to work fine (keep an eye on the parenthesis):
> -------------------------------------
> $text = "<p>Bla bla</p>
> <p>- dis dat </p>
> <p>- DIS DAT</p>
> <p>Bla bla</p>
> " ;
>
> @a = ($text =~ m/(<p>-.*?<\/p>)/sg) ;
>
> foreach $temp (@a) {
> $temp2 = $temp ;
> $temp =~ s/p>-|p>/li>/g ;
> $text =~ s"$temp2"$temp" ;
> }
> print $text ;
> -------------------------------------
>
> But if the text to be matched contains parenthesis:
>
> $text = "<p>Bla bla</p>
> <p>- dis dat (hjkhjk) </p>
> <p>- DIS DAT</p>
> <p>Bla bla</p>
> " ;
>
> The "m/expression/" matches the desired lines, but the s/// operator
> doesn't match the line containing the parenthesis.
>
> Could somebody puh-leaze help me on this?
You have just to make perl to quote the meta characters for you with \Q
Change
$text =~ s"$temp2"$temp" ;
to
$text =~ s"\Q$temp2"$temp";
It will work fine with that.
------------------------------
Date: Mon, 15 Sep 2003 13:02:29 +0200
From: Carl Cunningham <oh-god-please-dont-spam-me@hotmail.com>
Subject: Re: Regular expressions and parenthesis in match text
Message-Id: <BB8B68E5.C0C%oh-god-please-dont-spam-me@hotmail.com>
in Beitrag bk44ul$p8ai3$1@ID-206748.news.uni-berlin.de schrieb Patrick de
Palma unter me@privacy.net am 15.09.2003 12:40 Uhr:
>
> You have just to make perl to quote the meta characters for you with \Q
> Change
>
> $text =~ s"$temp2"$temp" ;
>
> to
>
> $text =~ s"\Q$temp2"$temp";
>
> It will work fine with that.
Doh! Thank you _very_ much.
----------------------------------------------------------------------------
Carl K. Cunningham
Roberts´ interactive GmbH
E-Mail: initials of first and last name, at 'roberts' dot 'de'
----------------------------------------------------------------------------
------------------------------
Date: Mon, 15 Sep 2003 15:51:08 +0800
From: "Bill Zhao" <bzhaoa@yahoo.com.cn>
Subject: Re: Send email using Perl
Message-Id: <bk3qig$b5v$1@mail.cn99.com>
"Ning li" <ningli2000@worldnet.att.net> ¼¶¼g©ó¶l¥ó
news:I6P8b.140824$3o3.10064623@bgtnsc05-news.ops.worldnet.att.net...
> Hi,
>
> I am new to Perl and I would like to know the Perl equivalent of this
> Unix mail command:
>
> mailx -s "My Subject Here" jdoe@mail.com < my_file_name
in perl:
if (`mailx -s "My Subject Here" jdoe@mail.com < my_file_name`) {
die "Mail Send Fail ";
}
>
> Thanks in advance.
>
> Nick Li
>
>
>
>
------------------------------
Date: 15 Sep 2003 08:03:20 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Send email using Perl
Message-Id: <slrnbmasi8.ot.sholden@flexal.cs.usyd.edu.au>
On Mon, 15 Sep 2003 15:51:08 +0800, Bill Zhao <bzhaoa@yahoo.com.cn> wrote:
>
> "Ning li" <ningli2000@worldnet.att.net> ¼¶¼g©ó¶l¥ó
> news:I6P8b.140824$3o3.10064623@bgtnsc05-news.ops.worldnet.att.net...
>> Hi,
>>
>> I am new to Perl and I would like to know the Perl equivalent of this
>> Unix mail command:
>>
>> mailx -s "My Subject Here" jdoe@mail.com < my_file_name
> in perl:
> if (`mailx -s "My Subject Here" jdoe@mail.com < my_file_name`) {
> die "Mail Send Fail ";
> }
Did you even think about that for a second? Did you really want to
interpolate the array @mail into that command?
Why does mailx indicate failure by outputting to stdout? That seems like
a remarkably stupid way of indicating failure.
Of course it probably doesn't. It's far more likely you just don't know
how to execute a command correctly in perl...
--
Sam Holden
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 5504
***************************************