[24040] in Perl-Users-Digest
Perl-Users Digest, Issue: 6237 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 9 11:05:59 2004
Date: Tue, 9 Mar 2004 08:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 9 Mar 2004 Volume: 10 Number: 6237
Today's topics:
$result = system('/usr/bin/cksum TEST.mp3 >&1'); <news@vangee.nl>
Re: $result = system('/usr/bin/cksum TEST.mp3 >&1'); <nobull@mail.com>
Re: $result = system('/usr/bin/cksum TEST.mp3 >&1'); <vetro@online.no>
ANNOUNCE: AFS Perl API 2.2.1 released <nog@MPA-Garching.MPG.DE>
ANNOUNCE: CGI::Session::MembersArea V 1.00 <ron@savage.net.au>
ANNOUNCE: DBIx::Admin::TableInfo V 1.01 <ron@savage.net.au>
ANNOUNCE: ExtUtils::ModuleMaker::TT v0.70 <dg-junk@hyperbolic.net>
ANNOUNCE: FramesReady-1.016 now available <aederhaag@comcast.net>
ANNOUNCE: Javascript::MD5 V 1.00 <ron@savage.net.au>
ANNOUNCE: XML::EasySQL (curtisleefulton)
Beginner Perl Help - Substituting Strings (Tom)
Re: Beginner Perl Help - Substituting Strings (Anno Siegel)
Re: Beginner Perl Help - Substituting Strings <vetro@online.no>
Re: Daemon with Perl <tadmc@augustmail.com>
Flat file database problem <abcsydney@ans.com.au>
Re: Flat file database problem <nobull@mail.com>
Re: Flat file database problem <ramprasad.padmanabhan@nospam.oracle.com>
How to comment more than one line in Perl? (cayenne)
Re: How to comment more than one line in Perl? <jurgenex@hotmail.com>
Re: How to comment more than one line in Perl? <josef.moellers@fujitsu-siemens.com>
Re: How to modify struct value within a list (Anno Siegel)
Re: Is it possible to impose a timeout on <>? <bart.lateur@pandora.be>
Re: MS SQL 2000 <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 9 Mar 2004 13:25:29 +0100
From: "Ewald van Gemert" <news@vangee.nl>
Subject: $result = system('/usr/bin/cksum TEST.mp3 >&1');
Message-Id: <404db668$0$80589$ee9da40f@news.wanadoo.nl>
Hi,
I would like to get the output:
1306701436 266 TEST.mp3
in the $result string.
This doen't work.
What does?
Regards,
Ewald
------------------------------
Date: 09 Mar 2004 12:40:13 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: $result = system('/usr/bin/cksum TEST.mp3 >&1');
Message-Id: <u9oer68a8i.fsf@wcl-l.bham.ac.uk>
"Ewald van Gemert" <news@vangee.nl> writes:
> Hi,
>
> I would like to get the output:
> 1306701436 266 TEST.mp3
> in the $result string.
>
> This doen't work.
> What does?
Please look up the explaination function you are using in the
reference manual. Pay particular note to the bit where it says "This
is not what you want to use to capture the output from a command, for
that you should... "
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 09 Mar 2004 13:45:01 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: $result = system('/usr/bin/cksum TEST.mp3 >&1');
Message-Id: <m3d67mnq9e.fsf@quimby.dirtyhack.org>
* Ewald van Gemert
> Hi,
>
> I would like to get the output:
> 1306701436 266 TEST.mp3
> in the $result string.
>
> This doen't work.
> What does?
You could try using String::CRC::Cksum instead.
<URL:http://search.cpan.org/~ahamm/String-CRC-Cksum-0.03/Cksum.pm>
--
#!/usr/bin/vr
------------------------------
Date: Tue, 9 Mar 2004 14:54:05 GMT
From: Norbert Gruener <nog@MPA-Garching.MPG.DE>
Subject: ANNOUNCE: AFS Perl API 2.2.1 released
Message-Id: <HuBDoy.1vtM@zorch.sf-bay.org>
AFS Perl API Version 2.2.1
I am pleased to announce the AFS Perl API 2.2.1 release
The AFS module bundle is a dynamically loadable extension to
Perl. It gives the AFS user and administrator access to many of
the AFS programming APIs, allowing you to make these calls
directly from Perl, rather then processing the output of a
command. The AFS module bundle is a thin layer above the low-level
AFS APIs.
Where To Get It
The version 2.2.1 is now available at
http://www.MPA-Garching.MPG.de/~nog/perl/AFS-2.2.1.tar.gz
http://www.cpan.org/authors/id/N/NO/NOG/AFS-2.2.1.tar.gz
This release should work on all UNIX/Linux platforms which have
AFS API interfaces and the appropriate C compilation environment.
User visible changes in this release
- fixed method DESTROY for the modules AFS::KAS, AFS::PTS,
AFS::VLDB, and AFS::VOS:
under certain circumstances DESTROY caused segmentation faults;
For more information about the current state of the AFS Perl API,
check my "AFS Perl API Kwiki" site at:
http://www.mpa-garching.mpg.de/kwiki/nog/afsperl/
Share and Enjoy!
Norbert
--
Ceterum censeo | PGP encrypted mail preferred.
Redmond esse delendam. | PGP Key at www.MPA-Garching.MPG.de/~nog/
------------------------------
Date: Sun, 7 Mar 2004 00:14:39 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: CGI::Session::MembersArea V 1.00
Message-Id: <HuBDno.1BC5@zorch.sf-bay.org>
The pure Perl module CGI::Session::MembersArea V 1.00
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.
On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.
An extract from the docs:
NAME
CGI::Session::MembersArea - A resource guardian based on CGI::Session
Specifically, it implements an idea in the CGI::Session CookBook, from the
section called Member's Area.
Recent changes:
1.00 Fri Mar 5 12:37:29 2004
- Original version
A demonstration program using this module is available from
http://savage.net.au/Perl-tutorials.html
under the heading
# 41: A pure Perl, vendor-independent, database administration tool
--
Cheers
Ron Savage, ron@savage.net.au on 7/03/2004
http://savage.net.au/index.html
------------------------------
Date: Sat, 6 Mar 2004 03:03:45 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: DBIx::Admin::TableInfo V 1.01
Message-Id: <HuBDn9.1BAI@zorch.sf-bay.org>
The pure Perl module DBIx::Admin::TableInfo V 1.01
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.
On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.
An extract from the docs:
NAME
DBIx::Admin::TableInfo - A wrapper around DBI's table_info() and column_info()
Recent changes:
1.01 Wed Mar 3 10:08:41 2004
- Add method refresh() to re-create internal data by re-calling DBI's table_info().
This has to be called after you change the database structure, eg by doing
'drop table <some table>' or something similar
--
Cheers
Ron Savage, ron@savage.net.au on 6/03/2004
http://savage.net.au/index.html
------------------------------
Date: Mon, 8 Mar 2004 15:58:51 GMT
From: David Golden <dg-junk@hyperbolic.net>
Subject: ANNOUNCE: ExtUtils::ModuleMaker::TT v0.70
Message-Id: <HuBDnz.1BD7@zorch.sf-bay.org>
Now available on CPAN, ExtUtils::ModuleMaker::TT brings the power of the
Template Toolkit to module building. Use built-in defaults or customize
the templates to suit your own coding style. Included is a new
command-line utility for creating a module skeleton which supports
loading default settings from a configuration file, creating whole
distribution skeletons, adding new .pm files to an existing distribution
tree and more.
An excerpt from the POD follows:
SYNOPSIS
use ExtUtils::ModuleMaker::TT;
my $mmtt = ExtUtils::ModuleMaker::TT->new (
NAME => 'My::New::Module',
TEMPLATE_DIR => '~/.perltemplates'
);
$mmtt->complete_build();
DESCRIPTION
This module extends ExtUtils::ModuleMaker to use Template Toolkit 2
(TT2) to build skeleton files for a new module. Templates may either be
default templates supplied within the module or user-customized
templates in a directory specified with the *TEMPLATE_DIR* parameter.
Summary of Features/Enhancements:
* Supports building full module skeletons with all the functionality
of ExtUtils::ModuleMaker
* Supports adding a single .pm file (and corresponding .t file) to an
existing module distribution tree.
* Supports creating skeleton text for a single method (generally to be
called via a script from within your favorite editor)
* Can create a template directory containing the default templates for
subsequent user customization
* Templates can access any parameter in the creating object (e.g.
$mmtt, above). This supports transparent, user-extensible template
variables for use in custom templates
* Included script *makeperlmod* provides a command line user interface
for module creation. Supports reading default configuration settings
from a file and will create a default config file if requested. Can
create full distributions, single modules, single methods, or
default template directories
Notable changes from ExtUtils::ModuleMaker:
* *complete_build* now takes arguments that are added to or overwrite
the current configuration
* Default templates are generally simpler and more compact
* Also creates a MANIFEST.SKIP file with reasonable default contents
* Tests are named after their corresponding .pm files rather than
being sequentially numbered. This change supports the "single .pm"
mode more consistently. E.g., for "Sample::Module", a test file
"Sample_Module.t" is created
* Supports both 'Module::Build and Proxy' and 'Module::Build and proxy
Makefile.PL' as *BUILD_SYSTEM* synonyms to cover discrepancy between
ExtUtils::ModuleMaker code and pod
USAGE
Generally, users should just use the included script, makeperlmod. For
example, the following command will create a module distribution using
default settings:
makeperlmod -n Sample::Module
See the makeperlmod man page for details on creating a custom
configuration file (for setting author details and other
ExtUtils::ModuleMaker options). The "CUSTOMIZING TEMPLATES" section
below contains other examples.
CUSTOMIZING TEMPLATES
Overview
Use the makeperlmod script to create a directory containing a copy of
the default templates. Alternatively, use the create_template_directory
method directly. Edit these templates to suit personal taste or style
guidelines. Be sure to specify a TEMPLATE_DIR configuration option when
making modules.
Customizing with makeperlmod
This can all be done quite easily with makeperlmod. Begin with:
makeperlmod -d > ~/.makeperlmod.config
makeperlmod -t ~/.makeperlmod.templates
Edit .makeperlmod.config and add "TEMPLATE_DIR
~/.makeperlmod.templates". Make any other desired edits to AUTHOR,
COMPACT, etc. (COMPACT is recommended.)
Edit the resulting templates as needed. Templates are written with the
Template Toolkit to allow for easy user customization of the contents
and layout. See the Template module for the full syntax or just examine
the default templates for quick changes.
Presto! Customization is done. Now start making modules with
makeperlmod -n My::New::Module
------------------------------
Date: Sat, 6 Mar 2004 06:09:31 GMT
From: Alan E Derhaag <aederhaag@comcast.net>
Subject: ANNOUNCE: FramesReady-1.016 now available
Message-Id: <HuBDnI.1BB7@zorch.sf-bay.org>
You can find this in CPAN at
http://www.cpan.org/authors/id/D/DE/DERHAAG/FramesReady-1.016.tar.gz
This version fixes a critical shortcoming in the definition of the
@schema array containing the valid/acceptable schema types for child
processing. This should help the Cookies use to head off
protocol/schema types that cannot be resolved by that module: mailto,
about:blank, etc. Also the default assignment of the UserAgent is no
longer made and will default to the parent class supplied agent. The
callback routine can now be changed from using the one defined
internally to one supplied by the user or an undef for none.
POD:
NAME
LWP::UserAgent::FramesReady - a frames-capable version of LWP::UserA-
gent
SYNOPSIS
use LWP::UserAgent::FramesReady;
$ua = new LWP::UserAgent::FramesReady;
$ua = new LWP::UserAgent::FramesReady({'callback'=>\&callback
[,'size'=>$size]});
$ua = new LWP::UserAgent::FramesReady({'nomax'=>1,
'callback'=>\&LWP::UserAgent::FramesReady::callback
[,'size'=>$size]});
$response = $ua->request($http_request);
DESCRIPTION
LWP::UserAgent::FramesReady is a version of LWP::UserAgent that is
smart enough to recognize the presence of frames in HTML and load them
automatically.
The subroutine variant requires a hash reference to a callback routine
that is supplied to the request to process the content in chunks to
look for, for instance, immediate refreshes and alter them to be redi-
rects which LWP::UserAgent->request will follow out as it does all
other redirects. If size (supplied as an additional hash element) is
supplied it will be the suggested chunk size. If the subroutine vari-
ant is requested without a size, the size will default to 8K. The
default is to use the callback() function defined with the class
object.
The LWP::UserAgent::FramesReady::callback is supplied as the default
callback routine and the $cnf->{'nomax'} can be supplied and used by
that routine to enforce truncation of received content even if the
request to do so is not honored by the server called for the content.
To override the default behavior and not use an actual callback, the
$ua->callbk should be called supplying 'undef' as the subroutine to use
as in '$ua->callbk(undef)'. Not defining a code ref will default to
the callback defined here.
Because a framed HTML page actually consists of several HTML pages and
requires more than one HTTP response, LWP::UserAgent::FramesReady
returns framed pages as HTTP::Response::Tree objects. Responses that
don't have the Content-type of 'text/html' or have a return code < 400
are still returned but as HTTP::Response objects as frames processing
is probably not valid for them. Note: a
$response->isa('HTTP::Response::FramesReady') type check should be done
before attempting to use this module's methods.
METHODS
LWP::UserAgent::FramesReady inherits most of its methods from
LWP::UserAgent. The following method overrides the LWP::UserAgent ver-
sion:
$ua->request($request)
This behaves like LWP::UserAgent's request method, except that it
takes only one parameter (an HTTP::Request object as usual). Fur-
ther parameters may generate a warning and be ignored. Such
attempts usually are due to a proxy request, redirect override,
authentication or moved file condition that the base class function
can handle properly, anyway.
In addition to request()'s usual behavior (authenticating, follow-
ing redirects, etc.), this will attempt to follow frames if it
detects an HTML page that contains them. All responses collected
as a result of following frames will be returned in an
HTTP::Response::Tree object except as denoted above.
The following method is new:
$ua->max_depth([$depth])
This gets or sets the maximum depth that the user agent is allowed
to go to fetch framed pages. 0 means it will not fetch any frames,
1 means it will fetch only the frames for the topmost page and not
any sub-frames, and so on. The default is 3.
$ua->callbk([\&callback])
Get/set the callback subroutine to use to process input as it is
gathered. This causes the input to be chunked and the routine must
either process the data itself or append it to the
$response->{_content} in order for the final content to be pro-
cessed all at one time.
$ua->size([$size])
Get/Set the size suggested for chunks when the callback routine is
used.
$ua->credent([$credentials])
Get/set the credentials for authentification if called for.
callback()
The callback routine is a sample of how to revise the way the imme-
diate refresh responses are processed by converting them into redi-
rects. Since the routine is called whenever there is chunked
response data available by use of the alternate LWP::UserA-
gent::request() method, and we only change headers for immediate
refreshes. We must also deal with the fact that the callback was
originally designed for processing the content. The $resp->{_con-
tent} field must have the unprocessed data element appended back
in.. appended, as this data is chunked and there may already be
content from a previous chunk that was processed.
$ua->valid_scheme()
The valid_scheme validates the frame src entry to scheme types we
can process. If LWP::Debug is set, there will be reporting of the
reason for skipping this entry.
$ua->get_basic_credentials()
This routine overloads the LWP::UserAgent::get_basic_credentials in
order to supply authorization if it has been pre-loaded an ini-
tial/new or by use of the $ua->credent() routine. Supplies a
return in a list context of a UserID and a Password to LWP::UserA-
gent::credentials().
NOTES
Processing other embedded objects in an HTML page is similar to pro-
cessing frames. Perhaps someday there will be yet another version of
this that can also handle things like in-line images, layers, etc.
BUGS
Any known bugs will be noted here and documented in the source with
"BUG:" in the comments.
COPYRIGHT
Copyright 2003 N2H2, Inc. 2004 Secure Computing, Inc. All
rights reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
------------------------------
Date: Sat, 6 Mar 2004 03:01:42 GMT
From: Ron Savage <ron@savage.net.au>
Subject: ANNOUNCE: Javascript::MD5 V 1.00
Message-Id: <HuBDMy.1B9H@zorch.sf-bay.org>
The pure Perl module Javascript::MD5 V 1.00
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.
On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.
An extract from the docs:
NAME
Javascript::MD5 - Calculate the MD5 digest of a CGI form field
Recent changes:
1.00 Fri Mar 05 10:23:29 2004
- Original version
- The original Javascript code from Yahoo is shipped as yahoo.js.
See http://4.11.205.206/yahoo.zip.
Many thanks to Mark S Pryor for telling me about yahoo.js
- I have deleted from that code some functions which were not called, changed all
" to ', and made the CGI form field name, by default 'password', a parameter
- The program in the synopsis is in the examples/ directory
--
Cheers
Ron Savage, ron@savage.net.au on 6/03/2004
http://savage.net.au/index.html
------------------------------
Date: Mon, 8 Mar 2004 19:00:45 GMT
From: curtisf@fultron.net (curtisleefulton)
Subject: ANNOUNCE: XML::EasySQL
Message-Id: <HuBDoA.1BLz@zorch.sf-bay.org>
XML::EasySQL is a two-way SQL/XML base class for Perl
You can find it at: http://search.cpan.org/~curtisf/XML-EasySQL-1.0/
Features:
o Two-way transforms between XML and SQL data
o smart SQL updates: only altered tables are updated
o unlimited tree depth
o multiple SQL tables can merge into one XML tree, then back again
o precise control over how data is translated
o offers either an easy XML interface or plain DOM
o database independent
------------------------------
Date: 9 Mar 2004 07:01:22 -0800
From: tsbayne@yahoo.com (Tom)
Subject: Beginner Perl Help - Substituting Strings
Message-Id: <69305845.0403090701.233e7b93@posting.google.com>
I am working on a chat script and I'm trying to use code similar to
the following:
if ($post =~ /:)/)
{
$post =~ s/:)/"<img src="smile.gif" border=0>";
$newp = "<b>$login:</b> <font
color=\"$color\">$post</font><br>\n";
}
I think I know why it doesn't work, but I don't know the correct
syntax. Can anyone help a complete beginner? Please, keep the
laughing to a minimum.
-tom
------------------------------
Date: 9 Mar 2004 15:15:25 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Beginner Perl Help - Substituting Strings
Message-Id: <c2kn2d$8nt$2@mamenchi.zrz.TU-Berlin.DE>
Tom <tsbayne@yahoo.com> wrote in comp.lang.perl.misc:
> I am working on a chat script and I'm trying to use code similar to
> the following:
>
> if ($post =~ /:)/)
> {
> $post =~ s/:)/"<img src="smile.gif" border=0>";
> $newp = "<b>$login:</b> <font
> color=\"$color\">$post</font><br>\n";
> }
>
> I think I know why it doesn't work,
What does "doesn't work" mean? What do you expect it to do?
> but I don't know the correct
> syntax. Can anyone help a complete beginner?
We might, if you told us what you want to do. If your code is broken,
(it has syntax errors) it cannot serve as a means to tell us that.
Anno
------------------------------
Date: Tue, 09 Mar 2004 16:27:31 +0100
From: Vetle Roeim <vetro@online.no>
Subject: Re: Beginner Perl Help - Substituting Strings
Message-Id: <m3ptbmm464.fsf@quimby.dirtyhack.org>
* tsbayne@yahoo.com
> I am working on a chat script and I'm trying to use code similar to
> the following:
>
> if ($post =~ /:)/)
You have to escape the paranthesis, as they're used for grouping:
$post =~ /:\)/;
See perlre for more details:
<URL:http://search.cpan.org/~krishpl/pod2texi-0.1/perlre.pod>
> {
> $post =~ s/:)/"<img src="smile.gif" border=0>";
Escape the ) and ", and add the missing / at the end:
$post =~ s/:\)/"<img src=\"smile.gif\" border=0>"/;
I suggest that you try learning Perl properly.. Check out
<URL:http://learn.perl.org/> for more information.
[...]
--
#!/usr/bin/vr
------------------------------
Date: Tue, 9 Mar 2004 07:26:42 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Daemon with Perl
Message-Id: <slrnc4rhgi.44b.tadmc@magna.augustmail.com>
Vito Corleone <corleone@godfather.com> wrote:
> Subject: Daemon with Perl
^^^^^^
> Any
> documentation, etc?
perldoc -q Daemon
How do I fork a daemon process?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 9 Mar 2004 22:47:16 +1100
From: "Paul B" <abcsydney@ans.com.au>
Subject: Flat file database problem
Message-Id: <404daec6@daisy.ans.com.au>
Hi guys,
I have a problem with my flatfile database when using the Add Record part of
the script.
It removes the last character of the line above the line it just added. I
have included below the code that adds a record to my database.
Any ideas would be appreciated.
Kind Regards
Paul
*Remove 'abc' from my email to respond.
sub add_record {
foreach $required (@required){
if($q->param($required) eq "") {
$title = "Add A Record"; $error_message = "You did not fill out the required
information!"; &access_problem($error_message); exit; } }
foreach $field (@fields){
${$field} = $q->param($field);
${$field} = filter(${$field});
$record .= "${$field}\|";
}
chop $record;
unless (-e $database){ open (DB, ">$database") || die "Error creating
database. $!\n"; }
else { open (DB, ">>$database") || die "Error opening database. $!\n"; }
flock DB, $EXCLUSIVE;
seek DB, 0, 2;
if($q->param('add_this_record') eq "Add This Record") {
print DB "\n$record";
} else {
print DB "$record";
}
flock DB, $UNLOCK;
close(DB);
} # End of add_record subroutine.
------------------------------
Date: 09 Mar 2004 12:33:40 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Flat file database problem
Message-Id: <u9smgi8ajf.fsf@wcl-l.bham.ac.uk>
"Paul B" <abcsydney@ans.com.au> writes:
> I have a problem
Get into the habit of always declaring all variables as lexically
scoped in the smallest applicable scope unless there is a positive
reason not to do so. Do this now, do not wait for your bad habits to
cause you pain.
Use whitespace (pariticularly line breaks and indentation) in your
code to aid readability.
Niether of the above have anything specific to do with Perl. They
apply in most programming languages.
Do not use the special &subroutine() syntax for calling subroutines
unless you understand what the effect of the & is and you really want
those semantics.
I have no idea (yet) if the above have anything to do with your
problem but they will make your code less difficult for you, and more
importantly for others, to debug. When posting to Usenet common
courtesy demands that you do everything you can to help people to help
you.
Have you read the posting guidelines that are posted here frequently?
> with my flatfile database when using the Add Record part of
> the script.
>
> It removes the last character of the line above the line it just added. I
> have included below the code that adds a record to my database.
You should produce a minimal but complete script the illustrates your
problem.
Have you read the posting guidelines that are posted here frequently?
> Any ideas would be appreciated.
>
> Kind Regards
> Paul
>
> *Remove 'abc' from my email to respond.
Does your mail admin approve of LHS munging?
> sub add_record {
> foreach $required (@required){
> if($q->param($required) eq "") {
> $title = "Add A Record"; $error_message = "You did not fill out the required
> information!"; &access_problem($error_message); exit; } }
>
> foreach $field (@fields){
> ${$field} = $q->param($field);
> ${$field} = filter(${$field});
> $record .= "${$field}\|";
> }
> chop $record;
Do not use symbolic references unless you have a really good reason.
I'm 99.9999% sure you don't have a good reason here. I'm 95% sure
you don't even have a bad reason.
Also:
perldoc -f join
perldoc -f map
> unless (-e $database){ open (DB, ">$database") || die "Error creating
> database. $!\n"; }
> else { open (DB, ">>$database") || die "Error opening database. $!\n"; }
You seem to be going to a lot of effort to introduce a race condition
into your program. Simply open the database in append mode
unconditionally.
> flock DB, $EXCLUSIVE;
Any reason you don't just use LOCK_EX directly?
> seek DB, 0, 2;
> if($q->param('add_this_record') eq "Add This Record") {
> print DB "\n$record";
> } else {
> print DB "$record";
> }
> flock DB, $UNLOCK;
> close(DB);
> } # End of add_record subroutine.
Note - it is more conventional for flat-files to have "\n" as a record
_terminator_ than as a record _separator_ - i.e. the last character of
any non-empty flat file is always "\n".
I do not think the code you have posted can account for the symptoms
you describe.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 09 Mar 2004 18:26:47 +0530
From: Ramprasad A Padmanabhan <ramprasad.padmanabhan@nospam.oracle.com>
Subject: Re: Flat file database problem
Message-Id: <404DBF0F.3040406@nospam.oracle.com>
Paul B wrote:
> Hi guys,
>
> I have a problem with my flatfile database when using the Add Record part of
> the script.
>
> It removes the last character of the line above the line it just added. I
> have included below the code that adds a record to my database.
>
> Any ideas would be appreciated.
>
> Kind Regards
> Paul
>
> *Remove 'abc' from my email to respond.
>
> sub add_record {
> foreach $required (@required){
> if($q->param($required) eq "") {
> $title = "Add A Record"; $error_message = "You did not fill out the required
> information!"; &access_problem($error_message); exit; } }
>
> foreach $field (@fields){
> ${$field} = $q->param($field);
> ${$field} = filter(${$field});
> $record .= "${$field}\|";
> }
> chop $record;
> unless (-e $database){ open (DB, ">$database") || die "Error creating
> database. $!\n"; }
> else { open (DB, ">>$database") || die "Error opening database. $!\n"; }
> flock DB, $EXCLUSIVE;
> seek DB, 0, 2;
> if($q->param('add_this_record') eq "Add This Record") {
> print DB "\n$record";
> } else {
> print DB "$record";
> }
> flock DB, $UNLOCK;
> close(DB);
> } # End of add_record subroutine.
>
>
I didnt quite understand your problem but Do you really have to use text
based db.In that case why dont you look at DBD::CSV or stuff like that.
Write your code as far as possible in DBI and SQL. So you would have
minimum effort when you will have to port it to any other database
Writing your own interface to a database is the worst case of
'reinventing the wheel'
Bye
Ramprasad
------------------------------
Date: 9 Mar 2004 07:26:18 -0800
From: chilecayenne@yahoo.com (cayenne)
Subject: How to comment more than one line in Perl?
Message-Id: <2deb3d1.0403090726.4312cb7f@posting.google.com>
Hello all,
I'm trying to learn/debug Perl...and while doing that I'd like to be
able to comment LARGE, multiple lines of code....but, from all I can
read and find...I only see the # as the symbol that comments out one
line at a time.
Is there anything similar to the /*...................*/ construct
where you can comment out large blocks of code traversing multiple
lines ?
Thanks in advance,
chilecayenne
------------------------------
Date: Tue, 09 Mar 2004 15:34:03 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to comment more than one line in Perl?
Message-Id: <Ltl3c.79517$6K.14874@nwrddc02.gnilink.net>
cayenne wrote:
> I'm trying to learn/debug Perl...and while doing that I'd like to be
First thing you should do is familiarize yourself with the documentation
that came with your Perl installation. Part of this documentation is
"perldoc". For instructions on how to use it do a simple "perldoc perldoc"
and to get an overview about what topics are available try "perldoc perl".
> able to comment LARGE, multiple lines of code....but, from all I can
> read and find...
Then you haven't checked the FAQ which can be searched using the "-q" option
of "perldoc".
> I only see the # as the symbol that comments out one
> line at a time.
>
> Is there anything similar to the /*...................*/ construct
> where you can comment out large blocks of code traversing multiple
> lines ?
perldoc -q comment
"How can I comment out a large block of perl code?"
jue
------------------------------
Date: Tue, 09 Mar 2004 16:37:10 +0100
From: =?ISO-8859-1?Q?Josef_M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to comment more than one line in Perl?
Message-Id: <c2ko69$sp2$1@nntp.fujitsu-siemens.com>
cayenne wrote:
> Hello all,
> I'm trying to learn/debug Perl...and while doing that I'd like to be
> able to comment LARGE, multiple lines of code....but, from all I can
> read and find...I only see the # as the symbol that comments out one
> line at a time.
>=20
> Is there anything similar to the /*...................*/ construct
> where you can comment out large blocks of code traversing multiple
> lines ?
Have a look at pod (Plain Old Documentation).
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: 9 Mar 2004 11:44:34 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to modify struct value within a list
Message-Id: <c2kan2$2lb$1@mamenchi.zrz.TU-Berlin.DE>
Barry <titanandrews@hotmail.com> wrote in comp.lang.perl.misc:
> Hello,
> I have a series of different instances of structs which are stored
> in a list. I want to be able to modify an element of a list that is in
> the struct that is stored in the list. Follow that? I am certain my
> syntax is the problem, but I just can't figure it out. Here is a
> simple example of what I am trying to do:
>
> use Class::Struct;
>
> struct defs =>
> {
> name => '$',
> types => '@',
> };
>
> my @alldefs;
> my $defs = defs->new( name => 'Fred',
> types => ('this','that');
[...]
Have you even run that code before asking a question about it?
After filling in the missing ")", the answer from Class::Struct is
"Initializer for types must be array reference at ..."
In other words, the defs->new() method fails, and clearly explains
why. Do your homework and then ask again.
Anno
------------------------------
Date: Tue, 09 Mar 2004 13:11:56 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Is it possible to impose a timeout on <>?
Message-Id: <tegr40dpbbtc9tkoir3imoli03lj3pgfhr@4ax.com>
Bob Dubery wrote:
>$timeout = 5;
>
>for($i=0; $i < 2; $i++){
> for($j=0; $j <3; $j++){
> print "$i\.$j...\n";
> my @stuff;
> eval{
> local $SIG{ALRM} = sub{next};
> alarm($timeout);
> @stuff=<>;
> };
>
> alarm(0);
>
> unless($EVAL_ERROR){
> print "$#stuff lines of input entered\n";
> }
> }
>}
Yuck! A "next" in a subroutine, you should be ashamed of yourself! ;-)
>On UNIX that is. It runs without warning (even with strict and -w) on
>Windows, but it never times out :-(
You need perl5.8.x on Windows, alarm() is not implemented in 5.6.1 and
earlier. You might have noticed if you checked the error code in $@
after the eval.
--
Bart.
------------------------------
Date: Tue, 09 Mar 2004 13:45:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: MS SQL 2000
Message-Id: <ihir40daeauskevoffks50l4letc0pk18g@4ax.com>
anonymous@coolgroups.com wrote:
>How exactly do I create a DSN? I don't see any Data Sources
>option in my windows control panel.
You don't have a "ODBC data sources (32bit)" control panel? How odd.
--
Bart.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6237
***************************************