gopikavi has asked for the wisdom of the Perl Monks concerning the following question:

no expected output with my perl cgi script
#!/usr/bin/local/perl print "Content-Type:text/html\n\n"; open(file,"cpfsk.access"); @project_name=grep { $_ =~ m/^\[/} <file>; close file; print @project_name; #!/usr/bin/local/perl print "Content-Type:text/html\n\n"; open(INFILE,'<',"cpfsk.access"); while($line=<INFILE>) { chomp; $project_name=grep \[*\],$line; print $project_name; } close(INFILE);
cpfsk.access:
cpfskTeam = sonkar, mobrien3, dokeeff2, pquinla, hkumar3 [cpfsk:/] * = r @cpfskTeam = rw @serveradmins = rw @svnadmin = rw
expected output: cpfsk
obtained output:
cpfsk:/

Replies are listed 'Best First'.
Re: Not enough arguments script with my perl cgi script?
by Anonymous Monk on May 08, 2017 at 06:59 UTC
      Edited my code.But seems to be problem .

      Original content restored below by [GrandFather.

      EDITED MY CODE BY THOSE DOCUMENTATION WHICH YOU HAVE PROVIDED ME.WHICH MISTAKE BY ME HAD BRING ME WRONG OUTPUT FROM THE ABOVE CODE

        Use a capture () to extract the part you want

        #!/usr/bin/local/perl use strict; use Data::Dump 'pp'; my @project_name = (); while (my $line = <DATA>){ if ( $line =~ m!\[(.*):/\]! ){ push @project_name,$1; } } pp \@project_name; __DATA__ cpfskTeam = sonkar, mobrien3, dokeeff2, pquinla, hkumar3 [cpfsk:/] * = r @cpfskTeam = rw @serveradmins = rw @svnadmin = rw
        poj
        you can't guess at the syntax you're supposed to use, the good news is you dont have to guess, copy/paste from the documentation