> 
> 
> Hello Perl type people
> 
>  i am shore i had this working, but its all gone wrong for some resion the
> options do not seem to be getting filled.
>

Actually you were probably 'sure', and it is probably failing for some
'reason'.
 
>  can some one please help
> 

'someone' probably will help, but I don't think there are any 'one's here.

> the program is for searching through a large datafile (poller.cfg)
> and outputting the found data in a more usefull format.
> 

or even a 'useful' format.

> BTW i am not getting payed to dev this script it just make my job eayeser

Nope not 'payed' but possibly 'paid', and very rarely would anyone pay
to 'dev' a script as opposed to 'develop' one. and it probably 'makes'
your job 'easier'.

> and i get to try and lern perl too.

Hopefully you are 'learn'ing Perl.

> i guess this should all be structured better so if you have any
> constructive comments =)

Start with a spell checker, use punctuation, work on the grammar.  Have
a look at:

http://www.catb.org/~esr/faqs/smart-questions.html#writewell

Specifically,

"Write in clear, grammatical, correctly-spelled language

We've found by experience that people who are careless and sloppy
writers are usually also careless and sloppy at thinking and coding
(often enough to bet on, anyway). Answering questions for careless and
sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.

So expressing your question clearly and well is important. If you can't
be bothered to do that, we can't be bothered to pay attention. "

The whole page has valuable insights.

> 
> thank you.
> RichT
> 
> 
> /scanPoller.cfg.pl==================================================
>  more scanPoller.cfg.pl
> #!/usr/local/bin/perl
> #
> 
> use strict;
> use warnings;
> use Getopt::Long;
> 
> my
>
($inFile,$USAGE,$showKey,$site,$found,$foundKeys,@dataFile,@foundSegments,$value);

Declaring all of your variables up front defeats the purpose of 'strict'
and makes it far less useful. You should declare your variables at first
usage and in the proper scopes.


> my ($opt_inFile, $opt_listAllFields, $opt_help ) = (0,0,0);
> my $opt_findField = "agentAddress";
> my $opt_showFields = "segment,agentAddress,community";
> 
> $USAGE = <<USAGETEXT;
> usage: $0 ipaddress
>           the following options are also availble
>           [-inFile filename ] input filename
>           [-findField fieldName ] this is the search key (default is
> agentAddress)
>           [-showFields field names ] feilds to output (default is
> segment,agentAddress,community)
>           [-listAllFields ] list avalible fields
>           [-help] this help text
> USAGETEXT
> 

The above is ok, but you might consider taking the advice of the
Getopt::Long docs and using Pod::Usage to generate error messages and
help text via pod.

> &GetOptions(    "inFile=s",
>                 "findField=s",
>                 "showFields=s",
>                 "listAllFields",
>                 "help|h|H|?|HELP",
>         );
> 

You should drop the C<&> it is not needed in this context. You should
also go back to the docs for Getopt::Long, it does not have the default
$opt_ variables for the options, it instead uses references or a hash. I
assume this is left over from Getopt::Std, and in that case you would
have to declare your $opt_ variables with C<our> instead of C<my>.

> print " listAllFields =$opt_listAllFields\n";  #testing
> print " help =$opt_help\n";  #testing
> 

Docs can be found at 
http://search.cpan.org/~jv/Getopt-Long-2.34/lib/Getopt/Long.pm

And I have an example template that uses Getopt::Long and incorporates
Pod::Usage available here:

http://danconia.org/cgi-bin/request?handler=Content;content=StaticPage;label=getopt_long_template

<snip>

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to