Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.79 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. my $in_vcard = 0;
  6. my @codestack;
  7.  
  8. while (<>) {
  9.     if (/\{\s*$/) {
  10.         push @codestack;
  11.         $in_vcard = 1;
  12.         next;
  13.     } elsif (/\}\s*$$/) {
  14.         if ($in_vcard) {
  15.             if (len(@codestack) > 2) {
  16.                 # just dump code
  17.                 foreach my $line(@codestack) {
  18.                     print;
  19.                 }
  20.                 print;
  21.             } else {
  22.                 my $line = $codestack[0];
  23.                 $line =~s/\{\s*$//;
  24.                 print "$line\n";
  25.                 print $codestack[1];
  26.             }
  27.             $in_vcard = 0;
  28.             @codestack = ();
  29.         }
  30.     } else {
  31.         if ($in_vcard == 1) {
  32.             push @codestack;
  33.         } else {
  34.             print;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement