in reply to Help to split
Hello, another way (more suitable for a beginner?) to do it:
#!/usr/bin/perl use strict; use warnings; # Get the filename as command line argument my $filename = shift; open my $fh, "<", $filename or die "Can't open $filename"; while ( my $line = <$fh> ) { # go through file, line by line my @fields = split ':', $line; my ($first) = split /\s+/, $fields[4]; print "$first\n"; } close $fh;
Excellence is an art won by training and habituation: we do not act rightly because we have virtue or excellence, but we rather have these because we have acted rightly. -- Will Durant
|
|---|