Click to See Complete Forum and Search --> : perl: Lno.pm v0.000001, but i can't get it to work


YaRness
01-25-2001, 11:32 AM
<edit> nevermind, i used the "h2xs" thingie to generate the module, and now it works.

Lno.pm

package Lno;

require 5.005_62;
use strict;
use warnings;

require Exporter;

our @ISA = qw(Exporter);

# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.

# This allows declaration use Lno ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
our %EXPORT_TAGS = ( 'all' => [ qw(

) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our @EXPORT = qw(&prompt

);
our $VERSION = '0.01';


# Preloaded methods go here.
sub prompt
{
#gets one input for each prompt sent.
#returns either list or string, depending on what is wanted
my @values;
foreach (@_)
{
print;
my $input = <STDIN>;
chomp $input;
push @values, $input;
}

return wantarray ? @values : join($", @values);
}

1; # don't forget to return a true value from the file


test.pl

#!/usr/local/bin/perl -w
use strict;
use Lno;
#
my @list = prompt("Enter a thingie: ","Enter another thingie: ");
#
print @list;



that prompt function is my "get_user_input" from other posts... i'm not sure what to name it yet.

i'll prolly add the "mprint" thingie TLD and i hammered out too, just want to get all this module nastiness solid first

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/


[This message has been edited by YaRness (edited 25 January 2001).]

[This message has been edited by YaRness (edited 25 January 2001).]

YaRness
01-25-2001, 04:49 PM
i changed the "prompt" function (would still like a better name for it...). implemented jemfinch's suggestion to use chomp instead of tr/\n//, and i changed the if thingie to a wantarray thingie. the '$"' variable is the LIST_SEPARATOR, which is a whitespace by default. i used that so when you return a bunch of inputs to a string, you can control what the string will look like by setting the '$"' variable (that's a dollar sign followed by a quote.. it was hard to tell in the fubared html man pages).

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/

TheLinuxDuck
01-26-2001, 05:58 PM
What about the possibility of returning a reference to an array, instead of a scalar joined by $"?

Sure, it's easy to split, but what if the one of the inputs uses the same char as $"?

The array ref would ensure easy usage of the return, and the user could join them later if they want..

Just a thought. http://www.linuxnewbie.org/ubb/smile.gif

------------------
TheLinuxDuck
I have a belly button.
:wq

YaRness
01-26-2001, 10:56 PM
sounds doable. i made some other changes to that i think though. i didn't bring home a copy, so i'll hafta look at it when i get back to work monday. i think all i did was add support for a void context call, but who knows. that is probably a better idea though.

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/

TheLinuxDuck
01-27-2001, 12:00 AM
Originally posted by YaRness:
sounds doable. i made some other changes to that i think though. i didn't bring home a copy, so i'll hafta look at it when i get back to work monday. i think all i did was add support for a void context call, but who knows. that is probably a better idea though.


Heh.. I am trying to think of a way to make my scripts and code and stuff I work on at work available at home.. something that's not to terribly difficult to do, and also something that doesn't require me to copy files before i leave.. maybe I need to set a cron job.. http://www.linuxnewbie.org/ubb/smile.gif

Btw, what is h2xs?

------------------
TheLinuxDuck
I have a belly button.
:wq

YaRness
01-27-2001, 09:55 AM
"h2xs -A -X -n modulename" will create a skeleton for module "modulename" in "modulename/modulename.pm" basically it sets up those crazy exporter thingies.

i'm not sure what all the parameters do, but a "perldoc h2xs" might be in order (ok, the -n specifies the modulename, i see that much from perldoc).

------------------
"Assembly of Japanese bicycle require great peace of mind."
Registered Linux User #188285 http://counter.li.org/

Sterling
01-28-2001, 11:55 AM
TLD - Look into running sshd on your system at work, or having it run on some system that has access to your files. Then you can use scp to copy them between machines as needed. VERY nice program.

------------------
-Sterling
"There is no Linuxnewbie.org cabal..."

TheLinuxDuck
01-29-2001, 02:16 AM
Originally posted by Sterling:
TLD - Look into running sshd on your system at work, or having it run on some system that has access to your files. Then you can use scp to copy them between machines as needed. VERY nice program.


Actually, I set up sshd at one point, but got confused when it wanted the keys and such.. I never did figure out how the whole key thing worked..

I know that it asks for passwords, but I wanted to make sure that no one can access it but those who need to. http://www.linuxnewbie.org/ubb/smile.gif

But, I'll take another look at it this week and see if I can't make some better sense of the key thing.. Thanks for the tip, Sterling! http://www.linuxnewbie.org/ubb/smile.gif

------------------
TheLinuxDuck
I have a belly button.
:wq