Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List getters getting in the way #10

Closed
mzedeler opened this issue Jul 4, 2013 · 2 comments
Closed

List getters getting in the way #10

mzedeler opened this issue Jul 4, 2013 · 2 comments

Comments

@mzedeler
Copy link

mzedeler commented Jul 4, 2013

The current implementation of list getters for things like osfamily are
cumbersome to use and not very perlish.

If I want to get all the available osfamily names, as I understand it, I
have to write something like this:

my @families;
my $i = 0;
while(1) {
    my $family = $os->osfamily($i);
    break if $family eq $osfamilies[$i-1];
    push @families, $family;
    $i++;
}

If the method call just returned an array, getting any part of the list
would be simple:

# get first os family
$os->osfamily()[0];

# get last os family
$os->osfamily()[-1];

# get the count of os families
scalar $os->osfamily();

The fact that $os->osfamilies($i) returns the last item on the list for
any number of $i greater that the last index is making it even harder to
work around this problem, since you don't have any simple stopping
condition.

I don't mind writing a patch for this.

@apersaud
Copy link
Member

If you provide a patch, I don't mind including it. Let me know.

@mzedeler
Copy link
Author

Hi @apersaud - thanks for the heads up. I'm not using this module any longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants