Re: remove newlines / perl /concise example

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 30 December 2010 21:57, ken <gebser@xxxxxxxxxxxx> wrote:
> Thanks for the previous tips and suggestions.  Here's a more concise
> example:
>
> Input file:
>
> <aaaa>
> <bbbb>
> <cccc>
> <dddd>
>
> I want everything on one line, i.e., remove all newlines.  Like so:
>
> <aaaa><bbbb><cccc><dddd>
>
> Simple perl code:

Code like this is often simpler if you use the Unix filter model and
let the operating system take care of opening all the files.

  #!/usr/bin/env perl

  use strict;
  use warnings;

  chomp(my @lines = <>);

  print @lines;

If this is in a file called 'join', you can run it like this:

 $ ./join < input.txt > output.txt

hth,

Dave...

-- 
Dave Cross :: dave@xxxxxxxxxxx
http://dave.org.uk/
@davorg
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux