Remove parenthesis character (Perl)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Remove parenthesis character (Perl)
# 1  
Old 10-28-2008
Remove parenthesis character (Perl)

Hello, i'm unable to remove the parenthesis character.

With $parsed_AsciiName =~ s/\(//;
the string is the same

And with $parsed_AsciiName =~ s/(//;
i retrieve "Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE"

Any ideas, please? thank you in advanced.
# 2  
Old 10-28-2008
Quote:
Originally Posted by aristegui
Hello, i'm unable to remove the parenthesis character.

With $parsed_AsciiName =~ s/\(//;
the string is the same

And with $parsed_AsciiName =~ s/(//;
i retrieve "Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE"

Any ideas, please? thank you in advanced.
How is this not working for you?

Code:
$ cat ./paren.perl
#!/usr/bin/perl

use strict;
use warnings;

my $parsed_AsciiName = "Today( is October 28, 2008.";

print "parsed_AsciiName Before = $parsed_AsciiName \n";
$parsed_AsciiName =~ s/\(//;
print "parsed_AsciiName After = $parsed_AsciiName \n";

exit 0;
$ ./paren.perl
parsed_AsciiName Before = Today( is October 28, 2008.
parsed_AsciiName After = Today is October 28, 2008.

Please post the code.
# 3  
Old 10-28-2008
Code:
split /\(/,$parsed_AsciiName ;

# 4  
Old 10-28-2008
Quote:
Originally Posted by ghostdog74
Code:
split /\(/,$parsed_AsciiName ;

I'm still not sure what is not working. Please post COMPLETE code:

Code:
$ cat paren.perl
#!/usr/bin/perl

use strict;
use warnings;

my $parsed_AsciiName = "Today( is October 28, 2008.";

print "parsed_AsciiName using split = ", split /\(/,$parsed_AsciiName;
print "\n";

print "parsed_AsciiName Before = $parsed_AsciiName \n";
$parsed_AsciiName =~ s/\(//;
print "parsed_AsciiName After = $parsed_AsciiName \n";

exit 0;
$ ./paren.perl
parsed_AsciiName using split = Today is October 28, 2008.
parsed_AsciiName Before = Today( is October 28, 2008.
parsed_AsciiName After = Today is October 28, 2008.

# 5  
Old 10-28-2008
Code:
# cat par.pl

$data="abc(123";
$data =~ s/\(/ /;
print $data;

# perl par.pl
abc 123
#

This worked for me.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to remove newline character if it is the only character in the entire file.?

I have a file which comes every day and the file data look's as below. Vi abc.txt a|b|c|d\n a|g|h|j\n Some times we receive the file with only a new line character in the file like vi abc.txt \n (8 Replies)
Discussion started by: rak Kundra
8 Replies

2. Shell Programming and Scripting

Remove parenthesis and run awk calculation

The awk below works fine if I manually remove the () from file1. However, when I try to use tr to remove the () and then | into awk to run the calculation no result is obtained. Is there a way to tell the awk to ignore the () in fiile1 if they are there or do I need to remove them first? Thank... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. UNIX for Dummies Questions & Answers

Renaming files to remove everything before one parenthesis

Hi, I have files in a folder that I would like all renamed without the preceding number and parenthesis. For example, I have files of the name 08) Great Good Fine Ok - Not Going Home 09) Roosevelt - Small Hours 10) RAC - I Should've Guessed Feat. SPEAK and I would like them all to be... (4 Replies)
Discussion started by: jyu429
4 Replies

4. Shell Programming and Scripting

perl cmd to remove the control-Z character at end of 10GB file

In a 10-50GB file , at end of file there is Control-z character tried the below options, 1. perl -p -i -e 's/^Z//g' new.txt 2. perl -0777lwi -032e0 new.txt and Sed command, dos2unix etc it takes more time to remove the control-z. need a command or perl program to GO TO LAST LINE OF FILE ... (7 Replies)
Discussion started by: prsam
7 Replies

5. HP-UX

How to remove new line character and append new line character in a file?

Hi Experts, I have data coming in 4 columns and there are new line characters \n in between the data. I need to remove the new line characters in the middle of the row and keep the \n character at the end of the line. File is comma (,) seperated. Eg: ID,Client ,SNo,Rank 37,Airtel \n... (8 Replies)
Discussion started by: sasikari
8 Replies

6. UNIX for Dummies Questions & Answers

How to remove \ character

Dear Members, I have a file which is a single line file. It has "\" character and i need to replace this character with a new line character. How can we do this? I tried with sed but it did not work. sed 's//"\n"/g' t1 > t2Thanks Sandeep (3 Replies)
Discussion started by: sandeep_1105
3 Replies

7. Shell Programming and Scripting

Remove a ^M character

Hi, I'd like to ask for some help with the following: I've cut a couple of columns of file1 to create file2 with the following code: cur -f 1,3,8 file1 > file2 Then I need to transfer file 2 from UNIX to Windows and use it further. Unfortunatelly, for some reason the line is displayed... (4 Replies)
Discussion started by: zajtat
4 Replies

8. Shell Programming and Scripting

Perl use split and remove specific character

i want to split the input by a space and remove specific characters like full stop, comma...... etc. and then save each word in an array. i got something below, but it didn't work. can anyone please help me? Thank you #!/usr/bin/perl -w while (<>) { $line = <>; @word = split(' ',... (6 Replies)
Discussion started by: mingming88
6 Replies

9. Shell Programming and Scripting

Perl RegExp to remove last character from strings

I use SAS (a statistical software) and have to remove last character or the last 1/2 numbers that appear after characters from the string using Perl Regular Expression (which is recognized by SAS). Input: f183ii10 f183ii2 f182ii1 f182ii2 f183iim f22ii f22ii11 f22ii12 pmh4 pmhm Desired... (2 Replies)
Discussion started by: ospreyeagle
2 Replies

10. Shell Programming and Scripting

Need to only remove parenthesis and : leave the rest

Hi all, I'm stuck on this last part...am running a simple script under AIX to extract NetView host IP addresses. The line below returns the IP address in parenthesis with a trailing colon, i.e. ping -c 1 $name |grep \( | awk '{ print $3 }' --------> returns (a.b.c.d): How can I only... (10 Replies)
Discussion started by: livinthedream
10 Replies
Login or Register to Ask a Question