Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. if (/NAME:/){
  2. my @arr = /NAME:sS*sS*sS*/g or next;
  3. print "$_n" for @arr;
  4. }
  5.  
  6. if (/NAME:/){
  7. my @arr = /NAME:sS*sS*sS*/g or next;
  8. print "$_n" for @arr;
  9. }
  10.  
  11. my ($tmp) = /(?<=NAME: )(.*?)(?=s+DATE:)/g or next;
  12. my @arr = split(/,s+/, $tmp);
  13.  
  14. use strict;
  15. use strict;
  16. use warnings;
  17. use autodie;
  18. use feature qw(say);
  19.  
  20. use constant {
  21. TEXT_FILE => 'file.txt',
  22. NAME_LINE => qr/^NAME:s+/,
  23. };
  24.  
  25. open my $name_fh, "<", TEXT_FILE; # Autodie eliminates need for testing if this worked
  26. while ( my $line = <DATA> ) {
  27. chomp $line;
  28. next unless $line =~ NAME_LINE; # Skip lines if they don't contain name
  29. ( my $name = $line ) =~ s/NAME:s+(.+?)s+DATE.*/$1/;
  30. say qq("$name");
  31. }
  32. close $name_fh;
  33.  
  34. print join ": ", @foo . "n"; # Doesn't work.
  35. say join ": ", @foo; # This works fine.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement