[Boulder.pm] Perl Help

Robert L. Harris Robert.L.Harris at rdlg.net
Sat Mar 31 18:35:40 PDT 2007




Being a little verbose.

while(<INPUT>) {
  chomp;
  ($Part, $Number, $Desc)=split(";",$_ine);
  if ($Part =~ /(.*)II/) {
    $NewPart=$1." II";
  } elsif ( $Part =~ /(.*)([CDI])/) {
    $NewPart=$1." ".$2;
  } else {
    $NewPart=$Part;
  }
  print OUTPUT $NewPart.";".$Number.";".$Desc;
}





Thus spake Rod Burgess (rodbandkimb at msn.com):

> I have the following file with three data fields separated by a "; semicol"
> 
> 14567345;1;Oil Seal
> 4533457C;1;Heat Shield
> 56842204;1;Misc Part
> 5481206D;1;Gasket
> 81003589I;1;Washer
> T23546II;1;Shirt
> 
> The 1st Data Field is Part#
> The 2nd Data Field is Number of Parts
> The 3rd Data Field is Part Description
> 
> The only change that I need to this file is if the 1st data field being the 
> part# ends in a "C,D,I, or II"
> I would like the file to look like this (having a space between the part 
> number an its Identifier.
> If that possible with Perl? Could someone show me a sample perl program to 
> do this?
> 
> 14567345;1;Oil Seal
> 4533457 C;1;Heat Shield
> 56842204;1;Misc Part
> 5481206 D;1;Gasket
> 81003589 I;1;Washer
> T23546 II;1;Shirt
> 
> 
> _______________________________________________
> Boulder-pm mailing list
> Boulder-pm at pm.org
> http://mail.pm.org/mailman/listinfo/boulder-pm

:wq!
---------------------------------------------------------------------------
Robert L. Harris                     | GPG Key ID: E344DA3B
                                         @ x-hkp://pgp.mit.edu
DISCLAIMER:
      These are MY OPINIONS             With Dreams To Be A King,
       ALONE.  I speak for              First One Should Be A Man
       no-one else.                       - Manowar

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.pm.org/pipermail/boulder-pm/attachments/20070331/7190b7dc/attachment.bin 


More information about the Boulder-pm mailing list