denting24by7 has asked for the wisdom of the Perl Monks concerning the following question:
I am doing something wrong trying to build an array that should contain all jscript extension file names. I am very new to perl. I have this working in bash. I know that the first array has the lines containing the jscript file names. Just can't figure out how to remove just them and put them in an array to sort unique items.
#!/usr/bin/perl use strict; use warnings; sub main { my @js = (); my @ujs =(); my $file = 'access_log.txt'; open(FH, $file) or die("File $file not found"); while(my $String = <FH>) { if($String =~ '[^/]*\.js') { push(@js,($String)); #print "$String \n"; @ujs = grep {/[^/]*\.js/}, @js; # print @ujs; } } close(FH); foreach (@ujs) { print "$_\n"; } } main();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Building ARRAY with grep expression NOT working
by hippo (Archbishop) on Mar 31, 2020 at 21:37 UTC | |
by jwkrahn (Abbot) on Apr 01, 2020 at 01:49 UTC | |
by Tux (Canon) on Apr 01, 2020 at 06:08 UTC | |
by GrandFather (Saint) on Apr 01, 2020 at 07:29 UTC | |
| |
by denting24by7 (Initiate) on Apr 02, 2020 at 04:58 UTC | |
by hippo (Archbishop) on Apr 02, 2020 at 10:01 UTC | |
| |
|
Re: Building ARRAY with grep expression NOT working
by Corion (Patriarch) on Mar 31, 2020 at 20:16 UTC | |
|
Re: Building ARRAY with grep expression NOT working
by bliako (Abbot) on Apr 01, 2020 at 08:45 UTC | |
|
Re: Building ARRAY with grep expression NOT working
by Tux (Canon) on Mar 31, 2020 at 20:10 UTC | |
|
Re: Building ARRAY with grep expression NOT working
by leszekdubiel (Scribe) on Apr 04, 2020 at 08:18 UTC |