Re: Escaping a plus sign
- From: paul@xxxxxxxxxxxxxxxxxxx (Paul Nowosielski)
- Date: Tue, 30 May 2006 14:35:43 -0600
So would this be the correct solution:
while (($PKEY, $MGMTCMNT, $manager_id, $MGMTNM, $UPDATE1, $UPDATE2) =
$sth->fetchrow_array) {
$comment = "";
# added to escape the plus sign
$MGMTCMNT = ~ s/\+/\\+/g;
$MGMTNM = ~ s/\+/\\+/g;
if ($MGMTCMNT =~ /$MGMTNM/) {
$len = length($MGMTNM);
$start = index($MGMTCMNT, "$MGMTNM (");
$start += $len + 2;
$end = index($MGMTCMNT, ")", $start) - $start;
$comment = substr($MGMTCMNT, $start, $end);
}
if ($UPDATE1 > $artisttime || $UPDATE2 > $artisttime ) {
print (ARTMGRFILE "$PKEY\t$manager_id\t$comment\n");
}
}
On Tuesday 30 May 2006 14:23, Anthony Ettinger wrote:
should probably escape the + sign with \+
$field =~ s/\+/\\+/g;
On 5/30/06, Paul Nowosielski <paul@xxxxxxxxxxxxxxxxxxx> wrote:
Dear All,
I have a perl script that runs nightly. It create a data feed. The script
will die if the is a + sign in the fields its parsing.
Here is the snippet:
while (($PKEY, $MGMTCMNT, $manager_id, $MGMTNM, $UPDATE1, $UPDATE2) =
$sth->fetchrow_array) {
$comment = "";
if ($MGMTCMNT =~ /$MGMTNM/) {
$len = length($MGMTNM);
$start = index($MGMTCMNT, "$MGMTNM (");
$start += $len + 2;
$end = index($MGMTCMNT, ")", $start) - $start;
$comment = substr($MGMTCMNT, $start, $end);
}
if ($UPDATE1 > $artisttime || $UPDATE2 > $artisttime ) {
print (ARTMGRFILE "$PKEY\t$manager_id\t$comment\n");
}
}
Here is the error message:
Quantifier follows nothing in regex; marked by <-- HERE in m/+ <-- HERE 1
Public Relations/ at /srv/www/htdocs/admin/utilities/aeg/manart.pl line
102.
In this error the problem file had the text "+1 Public Relations";
Is there a way to escape this character so in the future it won't kill
the script?
Thank you,
--
Paul Nowosielski
--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
<http://learn.perl.org/> <http://learn.perl.org/first-response>
--
Paul Nowosielski
Webmaster
office: 303.440.0666 ext 219
cel: 303.827.4257
.
- Follow-Ups:
- Re: Escaping a plus sign
- From: Paul Lalli
- Re: Escaping a plus sign
- References:
- Escaping a plus sign
- From: Paul Nowosielski
- Re: Escaping a plus sign
- From: Anthony Ettinger
- Escaping a plus sign
- Prev by Date: RE: Escaping a plus sign
- Next by Date: Re: Escaping a plus sign
- Previous by thread: Re: Escaping a plus sign
- Next by thread: Re: Escaping a plus sign
- Index(es):
Relevant Pages
|
|