special characters handling in perl

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting special characters handling in perl
# 1  
Old 08-12-2009
special characters handling in perl


Here is my piece of code--

sub per_user_qna_detail
		if($records[$index] =~ m/^(.*)\s*Morocco.*Entering\s*Module::authenticate/)
			printf "INSIDE per_user_qna_detail on LINE NO $index\n";
			$Time_Stamp = $1;

sub search_for_username_and_no_of_questions
	printf "ENTERING INSIDE search_for_username_and_no_of_questions ON LINENO=$index\n";
		#printf "LINENO=$index\n";
		if ($records[$index] =~ /userName\s+:\[(..*)\]/)
			$User_Name = $1;
			$User_Name =~ s/\s+//g;
			$User_Name= "'"  .   $User_Name     .  "'";
			print "User_Name = $User_Name\n";
				if ($records[$index] =~ /Set\s+of\s+questions\(bitmap\)\s+selected\s+:\s+(\d+)/)
					print "Inside set of questions bitmap selected\n";
					$Bitmap_Number_For_Questions = $1;
					printf "PRASANNA:$User_Name\n";
					print "$Bitmap_Number_For_Questions is no of questions for $User_Name\n";
					print "$Time_Stamp is time stamp for $User_Name\n";
					printf "EXITING INSIDE search_for_username_and_no_of_questions ON LINENO=$index\n";
					return 0;

	 printf "EXITING INSIDE search_for_username_and_no_of_questions ON LINENO=$index\n";

The code is working fine as expected if a user name is numeric, but if a username contains any special characters then it is failing.

The snippet of the log file is this---

Entering Module::authenticate

pid 2172 tid 3124: 160: 10110847: userName :[app@abc.com]
pid 2172 tid 3124: 160: 10110847: Set of questions(bitmap) selected : 7

and the other part is ---
pid 2172 tid 3124: 160: 10110851: Auth - Success and Complete, Returning SUCCESS
Wed May 20 08:19:17.594 2009 Morocco Standard Time INFO:    pid 2172 tid 3124: 160: 10110851: Exiting QnAModule::authenticate
ArAuthFrameworkImpl::doPostAuth::1:10110850:: Authentication mechanism returned [0] for AuthIdentity [APP@ABC.COM]

The expected result is like this--
Fri May 29 18:52:06.967 2009  , 'abc_kal.nt' , 6 ,  "Success" 
Fri May 29 18:52:38.592 2009  , 'nt@abc.com' , 9 ,  "Success" 
Fri May 29 18:58:49.717 2009  , '12345678' , 12 ,  "Success" 
Fri May 29 18:59:34.107 2009  , 'app@abc.com' , 12 , "Failure" 
Fri May 29 19:00:00.936 2009  , '98765432' , 12 , "Failure"

and the final result which is coming is this--
Fri May 29 18:58:49.717 2009  , '12345678' , 12 ,  "Success" 
Fri May 29 19:00:00.936 2009  , '98765432' , 12 , "Failure"

for this snippet i am not getting the desired result.
I did some googling and tried some options but they are not working for us.
Kindly suggest something to get it working.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

perl regular expression to remove the special characters

I had a string in perl script as below. Tue Aug7 03:54:12 2012 Now I need to replace the special character with space. After removing the special chaacters Tue Aug 7 03:54:12 2012 Could anyone please help me here for writing the regular expression? Thanks in advance.. Regards, GS (1 Reply)
Discussion started by: giridhar276
1 Replies

2. Shell Programming and Scripting

Replace special characters in multiple files - perl

I have 100 files, where i want to search a set of strings and make the replacement by other strings In the first case I want to include a parameter in the name of a file LOG_DCT = $ LOG_DIR/DCT_GERAL_"$DATAINI".log replace to : LOG_DCT = $ LOG_DIR / DCT_GERAL_ $ 1_ "$ DATAINI". log I did... (1 Reply)
Discussion started by: RMSoares
1 Replies

3. Shell Programming and Scripting

Want the substring of a string with special characters using perl

Hi, I am trying to separate the directory from the filename using the substring and it does not like it. $Complete_name="C:\ABCD\Reports_Split\090308.1630" I want $File_Name as 090308.1630 I tried using Substring function and it does not like slashes in the complete_name. Any... (5 Replies)
Discussion started by: sushma0907
5 Replies

4. Shell Programming and Scripting

remove special characters from text using PERL

Hi, I am stuck with a problem here. Suppose i have a variable which is assigned some string containing special charatcers. for eg: $a="abcdef^bbwk#kdbcd@"; I have to remove the special characters using Perl. The text is assigned to the variable implicitly. How to do it? (1 Reply)
Discussion started by: agarwal
1 Replies

5. Shell Programming and Scripting

Problem with awk while handling special charaters

Hi, I have an application.xml file like </dependency> <artifactId>_AdminServicesEAR</artifactId> <version>1.0.0-20080521.085352-1</version> <context-root>oldvalue</context-root> <type>ear</type> <DOCTYPE "abc/xyz/eft"> <NewTag>value123</xyz> ... (4 Replies)
Discussion started by: subin_bala
4 Replies

6. Shell Programming and Scripting

Open filename with special characters in Perl

Hi All, I am facing a weird problem. I have got a directory structure copied from windows to Linux. Some of the folders are named like /gfs/data/Dow Jones $5/ DJ FCBOT_O_tick_1998.zip /gfs/data/Dow Jones $5/ DJ FCBOT_O_tick_2000.CSV /gfs/data/Dow Jones... (6 Replies)
Discussion started by: mitrashatru
6 Replies

7. Shell Programming and Scripting

Handling special characters using awk

Hi all, How do I extract a value without special characters? I need to extract the value of %Used from below and if its greater than 80, need to send a notification. I am doing this right now..Its giving 17%..Is there a way to extract the value and assign it to a variable in one step? df |grep... (3 Replies)
Discussion started by: sam_78_nyc
3 Replies

8. Shell Programming and Scripting

Perl code to search for filenames that contain special characters

Hello, I have a requirement to search a directory, which contains any number of other directories for file names that contain special characters. directory structure DIR__ |__>DIR1 |__>DIR2__ |__>DIR2.1 |__>DIR2.2 |__>DIR3 .. ... (8 Replies)
Discussion started by: jerardfjay
8 Replies

9. UNIX for Advanced & Expert Users

handling special characters

Hello everyone, I use Samba to copy mp3 files to my Red Hat 8.0 box so I can randomize them through a playlist. When I copy: Sigur Rs-Nja Lagi.mp3 It shows in the mapped drive on Windows as: Sigur Rs-N_ja Lagi_.mp3 And via Putty as: Sigur R(grayed box)s-N_ja Lagi_.mp3 What is going... (1 Reply)
Discussion started by: effigy
1 Replies

10. Solaris

Handling Special Charcters

Dear All, I have created a UTF-8 database to store multi-lingual charcters. Below is the query from which i insert from Winsql (front-end third party database browser tool), the data gets inserted properly. insert into a (no, lbl) values (1, "Cliquez ici pour revenir _ la recherche de... (2 Replies)
Discussion started by: lloydnwo
2 Replies
Login or Register to Ask a Question