RE: Escaping a plus sign

2006-05-31 Thread Ken Lehman
Is it the if ($MGMTCMNT =~ /$MGMTNM/) part that is tripping you up? I
believe you could change it to if ($MGMTCMNT =~ /\Q$MGMTNM\E/) if you
need to keep the regular expression. Another idea might be to change it
to 
if ( ($start = index($MGMTCMNT, $MGMTNM ())  0) {




-Original Message-
From: Paul Nowosielski 
Sent: Tuesday, May 30, 2006 4:13 PM
To: beginners@perl.org
Subject: Escaping a plus sign

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




 


This email and any attachments have been scanned for known viruses using 
multiple scanners.
We believe that this email and any attachments are virus free, however the 
recipient must 
take full responsibility for virus checking. This email message is intended for 
the named 
recipient only. It may be privileged and/or confidential. If you are not the 
intended named
recipient of this email then you should not copy it or use it for any purpose, 
nor disclose
its contents to any other person. You should contact Misys Banking Systems so 
that we can 
take appropriate action at no cost to yourself.



www.misys.com 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Escaping a plus sign

2006-05-31 Thread Dr.Ruud
Paul Nowosielski schreef:

 The
 script will die if the is a + sign in the fields its parsing.

  perldoc -f quotemeta

-- 
Affijn, Ruud

Gewoon is een tijger.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Escaping a plus sign

2006-05-30 Thread Anthony Ettinger

should probably escape the + sign with \+

$field =~ s/\+/\\+/g;


On 5/30/06, Paul Nowosielski [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response






--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Escaping a plus sign

2006-05-30 Thread Paul Nowosielski
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 [EMAIL PROTECTED] 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: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/ http://learn.perl.org/first-response

-- 
Paul Nowosielski
Webmaster
office: 303.440.0666 ext 219
cel: 303.827.4257


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Escaping a plus sign

2006-05-30 Thread John W. Krahn
Paul Nowosielski wrote:
 Dear All,

Hello,

 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?

Yes, you can use the quotemeta escape sequence.  Just change:

 if ($MGMTCMNT =~ /$MGMTNM/) {

To:

 if ($MGMTCMNT =~ /\Q$MGMTNM/) {



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response