Sponsored Content
Full Discussion: Perl split and add new line
Top Forums Shell Programming and Scripting Perl split and add new line Post 302876415 by disedorgue on Sunday 24th of November 2013 10:38:23 AM
Old 11-24-2013
Hi,
If I respect your code (change in red):
Code:
$ cat cc3cc.pl
@outLs=<>; # <= add line just for example (no need in your code)
    foreach $defectRec (@outLs) {
      my($def_id,$status,$files_mod) = split(/,/, $defectRec);
      print "DEFECT ID: $def_id, Status: $status, Files Mod: $files_mod\r\n" if( defined ($debug) );
      $_= $files_mod;
      $_=~ s/;/;\r\n  /g;
      print "$def_id $status $_";
} # <== idem first line

input example:
Code:
$ cat cc2cc.vv
DEFECT_ID,Status,Files_Modified
20222,Testing,File1;File2;File3
20333,Testing,File4;File6

and then:
Code:
$ perl cc3cc.pl cc2cc.vv
DEFECT_ID Status Files_Modified
20222 Testing File1;
  File2;
  File3
20333 Testing File4;
  File6

Regards.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

add to first line of file using perl

Hey guys, I have a text file full of data and all I want to do with the thing is add the file extension name to the first line of the file. Here is what I have so far. I can't remember how to append to the first line of the file without deleting the exsisting data. #!/usr/local/bin/perl ... (5 Replies)
Discussion started by: kingdbag
5 Replies

2. Shell Programming and Scripting

Perl : split flat line's to $

Hi, below is the software list of lines I have, MozillaSrc 1.7.8.00.00 Mozilla 1.78 Source Distribution NFS B.11.11 ONC/NFS; Network-File System,Information Services,Utilities NParProvider B.11.11.01.04.01.01 nPartition Provider NPartition ... (7 Replies)
Discussion started by: acomd2
7 Replies

3. Shell Programming and Scripting

perl script to add a line into a file

hi all need a perl script to add a line into a file thanks with anticipation (2 Replies)
Discussion started by: karthikn7974
2 Replies

4. Shell Programming and Scripting

Split a single record to multiple records & add folder name to each line

Hi Gurus, I need to cut single record in the file(asdf) to multile records based on the number of bytes..(44 characters). So every record will have 44 characters. All the records should be in the same file..to each of these lines I need to add the folder(<date>) name. I have a dir. in which... (20 Replies)
Discussion started by: ram2581
20 Replies

5. Shell Programming and Scripting

[Perl] Split lines into array - variable line items - variable no of lines.

Hi, I have the following lines that I would like to see in an array for easy comparisons and printing: Example 1: field1,field2,field3,field4,field5 value1,value2,value3,value4,value5Example 2: field1,field3,field4,field2,field5,field6,field7... (7 Replies)
Discussion started by: ejdv
7 Replies

6. Shell Programming and Scripting

How to add a line in a file using perl script?

Hi all, I want to search for a line in a file using perl script and add a line above that line.Can any one suggest me command or code to that using script. Thanks BHarath (5 Replies)
Discussion started by: bharathece
5 Replies

7. Programming

Perl find text and add line

Hi All I need to add a line to a file but after a certain block of text is found The block of text looks like this <RDF:Description RDF:about="urn:mimetype:video/quicktime" NC:value="video/quicktime" and i need to add this in the next line down ( note there is... (4 Replies)
Discussion started by: ab52
4 Replies

8. Shell Programming and Scripting

How to add a line in every file with perl commandline?

Hi, i want to add a line at the beginning of every file in a directory. perl -i.bkp -p -e 'print "#include /verif/pdd1/exu/sxs/6sTest/reset/dfu/top_level.reset\n" if $. == 1' *.reset But this command is updating only the first file in the directory. I think this is because $. is not resetting... (3 Replies)
Discussion started by: twistedpair
3 Replies

9. Shell Programming and Scripting

How to add line breaks to perl command with large text in single quotes?

Below code extracts multiple field values from XML into array and prints all in one line. perl -nle '@r=/(?: jndiName| authDataAlias| value| minConnections| maxConnections| connectionTimeout| name)="(+)/g and print join ",",$ENV{tIPnSCOPE},$ENV{pr ovider},$ENV{impClassName},@r' server.xml ... (4 Replies)
Discussion started by: kchinnam
4 Replies

10. Shell Programming and Scripting

Add specific string to last field of each line in perl based on value

I am trying to add a condition to the below perl that will capture the GTtag and place a specific string in the last field of each line. The problem is that the GT value used is not right after the tag rather it is a few fields away. The values should always be 0/1 or 1/2 and are in bold in the... (12 Replies)
Discussion started by: cmccabe
12 Replies
set_color(1)							       fish							      set_color(1)

NAME
set_color - set_color - set the terminal color set_color - set the terminal color Synopsis set_color [-v --version] [-h --help] [-b --background COLOR] [COLOR] Description Change the foreground and/or background color of the terminal. COLOR is one of black, red, green, brown, yellow, blue, magenta, purple, cyan, white and normal. o -b, --background Set the background color o -c, --print-colors Prints a list of all valid color names o -h, --help Display help message and exit o -o, --bold Set bold or extra bright mode o -u, --underline Set underlined mode o -v, --version Display version and exit Calling set_color normal will set the terminal color to whatever is the default color of the terminal. Some terminals use the --bold escape sequence to switch to a brighter color set. On such terminals, set_color white will result in a grey font color, while set_color --bold white will result in a white font color. Not all terminal emulators support all these features. This is not a bug in set_color but a missing feature in the terminal emulator. set_color uses the terminfo database to look up how to change terminal colors on whatever terminal is in use. Some systems have old and incomplete terminfo databases, and may lack color information for terminals that support it. Download and install the latest version of ncurses and recompile fish against it in order to fix this issue. Version 1.23.1 Sun Jan 8 2012 set_color(1)
All times are GMT -4. The time now is 03:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy