Need help on PERL scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help on PERL scripting
# 1  
Old 02-12-2012
Need help on PERL scripting

Hi Guys;

Im pretty new here in the forum and I need help on how to write a PERL script.

Basically I have a file with content like these

AAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDD
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
GGGGGGGGGGGGGGGGGGGGGGGGGG
HHHHHHHHHHHHHHHHHHHHHHHHHH
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
KKKKKKKKKKKKKKKKKKKKKKKKKKKKK
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
MMMMMMMMMMMMMMMMMMMMM
NNNNNNNNNNNNNNNNNNNNNNNNNN
OOOOOOOOOOOOOOOOOOOOOOO
PPPPPPPPPPPPPPPPPPPPPPPPPPPPP
QQQQQQQQQQQQQQQQQQQQQQQ
RRRRRRRRRRRRRRRRRRRRRRRRRRRRR
SSSSSSSSSSSSSSSSSSSSSSSSSS
TTTTTTTTTTTTTTTTTTTTTTTTTT


it has 20 lines (A to T) but in every 4 line I need to insert a dummy string of 1's 0's and at the end of the file (at T) I need to duplicate it 5 times. Sample output would be like this.

AAAAAAAAAAAAAAAAAAAAAAAAAAA
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
CCCCCCCCCCCCCCCCCCCCCCCCCCC
DDDDDDDDDDDDDDDDDDDDDDDDDDD
111111111111111111111111111111
111111111111111111111111111111
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
GGGGGGGGGGGGGGGGGGGGGGGGGG
HHHHHHHHHHHHHHHHHHHHHHHHHH
111111111111111111111111111111
111111111111111111111111111111
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
KKKKKKKKKKKKKKKKKKKKKKKKKKKKK
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
111111111111111111111111111111
111111111111111111111111111111
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
MMMMMMMMMMMMMMMMMMMMM
NNNNNNNNNNNNNNNNNNNNNNNNNN
OOOOOOOOOOOOOOOOOOOOOOO
PPPPPPPPPPPPPPPPPPPPPPPPPPPPP
111111111111111111111111111111
111111111111111111111111111111
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
QQQQQQQQQQQQQQQQQQQQQQQ
RRRRRRRRRRRRRRRRRRRRRRRRRRRRR
SSSSSSSSSSSSSSSSSSSSSSSSSS
TTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTT
TTTTTTTTTTTTTTTTTTTTTTTTTTTTT


Can you help me on this guys? Please
# 2  
Old 02-12-2012
Hi, what have you tried so far?
# 3  
Old 02-12-2012
none so far.... Im just barely started and this task was assign to me.... and need to have result ASAP. Smilie

Last edited by ahock; 02-12-2012 at 07:00 AM..
# 4  
Old 02-12-2012
Code:
perl -pe '$_.=("1"x31 ."\n")x2 .("0"x31 ."\n")x4 if $.%4==0&&$.!=20;$_.=("T"x31 ."\n")x5 if $.==20' file

# 5  
Old 02-12-2012
hi bartus;

if its not to much to ask.... Is it ok if you can explain on it as I ma new into PERL so that I can learn easily.

Thanks
# 6  
Old 02-12-2012
Normally we could help you write your own script, but this is a bit too basic for a script..
Put this in file2:
Code:
111111111111111111111111111111
111111111111111111111111111111
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000
000000000000000000000000000000

Then you can use sed:
Code:
sed '$!n;$!n;$!n;${p;p;p;p;p;};$!rfile2' file1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl Scripting

I have create this shell script #!/bin/sh if ; then echo "Usage: ./script <filename>" exit 1 elif ; then fname="$1" fi output="output.txt" i=0 ... (11 Replies)
Discussion started by: Evelin90
11 Replies

2. Shell Programming and Scripting

need help in PERL Scripting

I am having file xyz.log Its content is like this int main() { d; #ifdef e; f; #else g; #ifdef h. #else i; (2 Replies)
Discussion started by: naaj_ila
2 Replies

3. Web Development

Perl scripting or shell scripting?

i am going to study any one of the scripting languages mentioned above(shell 0r perl scripting) . Which is having more scope for a fresher? (1 Reply)
Discussion started by: Anna Hussie
1 Replies

4. What is on Your Mind?

Shell Scripting vs Perl scripting

Gents, I have been working in a Solaris/Unix environment for about 9 months. I took some linux classses online before getting the job. But, I am not very good at scripting. I want to learn how to script. Do you think that I should start with Shell scripting or Perl? I wanted to continue with... (2 Replies)
Discussion started by: Pouchie1
2 Replies

5. What is on Your Mind?

Shell scripting vs Perl scripting

Hi all, I would like to start developping some good scripting skills. Do you think it would be best to start with shell scripting or Perl? I already got a fundation, really basics, in perl. but I am wondering what would be best to be good at first. Can you please help me determine which one to... (14 Replies)
Discussion started by: Pouchie1
14 Replies

6. UNIX for Dummies Questions & Answers

Need help configuring Active Perl on Windows Vista.: Perl Scripting on Windows

Hi All, Need help configuring Active Perl on Windows Vista. I am trying to install Active Perl on Windows Vista. The version of Active Perl i am trying to install is : ActivePerl 5.10.1 Build 1006 After installing it through cmd, When i try to run perl -v to check the version, i get the... (2 Replies)
Discussion started by: Vabiosis
2 Replies

7. Shell Programming and Scripting

Call Shell scripting from Perl Scripting.

Hi How to call a shell scripting through a Perl scripting? Actually I need some value from Shell scripting and passes in the Perl scripting. So how can i do this? (2 Replies)
Discussion started by: anupdas
2 Replies

8. Shell Programming and Scripting

Need help in perl scripting.

Hi, To run a perl script i am giving command like this in DOS prompt d:> perl D:\<dir_name>\<dir_name>\sample.pl Its throwing the following error while running the above syntax error at <eval 4> line 1, near "use D:" Can anyone help? (3 Replies)
Discussion started by: mvictorvijayan
3 Replies

9. Shell Programming and Scripting

perl scripting

Hi does anyone know how to ouput "I love scripting" to "scripting love I" without using reverse() function in perl? Thanks (2 Replies)
Discussion started by: ccp
2 Replies

10. UNIX for Advanced & Expert Users

Perl scripting

hi Can any one suggest me book for perl scripting on UNIX Platform. Regards (2 Replies)
Discussion started by: rochitsharma
2 Replies
Login or Register to Ask a Question