Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- xxx.xxx.xxx.xxx hostname #comments. i.dont. care. about
- if($line =~ m/(S+)s+(S+)/) {
- $ip = $1;
- $hostname = $2;
- }
- my @arr = split(/ /, $line);
- $ip = $arr[0];
- $hostname = $arr[1];
- #!/usr/bin/perl -n
- chop; # strip newline (in case next line doesn't strip it)
- s/#.*//; # strip comments
- next unless /S/; # don't process line if it has nothing (left)
- @fields = (split)[0,1]; # split line, and get wanted fields
- print join(' ', @fields), "n";
- @fields = (split /:/)[0,2,4..6];
- perl -ane 'print "@F[0,1]n";'
- perl -ape '$_="@F[0,1]
- "'
- perl -nae 'print "$F[0] $F[1]n";'
- perl -nae 'print "$F[0] $F[1}n";
- -a turns on autosplit mode when used with a -n or -p. An implicit split
- command to the @F array is done as the first thing inside the implicit
- while loop produced by the -n or -p.
- LINE:
- while (<>) {
- ... # your program goes here
- }
- while (my $line = <ARGV>) {
- chop $line;
- $line =~ s/#.*//;
- next unless $line =~ /S/;
- @fields = (split ' ', $line)[0,1];
- print join(' ', @fields), "n";
- }
Add Comment
Please, Sign In to add comment