multipe instance scenario in perl


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting multipe instance scenario in perl
# 1  
Old 09-10-2008
multipe instance scenario in perl

letz say that my file has 7 records with only one field. So my file has:

11111111
000000000000000
1111
aaaabbbccc
1111111222000000
aaaaaaaa
zz

All i need is:
1. when the field has a repetition of the same instance(a-z or 0-9), i would consideer it to be invalid. eg.(11111111,000000000000000,1111,aaaaaaaa,zz are all invalid)

2.If there is a repetition of 2 or more instances,it is valid. (eg. 1111111222000000,aaaabbbccc is valid)

3. Please note that the length of each field may vary.

So, i am expecting the output:
aaaabbbccc
1111111222000000

I am not sure if the title of the thread suits the matter. Anyway, whoever crosses this thread i would appreciate your input. Thanks in advance!
# 2  
Old 09-10-2008
What have you tried so far?
# 3  
Old 09-10-2008
^[0]+$ ---------> This will match all zeros. how do i match alpha and numeric in one expression
# 4  
Old 09-11-2008
I don't think you'll be able to solve it easily just with a regex. I would split the line into characters, add them to a hash, and then check the number of members of the hash to make sure there are more than 1.

What about single characters... are they considered valid or invalid? e.g. ab, and aaab?
# 5  
Old 09-11-2008
Maybe...
Code:
$ perl -n -e 'chomp;print "$_\n" if $_ =~ ("[^".substr($_,1,1)."]")' file1
aaaabbbccc
1111111222000000

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Move multipe files to corresponding directories

Hi, In a parent directory there are several files in the form IDENTIFIER1x IDENTIFIER1.yyy IDENTIFIER1_Z, etc IDENTIFIER2x IDENTIFIER2.yyy IDENTIFIER2_Z, etc IDENTIFIER3x IDENTIFIER3.yyy, IDENTIFIER3_Z, etcIn the same parent directory there are corresponding directories named... (7 Replies)
Discussion started by: spirospap
7 Replies

2. Shell Programming and Scripting

Perl script to change the date in some scenario

Hi , I have file FSN.log which contains number 100. i have other Perl script when i run it , it ll increment this FSN.log value. now my requirement is when the count in FSN.log becomes 999, it should make the value to 100 again and Perl script to change the date or it should make the date... (2 Replies)
Discussion started by: santhoshks
2 Replies

3. Shell Programming and Scripting

Renaming multipe files

Hi, I have these list of files from with the following filename format (the last 3 characters are in julian days). I want the year info retained added with sequence number 01-12 to represent the month. any suggestion on how to automate the renaming process. many thanks. original filenames ... (3 Replies)
Discussion started by: ida1215
3 Replies

4. Shell Programming and Scripting

multipe pattern

Extract of configuration file. members server1.domain1.com,server2.domain2.com,server3.domain3.com I am writing a script to remove the server members from a conf file. When I run the script the corresponding server should be removed from the file. /root/server-remove.sh... (2 Replies)
Discussion started by: anilcliff
2 Replies

5. Shell Programming and Scripting

execute multipe commands

I would like to execute multipe commands in a shell script. Please provide the commands for the below scenario: Execute command1 if command1 is succesfull, then execute command2, command3,command4 in parallel if command2, command3,command4 are success then run command 5 (3 Replies)
Discussion started by: p_gautham12
3 Replies

6. Shell Programming and Scripting

Parsing multipe data entries

Hi I am using command awk '{printf $1 " "}' PMT_GGSN_WPP_APN-20110517* > outfile The * refers to 24 files (1 generated per hour per day) with each one having the output of A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 I need... (8 Replies)
Discussion started by: rob171171
8 Replies

7. UNIX for Dummies Questions & Answers

Reading only first record from the multipe directories

Hi All, I have a requirement, I had a parent directory Land under that we have sub directories Yesterday, Today and Tommorrow And we have a file test.txt under the above directories Yesterday, Today and Tommorrow The data in the file test.txt under Yesterday folder is ... (5 Replies)
Discussion started by: somu_june
5 Replies

8. Shell Programming and Scripting

Transpose multipe columns to rows and adding headers

Hi, I found the following awk script to transpose multiple (3) columns to multiple rows: #=== BEGIN {FS=","} { for (i=1;i<=NF;i++) { arr=$i; if(nf<= NF) nf=NF; } nr=NR } END { for(i=1;i<=nf;i++) { (8 Replies)
Discussion started by: Gery
8 Replies

9. Shell Programming and Scripting

Multipe conditions in if statement

I have a script that runs every 15 minutes in cron that builds a web page. It runs at 15, 28, 45 and 58 minutes past the hour. (pretty much evry 15 mins). Every 2 hours from 6:28 to 18:28 it sends out emails if it finds errors. I do not want it sending email every single time it runs, every 15... (5 Replies)
Discussion started by: spacemancw
5 Replies

10. Shell Programming and Scripting

replace first instance(not first instance in line)

Alright, I think I know what I am doing with sed(which probably means I don't). But I cant figure out how to replace just the first occurance of a string. I have tried sed, ed, and grep but can't seem to figure it out. If you have any suggestions I am open to anything! (3 Replies)
Discussion started by: IronHorse7
3 Replies
Login or Register to Ask a Question