[18771] in Perl-Users-Digest
Perl-Users Digest, Issue: 939 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 19 14:05:43 2001
Date: Sat, 19 May 2001 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <990295509-v10-i939@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 19 May 2001 Volume: 10 Number: 939
Today's topics:
[ANNOUNCE] Attribute::Abstract 0.01 (Marcel Grunauer)
[ANNOUNCE] Attribute::Memoize 0.01 (Marcel Grunauer)
[ANNOUNCE] Attribute::TieClasses 0.01 (Marcel Grunauer)
[ANNOUNCE] DBIx::Lookup::Field 0.01 <marcel@codewerk.com>
[ANNOUNCE] Devel::SearchINC 0.02 <marcel@codewerk.com>
[ANNOUNCE] GraphViz::DBI 0.01 <marcel@codewerk.com>
[ANNOUNCE] GraphViz::ISA 0.01 <marcel@codewerk.com>
ANNOUNCE: Spreadsheet::WriteExcel 0.32 (John McNamara)
Re: Can anyone help me please? <Ask@For-It.Com>
Re: file names into an array <pne-news-20010519@newton.digitalspace.net>
Re: Hash: keys to variable names, or variable names to <pauljohn@ukans.edu>
Re: HELP NEEDED!!!!! <webmaster@domainenterprises.com>
Re: Korn Shell Conversion <pne-news-20010519@newton.digitalspace.net>
Re: login script <Wojciech.Domalewski@pnti.waw.pl>
Re: modem/serialport experts? (Phil)
Re: Multiple Functions-Same Script/ (Steve)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 May 2001 22:24:01 +0200
From: marcel@codewerk.com (Marcel Grunauer)
Subject: [ANNOUNCE] Attribute::Abstract 0.01
Message-Id: <tgd4isgtan6vdd@corp.supernews.com>
NAME
Attribute::Abstract - implementing abstract methods with attributes
SYNOPSIS
package SomeObj;
use Attribute::Abstract;
sub new { ... }
sub write : Abstract;
DESCRIPTION
Declaring a subroutine to be abstract using this attribute causes a call
to it to die with a suitable exception. Subclasses are expected to
implement the abstract method.
Using the attribute makes it visually distinctive that a method is
abstract, as opposed to declaring it without any attribute or method
body, or providing a method body that might make it look as though it
was implemented after all.
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel Gr¸nauer, <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Gr¸nauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: Fri, 18 May 2001 22:31:18 +0200
From: marcel@codewerk.com (Marcel Grunauer)
Subject: [ANNOUNCE] Attribute::Memoize 0.01
Message-Id: <tgd4j7q66juie0@corp.supernews.com>
NAME
Attribute::Memoize - Attribute interface to Memoize.pm
SYNOPSIS
use Attribute::Memoize;
sub fib :Memoize {
my $n = shift;
return $n if $n < 2;
fib($n-1) + fib($n-2);
}
$|++;
print fib($_),"\n" for 1..50;
DESCRIPTION
This module makes it slightly easier (and modern) to memoize a function
by providing an attribute, `:Memoize' that makes it unnecessary for you
to explicitly call `Memoize::memoize()'. Options can be passed via the
attribute per usual (see the `Attribute::Handlers' manpage for details,
and the `Memoize' manpage for information on memoizing options):
sub f :Memoize(NORMALIZER => 'main::normalize_f') {
...
}
However, since the call to `memoize()' is now done in a different
package, it is necessary to include the package name in any function
names passed as options to the attribute, as shown above.
TODO
test.pl
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel Gr¸nauer, <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Gr¸nauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1), Attribute::Handlers(3pm).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: Fri, 18 May 2001 22:32:02 +0200
From: marcel@codewerk.com (Marcel Grunauer)
Subject: [ANNOUNCE] Attribute::TieClasses 0.01
Message-Id: <tgd4jlpbsgn6e4@corp.supernews.com>
NAME
Attribute::TieClasses - attribute wrappers for CPAN Tie classes
SYNOPSIS
use Attribute::TieClasses;
my $k : Timeout(EXPIRES => '+2s');
# loads in Tie::Scalar::Timeout and tie()s $k with those options
DESCRIPTION
Damian Conway's wonderful `Attribute::Handlers' module provides an easy
way to use attributes for `tie()'ing variables. In effect, the code in
the synopsis is simply
use Attribute::Handlers
autotie => { Timeout => 'Tie::Scalar::Timeout' };
Still, going one step further, it might be useful to have centrally
defined attributes corresponding to commonly used Tie classes found on
CPAN.
Simply `use()'ing this module doesn't bring in all those potential Tie
classes; they are only loaded when an attribute is actually used.
The following attributes are defined:
Attribute name(s) Variable ref Class the variable is tied to
================= ============ =============================
Alias HASH Tie::AliasHash
Aliased HASH Tie::AliasHash
Cache HASH Tie::Cache
CharArray ARRAY Tie::CharArray
Counter SCALAR Tie::Counter
Cycle SCALAR Tie::Cycle
DBI HASH Tie::DBI
Decay SCALAR Tie::Scalar::Decay
Defaults HASH Tie::HashDefaults
Dict HASH Tie::TieDict
Dir HASH Tie::Dir
DirHandle HASH Tie::DirHandle
Discovery HASH Tie::Discovery
Dx HASH Tie::DxHash
Encrypted HASH Tie::EncryptedHash
FileLRU HASH Tie::FileLRUCache
Fixed HASH Tie::SubstrHash
FlipFlop SCALAR Tie::FlipFlop
IPAddrKeyed HASH Tie::NetAddr::IP
Insensitive HASH Tie::CPHash
Ix HASH Tie::IxHash
LDAP HASH Tie::LDAP
LRU HASH Tie::Cache::LRU
ListKeyed HASH Tie::ListKeyedHash
Math HASH Tie::Math
Mmap ARRAY Tie::MmapArray
NumRange SCALAR Tie::NumRange
NumRangeWrap SCALAR Tie::NumRangeWrap (in Tie::NumRange)
Offset ARRAY Tie::OffsetArray
Ordered HASH Tie::LLHash
PackedInt ARRAY Tie::IntegerArray
PerFH SCALAR Tie::PerFH
Persistent HASH Tie::Persistent
RDBM HASH Tie::RDBM
Range HASH Tie::RangeHash
RangeKeyed HASH Tie::RangeHash
Rank HASH Tie::Hash::Rank
Ranked HASH Tie::Hash::Rank
Ref HASH Tie::RefHash
Regexp HASH Tie::RegexpHash
RegexpKeyed HASH Tie::RegexpHash
Secure HASH Tie::SecureHash
Sentient HASH Tie::SentientHash
Shadow HASH Tie::ShadowHash
Shadowed HASH Tie::ShadowHash
Sort HASH Tie::SortHash
Sorted HASH Tie::SortHash
Strict HASH Tie::StrictHash
Substr HASH Tie::SubstrHash
TextDir HASH Tie::TextDir
Timeout SCALAR Tie::Scalar::Timeout
Toggle SCALAR Tie::Toggle
Transact HASH Tie::TransactHash
TwoLevel HASH Tie::TwoLevelHash
Vec ARRAY Tie::VecArray
Vector ARRAY Tie::VecArray
WarnGlobal SCALAR Tie::WarnGlobal::Scalar
I haven't had occasion to test all of these attributes; they were taken
from the module descriptions on CPAN. For some modules where the name
didn't ideally translate into an attribute name (e.g.,
`Tie::NetAddr::IP'), I have taken some artistic liberty to create an
attribute name. Some tie classes require the use of the return value
from `tie()' and are as such not directly usable by this mechanism,
AFAIK.
No censoring has been done as far as possible; there are several
attributes that accomplish more or less the same thing. TIMTOWTDI.
If you want any attribute added or renamed or find any mistakes or
omissions, please contact me at <marcel@codewerk.com>.
EXAMPLES
# Tie::Scalar::Timeout
my $m : Timeout(NUM_USES => 3, VALUE => 456, POLICY => 777);
print "$m\n" for 1..5;
# Tie::Hash::Rank
my %scores : Ranked;
%scores = (
Adams => 78,
Davies => 35,
Edwards => 84,
Thomas => 47
);
print "$_: $scores{$_}\n" for qw(Adams Davies Edwards Thomas);
# Tie::FlipFlop;
my $ff : FlipFlop(qw/Red Green/);
print "$ff\n" for 1..5;
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel Gr¸nauer, <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Gr¸nauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1), Attribute::Handlers(3pm).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: 19 May 2001 11:45:08 GMT
From: Marcel Grunauer <marcel@codewerk.com>
Subject: [ANNOUNCE] DBIx::Lookup::Field 0.01
Message-Id: <tgd4l1aav1cgef@corp.supernews.com>
NAME
DBIx::Lookup::Field - Create a lookup hash from a database table
SYNOPSIS
use DBI;
use DBIx::Lookup::Field qw/dbi_lookup_field/;
$dbh = DBI->connect(...);
my $inst_id = dbi_lookup_field(
DBH => $dbh,
TABLE => 'institution'
KEY => 'name',
VALUE => 'id',
);
print "Inst_A has id ", $inst_id->{Inst_A};
DESCRIPTION
This module provides a way to construct a hash from a database table.
This is useful for the situation where you have to perform many lookups
of a field by using a key from the same table. If, for example, a table
has an id field and a name field and you often have to look up the name
by its id, it might be wasteful to issue many separate SQL queries.
Having the two fields as a hash speeds up processing, although at the
expense of memory.
EXPORTS
dbi_lookup_field()
This function creates a hash from two fields in a database table on
a DBI connection. One field acts as the hash key, the other acts as
the hash value. It expects a parameter hash and returns a reference
to the lookup hash.
The following parameters are accepted. Parameters can be required or
optional. If a required parameter isn't given, an exception is
raised (i.e., it dies).
DBH The database handle through which to access the table from which
to create the lookup. Required.
TABLE
The name of the table that contains the key and value fields.
Required.
KEY The field name of the field that is to act as the hash key.
Required.
VALUE
The field name of the field that is to act as the hash value.
Required.
WHERE
A SQL 'WHERE' clause with which to restrict the 'SELECT'
statement that is used to create the hash. Optional.
BUGS
None known at this time. If you find any oddities or bugs, please do
report them to the author.
AUTHOR
Marcel Grünauer <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Grünauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
DBI(3pm).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: 19 May 2001 11:42:32 GMT
From: Marcel Grunauer <marcel@codewerk.com>
Subject: [ANNOUNCE] Devel::SearchINC 0.02
Message-Id: <tgd4kob6ddo7ed@corp.supernews.com>
NAME
Devel::SearchINC - loading Perl modules from their development dirs
SYNOPSIS
use Devel::SearchINC '/my/dev/dir';
use My::Brand::New::Module;
DESCRIPTION
When developing a new module, I always start with
h2xs -XA -n My::Module
This creates a directory with a useful skeleton for the module's
distribution. The directory structure is such, however, that you have to
install the module first (with `make install') before you can use it in
another program or module. For example, bringing in a module like so:
use My::Module;
requires the module to be somewhere in a path listed in `@INC', and the
relative path is expected to be `My/Module.pm'. However, `h2xs' creates
a structure where the module ends up in `My/Module/Module.pm'.
This module tries to compensate for that. The idea is that you `use()'
it right at the beginning of your program so it can modify `@INC' to
look for modules in relative paths of the special structure mentioned
above, starting with directories specified along with the `use()'
statement (i.e. the arguments passed to this module's `import()').
This is useful because with this module you can test your programs using
your newly developed modules without having to install them just so you
can use them. This is especially advantageous when you consider working
on many new modules at the same time.
TODO
Test on different platforms and Perl versions.
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel Grünauer, <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Grünauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: 19 May 2001 12:01:19 GMT
From: Marcel Grunauer <marcel@codewerk.com>
Subject: [ANNOUNCE] GraphViz::DBI 0.01
Message-Id: <tgd4lckg2ct9f2@corp.supernews.com>
NAME
GraphViz::DBI - graph database tables and relations
SYNOPSIS
use GraphViz::DBI;
print GraphViz::DBI->new($dbh)->graph_tables->as_png;
DESCRIPTION
This module constructs a graph for a database showing tables and
connecting them if they are related. While or after constructing the
object, pass an open database handle, then call `graph_tables' to
determine database metadata and construct a GraphViz graph from the
table and field information.
METHODS
The following methods are defined by this class; all other method calls
are passed to the underlying GraphViz object:
new( [$dbh] )
Constructs the object; also creates a GraphViz object. The
constructor accepts an optional open database handle.
set_dbh($dbh)
Sets the database handle.
get_dbh()
Returns the database handle.
is_table($table)
Checks the database metadata whether the argument is a valid table
name.
is_foreign_key($table, $field)
Determines whether the field belonging to the table is a foreign key
into some other table. If so, it is expected to return the name of
that table. If not, it is expected to return a false value.
For example, if there is a table called "product" and another table
contains a field called "product_id", then to indicate that this
field is a foreign key into the product table, the method returns
"product". This is the logic implemented in this class. You can
override this method in a subclass to suit your needs.
graph_tables()
This method goes through all tables and fields and calls appropriate
methods to determine which tables and which dependencies exist, then
hand the results over to GraphViz. It returns the GraphViz object.
TODO
* Test with various database drivers to see whether they support the
metadata interface.
* Provide the possibility to name edges to specify the type of
relationship ('has-a', 'is-a', etc.).
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel Grünauer <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Grünauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1), GraphViz(3pm).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: 19 May 2001 12:01:42 GMT
From: Marcel Grunauer <marcel@codewerk.com>
Subject: [ANNOUNCE] GraphViz::ISA 0.01
Message-Id: <tgd4llbjuouf4@corp.supernews.com>
NAME
GraphViz::DBI - graph database tables and relations
SYNOPSIS
use GraphViz::DBI;
print GraphViz::DBI->new($dbh)->graph_tables->as_png;
DESCRIPTION
This module constructs a graph for a database showing tables and
connecting them if they are related. While or after constructing the
object, pass an open database handle, then call `graph_tables' to
determine database metadata and construct a GraphViz graph from the
table and field information.
METHODS
The following methods are defined by this class; all other method calls
are passed to the underlying GraphViz object:
new( [$dbh] )
Constructs the object; also creates a GraphViz object. The
constructor accepts an optional open database handle.
set_dbh($dbh)
Sets the database handle.
get_dbh()
Returns the database handle.
is_table($table)
Checks the database metadata whether the argument is a valid table
name.
is_foreign_key($table, $field)
Determines whether the field belonging to the table is a foreign key
into some other table. If so, it is expected to return the name of
that table. If not, it is expected to return a false value.
For example, if there is a table called "product" and another table
contains a field called "product_id", then to indicate that this
field is a foreign key into the product table, the method returns
"product". This is the logic implemented in this class. You can
override this method in a subclass to suit your needs.
graph_tables()
This method goes through all tables and fields and calls appropriate
methods to determine which tables and which dependencies exist, then
hand the results over to GraphViz. It returns the GraphViz object.
TODO
* Test with various database drivers to see whether they support the
metadata interface.
* Provide the possibility to name edges to specify the type of
relationship ('has-a', 'is-a', etc.).
BUGS
None known so far. If you find any bugs or oddities, please do inform
the author.
AUTHOR
Marcel Grünauer <marcel@codewerk.com>
COPYRIGHT
Copyright 2001 Marcel Grünauer. All rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
SEE ALSO
perl(1), GraphViz(3pm).
Marcel
--
We are Perl. Your table will be assimilated. Your waiter will adapt to
service us. Surrender your beer. Resistance is futile.
-- London.pm strategy aka "embrace and extend" aka "mark and sweep"
------------------------------
Date: Fri, 18 May 2001 22:36:22 GMT
From: jmcnamara@cpan.org (John McNamara)
Subject: ANNOUNCE: Spreadsheet::WriteExcel 0.32
Message-Id: <tgd4jt3aeff8e6@corp.supernews.com>
======================================================================
ANNOUNCE
Spreadsheet::WriteExcel version 0.32 has been uploaded to CPAN.
======================================================================
NAME
Spreadsheet::WriteExcel - Write formatted text and numbers to a
cross-platform Excel binary file.
======================================================================
CHANGES
The facility to add panes and freeze panes has been added.
Page setup options have been added such as headers and footers,
margins, paper type, page orientation, and centering.
======================================================================
DESCRIPTION
The Spreadsheet::WriteExcel module can be used create a cross-
platform Excel binary file. Multiple worksheets can be added to a
workbook and formatting can be applied to cells. Text, numbers,
formulas and hyperlinks can be written to the cells.
The Excel file produced by this module is compatible with Excel 5,
95, 97 and 2000.
The module will work on the majority of Windows, UNIX and
Macintosh platforms. Generated files are also compatible with the
Linux/UNIX spreadsheet applications OpenOffice, Gnumeric and XESS.
The generated files are not compatible with MS Access.
This module cannot be used to read an Excel file. See
Spreadsheet::ParseExcel or look at the main documentation for some
suggestions. This module cannot be uses to write to an existing
Excel file.
======================================================================
SYNOPSIS
To write a string, a formatted string, a number and a formula to
the first worksheet in an Excel workbook called perl.xls:
use Spreadsheet::WriteExcel;
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("perl.xls");
# Add a worksheet
$worksheet = $workbook->addworksheet();
# Add and define a format
$format = $workbook->addformat(); # Add a format
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
# Write a formatted and unformatted string
$col = $row = 0;
$worksheet->write($row, $col, "Hi Excel!", $format);
$worksheet->write(1, $col, "Hi Excel!");
# Write a number and a formula using A1 notation
$worksheet->write('A3', 1.2345);
$worksheet->write('A4', '=SIN(PI()/4)');
======================================================================
REQUIREMENTS
This module requires Perl 5.005 (or later) and Parse::RecDescent:
http://search.cpan.org/search?dist=Parse-RecDescent
======================================================================
INSTALLATION
Method 1
Download the zipped tar file from one of the following:
http://search.cpan.org/search?dist=Spreadsheet-WriteExcel
http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search?idinfo=154
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/J/JM/JMCNAMARA/
Unzip the module as follows or use winzip:
tar -zxvf Spreadsheet-WriteExcel-0.xx.tar.gz
The module can be installed using the standard Perl procedure:
perl Makefile.PL
make
make test
make install # You may need to be root
make clean # or make realclean
Windows users without a working "make" can get nmake from:
ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe
Method 2
If you have CPAN.pm configured you can install the module as
follows:
perl -MCPAN -e "install 'Spreadsheet::WriteExcel'"
Method 3
ActivePerl users can use PPM as follows:
C:\> ppm
PPM> set repository tmp
http://homepage.eircom.net/~jmcnamara/perl
PPM> install Spreadsheet-WriteExcel
PPM> quit
C:\>
If this fails try the following:
PPM>install
http://homepage.eircom.net/~jmcnamara/perl/Spreadsheet-WriteExcel.ppd
If you wish to perform a local PPM install you can get the files
from:
http://homepage.eircom.net/~jmcnamara/perl/Spreadsheet-WriteExcel.ppd
http://homepage.eircom.net/~jmcnamara/perl/Spreadsheet-WriteExcel-0.xx-PPM.tar.gz
======================================================================
AUTHOR
John McNamara (jmcnamara@cpan.org)
--
------------------------------
Date: Sat, 19 May 2001 16:50:39 +0100
From: "Robb Meade" <Ask@For-It.Com>
Subject: Re: Can anyone help me please?
Message-Id: <9e64l1$mnb$1@news8.svr.pol.co.uk>
The subject was 'could I get some help please' - and that was what I
posted...
Being new to this group I did somewhat expect maybe a little more of a
friendly welcome.
I did try to explain the problem to the best of my ability in a number of
the posts, not having a knowledge of Perl didnt make that easy. Seems
people here were more interested in taking the piss, and try to look clever
about it, rather than being more friendly and helpful.
I wont bother you again.
Thanks anyway.
--
Robb Meade
Kingswood Web Services
www.kingswoodweb.net
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9gcq26.ugl.tadmc@tadmc26.august.net...
> Robb Meade <Ask@For-It.Com> wrote:
>
> >Subject: Can anyone help me please?
>
>
> Can you put the subject of your post in the Subject of your post please?
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Sat, 19 May 2001 18:11:06 +0200
From: Philip Newton <pne-news-20010519@newton.digitalspace.net>
Subject: Re: file names into an array
Message-Id: <o16dgtcf440u36r6qds4k0nveq8ihir0r7@4ax.com>
On Sat, 19 May 2001 23:43:42 +1000, "Nicole" <x@y.com> wrote:
> I have a number of text files (*.txt) in a directory.
>
> I want to put all the names for those files into an array called @files.
>
> How can I do this?
Here's one way:
> @files = <*.txt>;
Another way is to use readdir. Look up opendir, readdir, and closedir in
perlfunc.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 19 May 2001 11:38:33 -0500
From: "Paul Johnson" <pauljohn@ukans.edu>
Subject: Re: Hash: keys to variable names, or variable names to keys?
Message-Id: <tgd8gu3m8m1hf1@corp.supernews.com>
Thanks for the help. This is just what I needed!
<tadmc@augustmail.com> wrote:
> Paul Johnson <pauljohn@ukans.edu> wrote:
>>I wrote a CGI script that processes a bunch of string variables and
>>saves them into a dataset. I find my self doing the same repetitive,
>>stupid things, one variable after another.
>
>
>
> I suggest that you rewrite your program to use a hash instead of a bunch
> of individually named scalars. This has 2 benefits:
>
> 1) no Symbolic references
> 2) your "validation" problem becomes trivial
>
> #1 alone should be enough to convince you the change is warranted.
>
> See:
>
> http://www.plover.com/~mjd/perl/varvarname.html
> http://www.plover.com/~mjd/perl/varvarname2.html
> http://www.plover.com/~mjd/perl/varvarname3.html
>
<snip>
>
> A rough untested sketch of how it might be done:
>
>
> my %p; # (p)arameters
> # loading would really be done in a loop $p{lastname} =
> $cgi_input->param('lastname'); $p{firstname} =
> $cgi_input->param('firstname'); ...
>
> my %max = qw(
> lastname 30
> firstname 20
> );
>
> foreach my $param ( sort keys %p ) {
> if ( length $p{$param} > $max{$param} ) {
> print "'$param' field is too long (maximum is $max{$param})\n";
> }
> }
>
------------------------------
Date: Sat, 19 May 2001 12:49:45 -0500
From: John Martin Ping <webmaster@domainenterprises.com>
Subject: Re: HELP NEEDED!!!!!
Message-Id: <3B06B239.DA8D45DC@domainenterprises.com>
I would check with your service provider for you website. There could be an error in the httpd.conf
file that will not allow you run .cgi or .pl programs that instead displays them as a plain text file.
I have seen this happen before to people. Hope it helps.
TheMaster
OOooooH Yeah wrote:
> Hi guys!
>
> I am new to this ...just having a little bit of problem with this
> code...when executed it prints out not just the HTML code but also
> displays the perl code which it isn't suppose to. I can't figure out
> why it is showing perl code....Any help would be greatly appreciated....
>
> here is the code..
>
> #!/usr/bin/perl
>
> use CGI;
>
> print "Content-type: text/html \n\n";
>
> #read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
>
> print "<html><body
> background=http://www.blah.com/~cgi/csc5750/bground1.jpg>";
>
> if ($ENV {REQUEST_METHOD} eq 'GET')
> {
> $user_input = $ENV{QUERY_STRING};
> }
> else
> {
> #$user_input = $query_string;
> #chomp($user_input);
> chomp($user_input=<STDIN>);
> }
>
> %input;
> $delim = ";";
>
> $remote_host = $ENV{'REMOTE_HOST'};
> #$order_file_name ="orders/orders.txt"; # "orders/".$remote_host;
> $order_file_name ="orders/".$remote_host;
>
> if($user_input eq 'd=cart'){
> if(-e $order_file_name){
>
> &view_cart();
>
> exit;
> } else {
>
> print "<center><h2>Your Shopping Cart is empty .
> <BR><BR>";
> print '<table><tr><td valign="top"
> align=center> <p><big>search books</big></p>
> <form method="POST"
> action="http://www.blah.edu/~cgi/user-cgi/book.pl">
> <strong>Search:</strong><input type="text" name="string"
> size="20"><input type="submit" value="Search" name="search">
> </form>
>
> </td></tr></table>
>
> ';
>
> print '<table><tr><td valign="top" align=center>
> <form method="POST"
> action="http://www.blah.edu/~cgi/user-cgi/empty_cart.pl">
> <p align=center><input type="submit" value="Empty Cart" name="B1"></p>
>
> <p align=center><a href
> ="http://www.blah.edu/~cgi/csc5750/project/search.html"><input
> type="button" value="Buy more" name="buy"></a></p>
> </form>
>
> </td></tr></table>
> ';
> print "<p><a href=http://www.blah.edu/~cgi/project/main.html><img
> SRC=http://www.cs.wayne.edu/~hassan/csc5750/email2.gif ALIGN=\"center\"
> > </A>";
> exit;
> }
> }
>
> &parsedata();
>
> &appendtofile();
> &view_cart();
>
> sub parsedata(){
> @key_value_pairs = split(/&/, $user_input);
> foreach $key_value(@key_value_pairs){
> ($key,$value)=split(/=/, $key_value);
> $value =~ tr/+/ /;
> $input{$key}=$value;
>
> }
> }
>
> sub appendtofile(){
>
> if (-e $order_file_name) {
> open(order_file, $order_file_name)|| die "Cannot open $order_file_name
> for reading\n" ;
>
> while (<order_file>) {
> chop;
> ($item_id, $item_name, $item_price, $item_qty) = split(/$delim/,$_);
>
> }
> close (order_file);
> }
> else
> {
> open (order_file, ">> $order_file_name") || die "CAN'T CREATE
> FILE $order_file_name";
> close (order_file);
> }
>
> open(order_file, ">>$order_file_name") || die "Cannot open
> $order_file_name for writing\n";
>
> if ($input{'ITEM_QTY'} > 0)
> {
> print order_file
> $input{'ITEM_ID'}.$delim.$input{'ITEM_NAME'}.$delim.$input{'ITEM_PRICE'}.$delim.$input{'ITEM_QTY'};
>
> print order_file "\n";
> }
> else
> {
> print "<center><h3>Quantity entered was 0, Please go back and enter a
> valid ";
> print "quantity for at the item</h3></center>";
>
> exit;
> }
> close (order_file);
> }
>
> sub view_cart(){
>
> if (-e $order_file_name) {
> open(order_file, "$order_file_name") || die "Cannot open
> $order_file_name for reading\n";
>
> $sub_total = 0;
> print "<body
> background=http://www.blah.edu/~cgi/csc5750/project/bground1.jpg>";
> print "<form method=post
> action=\"http://www.cs.wayne.edu/~hassan/csc5750/register.html\">";
> print "<center><table border=0 cellspacing=0
> cellpadding=0><caption><font SIZE=+1>INVOICE<\/font><\/caption>";
> print '<tr><td align=center><B><H3>ISBN NO<BR></td><TD
> align=center><B><H3>Book Title</TD><TD><B><H3>Qty</TD>';
> print '<TD align=center><B><H3>Unit Price</TD><TD><B><H3>Item
> Total</TD></tr>';
> while(<order_file>){
> chop;
> ($item_id,$item_name,$price,$quantity) = split(/$delim/, $_);
> print "<tr>";
> $item_total = $price * $quantity;
> $sub_total = $sub_total + $item_total;
> print "<td align=center>$item_id<\/td><td align=left>$item_name<\/td>";
>
> $item_total = &Currency ($item_total);
> $price = &Currency($price);
> print "<td align=right>$quantity<\/td><td align=right>$price<\/td><td
> align=right>$item_total<\/td><\/tr>";
> }
> $tax = $sub_total * 0.06;
> $shipping = ($sub_total < 50)? 0 : $sub_total * 0.1;
> $total = $sub_total + $tax + $shipping;
> $sub_total = &Currency($sub_total);
> $total = &Currency($total);
> $shipping = &Currency($shipping);
> $tax = &Currency($tax);
> print '<TR><TD colspan=5> </TD>';
> print "<tr align=left><td colspan=3> <\/td><td align=left><B>Sub
> Total: <\/td><td align=right>$sub_total<\/td><\/tr>";
> print "<tr align=left><td colspan=3> <\/td><td align=left><B>State
> Tax 6\%: <\/td><td align=right>$tax<\/td><\/tr>";
> print "<tr align=left><td colspan=3> <\/td><td
> align=left><B>Shipping:<\/td><td align=right>$shipping<\/td><\/tr>";
> print "<tr align=left><td colspan=3> <\/td><td
> align=left><B>Total:<\/td><td align=right>$total<\/td><\/tr>";
> print "<\/table></center>";
>
> # print "<br><br><center><input type=submit value=\"CHECKOUT\">";
> print "<center><A
> href=http://www.blah.edu/~cgi/csc5750/project/register.html><img
> SRC=http://www.blah.edu/~cgi/csc5750/project/book4.gif ALIGN=\"center\"
> ";
>
> print "<FONT COLOR=yellow><CENTER><A
> HREF='http://www.cs.wayne.edu/~hassan/csc5750/project/register.html'>CHECKOUT</CENTER></FONT></A>";
>
> print '</form></center>';
>
> print '
> <form method="POST"
> action="http://www.blahblah.com/~cgi/user-cgi/empty_cart.pl">
> <center><input type="submit" value="EMPTY Cart" name="B1"></center>
> </form>';
>
> }
> close (order_file);
> }
>
> sub Currency {
> my $price = $_[0];
> $price = sprintf("%.2f", $price);
> $price = "\$".$price;
> return $price;
> }
> print "</body></html>";
>
> Thank You
------------------------------
Date: Sat, 19 May 2001 18:11:06 +0200
From: Philip Newton <pne-news-20010519@newton.digitalspace.net>
Subject: Re: Korn Shell Conversion
Message-Id: <ho5dgto26vepknot4vhjioh9agnfp0v3c1@4ax.com>
On Fri, 18 May 2001 18:18:21 -0400, "John Irwin" <jgi@mindspring.com>
wrote:
> Can anyone suggest a source of a Korn Shell to Perl conversion utility?
^^^^^ ^^^^^^^^^^
FAQ. perldoc -q "convert my shell script"
(Both `perldoc -q convert` and `perldoc -q shell` would have found that
answer; both of those keywords are (nearly) in your question. You should
have used them.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sat, 19 May 2001 17:28:31 GMT
From: Wojciech Domalewski <Wojciech.Domalewski@pnti.waw.pl>
Subject: Re: login script
Message-Id: <3B06AA63.17274E00@pnti.waw.pl>
Franco Luissi wrote:
> what do you want from the CGI?
> you may not need it if you are running on Apache, you may find the
> .htaccess and .htpasswd file setup is all you need- but there are modules
> if you need a script to interact with those files-
> it depend what you want, search "htaccess" on CPAN, I know there is
> Apache::HtAccess and Apache::HtPasswd as well as at least one other-
Ok, maybe that's what I want. Thanks.
> Wojciech Domalewski wrote:
>
> > Hello:
> >
> > Does anyone knows if there's any perl cgi script that performs user
> > authentication (Apache/.htaccess)?
> >
> > And what modules if any, to be compiled with apache, is required before
> > this can be done?
> >
> > Thanks!
> >
> > Wojciech.Domalewski@pnti.waw.pl .
------------------------------
Date: 19 May 2001 17:17:47 GMT
From: eclipsephil@aol.comnospam (Phil)
Subject: Re: modem/serialport experts?
Message-Id: <20010519131747.07735.00000417@ng-fz1.aol.com>
manos thanks for your interest. No your English is fine and your comments most
welcome. The problem with lookclear and matchclear is that they clear upto a
matched character if I am getting garbage then I dont know what to expect. I
think I will change the are_match to match anyting (although I havnt worked out
if this is possbiel yet) and wait until I get a timeout ie I have read all the
garbage and all is now clear. Thanks again!
Phil.
Live the Journey!
For each destination is but a doorway to another!
------------------------------
Date: 19 May 2001 16:21:04 GMT
From: steve@zeropps.uklinux.net (Steve)
Subject: Re: Multiple Functions-Same Script/
Message-Id: <slrn9gd6qv.q63.steve@zero-pps.localdomain>
On Sat, 19 May 2001 07:48:48 -0700, Webmaster wrote:
>Is it possible to have mutiple actions posted within the same script?
Yes. But I tend to do the HTML in perl too using CGI.pm. As always
there is more than one way to do it, have a look around at:
http://www.stonehenge.com/merlyn/WebTechniques/
There's an article over there about this.
And there's a script using another method here:
http://www.zeropps.uklinux.net/cgi-bin/viewimages.cgi
--
Cheers
Steve email mailto:steve@zeropps.uklinux.net
%HAV-A-NICEDAY Error not enough coffee 0 pps.
web http://www.zeropps.uklinux.net/
or http://start.at/zero-pps
4:57pm up 106 days, 17:45, 2 users, load average: 1.50, 1.31, 1.29
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 939
**************************************