[22312] in Perl-Users-Digest
Perl-Users Digest, Issue: 4533 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 10 18:22:09 2003
Date: Mon, 10 Feb 2003 15:21:28 -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 Mon, 10 Feb 2003 Volume: 10 Number: 4533
Today's topics:
Error in Perl Query (Jack Cane)
Re: Error in Perl Query <GPatnude@adelphia.net>
Re: Error in Perl Query <goldbb2@earthlink.net>
Re: Error in Perl Query <tore@aursand.no>
Re: error in timelocal function? <erik@cthulhu.demon.nl>
Error installing Perl 5.8.0 on z/OS 1.2 - Help! (Dino)
executing x86 machine code from perl (bad_knee)
Re: executing x86 machine code from perl <goldbb2@earthlink.net>
Re: executing x86 machine code from perl (bad_knee)
Failure when using Win32::GUI (Thomas Beardshear)
Re: Failure when using Win32::GUI <kevin@vaildc.net>
Re: Failure when using Win32::GUI <noreply@gunnar.cc>
file output <pdhze@yahoo.co>
Re: file output <jkeen@concentric.net>
Re: file output <bigj@kamelfreund.de>
Re: File question in perl...Please help <abigail@abigail.nl>
File rotation with Perl (Matthew Beason)
Re: File rotation with Perl <uri@stemsystems.com>
Re: File rotation with Perl (Matthew Beason)
Get vs. Post to Perl (Jack Cane)
Re: Get vs. Post to Perl <bart.lateur@pandora.be>
Re: Get vs. Post to Perl (Jack Cane)
Getting error of perl_get_sv : symbol not found from dy (Jim)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Feb 2003 06:41:37 -0800
From: jwcane@enw-ltd.com (Jack Cane)
Subject: Error in Perl Query
Message-Id: <3f29ccb2.0302100641.69565e1a@posting.google.com>
I am using Perl-CGI to execute a SQL query against an ODBC database
table. Two form variables are used to modify the query. The queries
below both cause application errors in Perl.exe. Would appreciate any
hints toward a solution. Or could it be a faulty ODBC driver (EasySoft
Interbase driver)?
========================
First Query
========================
my $row1 = param( "ROWSTART" );
my $row2 = param( "ROWEND" );
my $querystring = "select LastName, FirstName, MidInitial, UserName
from MemberNames where MbrNr > ".$row1." and mbrNr < ".$row2;
========================
Second Query
========================
my $row1 = param( "ROWSTART" );
my $row2 = param( "ROWEND" );
my $Q1 = "select LastName, FirstName, MidInitial, UserName from
MemberNames where MbrNr > ";
my $Q2 = " and mbrNr < ";
my $querystring = $Q1.$row1.$Q2.$row2;
------------------------------
Date: Mon, 10 Feb 2003 16:21:18 GMT
From: "codeWarrior" <GPatnude@adelphia.net>
Subject: Re: Error in Perl Query
Message-Id: <2kQ1a.5207$jR3.2784859@news1.news.adelphia.net>
"Jack Cane" <jwcane@enw-ltd.com> wrote in message
news:3f29ccb2.0302100641.69565e1a@posting.google.com...
> I am using Perl-CGI to execute a SQL query against an ODBC database
> table. Two form variables are used to modify the query. The queries
> below both cause application errors in Perl.exe. Would appreciate any
> hints toward a solution. Or could it be a faulty ODBC driver (EasySoft
> Interbase driver)?
>
> ========================
> First Query
> ========================
> my $row1 = param( "ROWSTART" );
> my $row2 = param( "ROWEND" );
>
> my $querystring = "select LastName, FirstName, MidInitial, UserName
> from MemberNames where MbrNr > ".$row1." and mbrNr < ".$row2;
> ========================
> Second Query
> ========================
> my $row1 = param( "ROWSTART" );
> my $row2 = param( "ROWEND" );
> my $Q1 = "select LastName, FirstName, MidInitial, UserName from
> MemberNames where MbrNr > ";
> my $Q2 = " and mbrNr < ";
>
> my $querystring = $Q1.$row1.$Q2.$row2;
Better wrtiting your SQL Queries like this:
$SQLSTMT = "SELECT LastName, FirstName, MidInitial, UserName from
MemberNames where MbrNr > $row1 and mbrNr < $row2";
$SQL = $DBH->prepare($SQLSTMT);
$RESULT = $SQL->execute();
------------------------------
Date: Mon, 10 Feb 2003 16:07:58 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Error in Perl Query
Message-Id: <3E4814AE.9E0AB0CF@earthlink.net>
Jack Cane wrote:
>
> I am using Perl-CGI to execute a SQL query against an ODBC database
> table. Two form variables are used to modify the query. The queries
> below both cause application errors in Perl.exe. Would appreciate any
> hints toward a solution. Or could it be a faulty ODBC driver (EasySoft
> Interbase driver)?
>
> ========================
> First Query
> ========================
> my $row1 = param( "ROWSTART" );
> my $row2 = param( "ROWEND" );
>
> my $querystring = "select LastName, FirstName, MidInitial, UserName
> from MemberNames where MbrNr > ".$row1." and mbrNr < ".$row2;
[snip]
No, don't do it that way, do it this way:
my $query_string = q;
SELECT LastName, FirstName, MidInitial, UserName
FROM MemberNames
WHERE MbrNr > ? AND MbrNr <= ?
;;
my $statement_handle = $database_handle->prepare($query_string);
$statement_handle->execute( $row1, $row2 );
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: Mon, 10 Feb 2003 23:39:30 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Error in Perl Query
Message-Id: <pan.2003.02.10.22.21.26.2234@aursand.no>
On Mon, 10 Feb 2003 06:41:37 -0800, Jack Cane wrote:
> The queries below both cause application errors in Perl.exe.
> [...]
What do the error messages you get say? It's very useful for us in here
to know exactly what goes wrong. :)
And - while we're at it. I prefer binding values into my SQL queries;
my $sth = $dbh->prepare('SELECT x FROM y WHERE z = ? AND n = ?');
$sth->execute( $z, $n );
.
.
.
$sth->finish();
--
Tore Aursand - tore@aursand.no - http://www.aursand.no/
------------------------------
Date: Sat, 08 Feb 2003 07:34:58 GMT
From: Erik van Roode <erik@cthulhu.demon.nl>
Subject: Re: error in timelocal function?
Message-Id: <Cq21a.2312$YC5.1663@newssvr19.news.prodigy.com>
Jay Tilton <tiltonj@erols.com> wrote:
>
> What timekeeping system represents midnight as 24:00? In one minute,
> will it be 24:01, or will it be a more sensible 0:01?
>
> Find the person who created this timekeeping system and kick him in
> the head.
ISO 8601 International Standard for the representation of dates and times
Midnight may be expressed as either 00:00:00 or 24:00:00.
Erik
------------------------------
Date: 7 Feb 2003 10:14:05 -0800
From: dino.swanwick@custserv.com (Dino)
Subject: Error installing Perl 5.8.0 on z/OS 1.2 - Help!
Message-Id: <5a83c269.0302071014.13e850cc@posting.google.com>
Hi,
I'm getting the following error when I try to install Perl 5.8.0 on a
z/OS 1.2 system. I have sucessfully (I think) the Configure script.
I'm getting the error when I try and do the 'make'. I have also
attached the output from an 'env' command so you can see my
environment variables.
Any help would be greatly appreciated.
Dino
AI00029:/usr/local/perl/perl-5.8.0>make
AutoSplitting perl library
/bin/env ./miniperl -Ilib -e 'use AutoSplit;
autosplit_lib_modules(@ARGV)' lib/ *.pm /bin/env ./miniperl -Ilib -e
'use AutoSplit; autosplit_lib_modules(@ARGV)' lib/ */*.pm make
lib/re.pm `lib/re.pm' is up to date
Making DynaLoader (static)
Making B (static)
Making ByteLoader (static)
Making Cwd (static)
Making Data::Dumper (static)
Making Devel::DProf (static)
Making Devel::PPPort (static)
Making Devel::Peek (static)
Making Digest::MD5 (static)
Making Encode (static)
c89 -c -I../Encode -DMAXSIG=38 -DOEMVS -D_OE_SOCKETS
-D_XOPEN_SOURCE_EXTEN DED -D_ALL_SOURCE -DYYDYNAMIC -W
,float\(ieee\) -DVERSION=\"1.25\" -DXS_VERSIO
N=\"1.25\" "-I../../.." eu_01_t.c
FSUM3065 The COMPILE step ended with return code 16.
FSUM3017 Could not compile eu_01_t.c. Correct the errors and try
again. FSUM8226 make: Error code 3 FSUM8226 make: Error code 255
FSUM8226 make: Error code 255
AI00029:/usr/local/perl/perl-5.8.0>env
MAIL=/usr/mail/AI00029
_CXX_LIBDIRS=/lib /usr/lib
_BPX_TERMPATH=OMVS
PATH=/usr/lpp/java/IBM/J1.3/bin:/bin
_CXX_INCDIRS=/usr/include /usr/lpp/ioclib/include
_CXX_WORK_UNIT=SYSDA
SHELL=/bin/sh
_C89_SLIB_PREFIX=SYS1
_CC_LIBDIRS=/lib /usr/lib
_C89_CLIB_PREFIX=CBC
_CXX_PLIB_PREFIX=CEE
_CC_INCDIRS=/usr/include /usr/lpp/ioclib/include
_CC_WORK_UNIT=SYSDA
PS1=$LOGNAME:$PWD>
COLUMNS=80
_CC_PLIB_PREFIX=CEE
_=/bin/env
STEPLIB=CBC.SCCNCMP
LOGNAME=AI00029
LANG=C
LIBPATH=/lib:/usr/lib:.
_CXX_SLIB_PREFIX=SYS1
_C89_LIBDIRS=/lib /usr/lib
_CXX_CLIB_PREFIX=CBC
DFHJVPIPE=BATCHCLI
TERM=dumb
_C89_INCDIRS=/usr/include /usr/lpp/ioclib/include
_C89_WORK_UNIT=SYSDA
_C89_CCMODE=1
HOME=/u/ai00029
LINES=28
_CC_SLIB_PREFIX=SYS1
_CC_CLIB_PREFIX=CBC
_C89_PLIB_PREFIX=CEE
JAVA_HOME=/usr/lpp/java/IBM/J1.3
TZ=EST5EDT
MANPATH=/usr/man/%L
DFHJVSYSTEM_00=CICSTECH-CICSRegion
NLSPATH=/usr/lib/nls/msg/%L/%N
------------------------------
Date: 7 Feb 2003 11:41:35 -0800
From: bl8n8r@yahoo.com (bad_knee)
Subject: executing x86 machine code from perl
Message-Id: <e817ca4d.0302071141.164758ad@posting.google.com>
Hello,
Does anyone know if it's possible to have perl
execute machine code instructions from an array
Such as below? I'd like to use some machine code
routines for decrypting a string var and don't want
the algorithm to be readily visible from the source code.
@Foo = (0xa8,0xa0,0x99,0xed,0xa4,0x9c,0xbf,0x8d,0xc0,0x03,0x39,...);
Thanks in advance,
bl8n8r
------------------------------
Date: Fri, 07 Feb 2003 15:28:46 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: executing x86 machine code from perl
Message-Id: <3E4416FE.7C55F0D8@earthlink.net>
bad_knee wrote:
>
> Hello,
>
> Does anyone know if it's possible to have perl
> execute machine code instructions from an array
> Such as below? I'd like to use some machine code
> routines for decrypting a string var and don't want
> the algorithm to be readily visible from the source code.
>
> @Foo = (0xa8,0xa0,0x99,0xed,0xa4,0x9c,0xbf,0x8d,0xc0,0x03,0x39,...);
The closest you can come is Inline::ASM, which would allow you to write
your decoding algorithm in assembler.
Considering that anyone who can read assmelber in the first place
undoubtalby has (or can obtain) a program which disassembles bytes into
assembler, this isn't all that bad.
--
"So, who beat the clueless idiot today?"
"Well, we flipped for it, but when Kuno
landed, he wasn't in any shape to fight."
"Next time, try flipping a *coin.*"
------------------------------
Date: 10 Feb 2003 09:54:14 -0800
From: bl8n8r@yahoo.com (bad_knee)
Subject: Re: executing x86 machine code from perl
Message-Id: <e817ca4d.0302100954.4ccb96c7@posting.google.com>
> The closest you can come is Inline::ASM, which would allow you to write
> your decoding algorithm in assembler.
That would be wonderful, except the legalities require
the algorithms to be in machine code form in the source.
I never thought I'd hear myself say coding something in
assembly would be less problematic ;)
------------------------------
Date: 8 Feb 2003 23:20:47 -0800
From: thomasjb@pacbell.net (Thomas Beardshear)
Subject: Failure when using Win32::GUI
Message-Id: <1813f5c0.0302082320.796b4af4@posting.google.com>
I keep getting the following error message when I try to use the
Win32::GUI module:
C:\>perl -w rd.pl c:/
syntax error at rd.pl line 2, near "use "WIN32::GUI""
Execution of rd.pl aborted due to compilation errors.
The program scans the specified directory and returns a list of all
directories on the PC. It works fine until I added the following to
the top of the file:
use "WIN32::GUI";
BEGIN {
Win32::GUI::Hide(scalar(Win32::GUI::GetPerlWindow()))
};
I got the above from several Google searches and is probably related
to a library path not being setup for Perl, but I can't figure out
what to change to fix it.
I'm using ActiveState's perl which was installed to a network drive.
The only environment variable I set was the path to Perl.exe. I wrote
the program tonight over a period of 2 hours (most of it trying to
decide what data to return). It's been working fine all night and the
only difference between working and not working is the 4 lines above.
- I rarely use modules.
Thomasjb
------------------------------
Date: Sun, 09 Feb 2003 02:30:44 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: Failure when using Win32::GUI
Message-Id: <kevin-C28EF3.02304309022003@vienna7.his.com>
In article <1813f5c0.0302082320.796b4af4@posting.google.com>,
thomasjb@pacbell.net (Thomas Beardshear) wrote:
> I keep getting the following error message when I try to use the
> Win32::GUI module:
>
> C:\>perl -w rd.pl c:/
> syntax error at rd.pl line 2, near "use "WIN32::GUI""
> Execution of rd.pl aborted due to compilation errors.
[]
> use "WIN32::GUI";
^ ^
Lose the quotes.
[]
--
Kevin Michael Vail | Dogbert: That's circular reasoning.
kevin@vaildc.net | Dilbert: I prefer to think of it as no loose ends.
http://www.vaildc.net/kevin/
------------------------------
Date: Sun, 09 Feb 2003 08:00:34 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Failure when using Win32::GUI
Message-Id: <CUn1a.10212$LY2.612909@newsc.telia.net>
Thomas Beardshear wrote:
> use "WIN32::GUI";
1) Remove the quotes.
2) Don't exchange lower-case letters for capital ditto
In other words, try this:
use Win32::GUI;
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sat, 08 Feb 2003 16:43:54 GMT
From: piet <pdhze@yahoo.co>
Subject: file output
Message-Id: <Usenet.sadrista@localhost>
I am using a script that reads some stuff from a list of html files
(thanks to David Dorward, who got me started). The script writes the
results to a new file results.txt.
Now, I also have a plain text file called search.txt. The problem is, I
need to replace some lines within this file with the result of my
script. The block of lines that need to be replaced are delimited by
two tags like this
//begin results
xxxxxxxxxxxxxxxxxx xxx
xxxx xxxx xxxxxx xxxxx
//end results
The number of lines is variable and can be somewhere between 2 and 200.
So my question is how would I replace these lines. (I've only just
started learning perl)
Thanks
piet
Here is my basic script:
#!/usr/bin/perl -w
use strict;
use HTML::TreeBuilder 3;
use HTML::Headparser;
open (FILE, ">results.txt");
#print FILE "Testing!";
my $torf = 0;
foreach my $file_name (<@ARGV>) {
my $tree = HTML::TreeBuilder->new;
$tree->parse_file($file_name);
my @meta = $tree->find_by_tag_name('meta');
my $p = HTML::HeadParser->new;
$p->parse_file($file_name);
for (@meta) {
if ($_->attr('name')) {
if ($torf == 0) {
print FILE ("c=0; item[c]=new Array(\"$file_name\",\"\",\"".
$p->header('Title'). "\","); print FILE ("\"". $_->attr('CONTENT') .
"\",\"\");\n"); $torf = 1;
} else {
print FILE ("c++; item[c]=new Array(\"$file_name\",\"\",\"".
$p->header('Title'). "\","); print FILE ("\"". $_->attr('CONTENT') .
"\",\"\");\n"); }
}
}
$tree = $tree->delete;
}
close (FILE);
------------------------------
Date: 08 Feb 2003 17:16:03 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: file output
Message-Id: <b23e0j$2ai@dispatch.concentric.net>
"piet" <pdhze@yahoo.co> wrote in message news:Usenet.sadrista@localhost...
> I am using a script that reads some stuff from a list of html files
> (thanks to David Dorward, who got me started). The script writes the
> results to a new file results.txt.
>
> Now, I also have a plain text file called search.txt. The problem is, I
> need to replace some lines within this file with the result of my
> script. The block of lines that need to be replaced are delimited by
> two tags like this
>
> //begin results
> xxxxxxxxxxxxxxxxxx xxx
> xxxx xxxx xxxxxx xxxxx
> //end results
>
> The number of lines is variable and can be somewhere between 2 and 200.
>
If the number of lines is that small, you could slurp the entire file into a
string and run a pattern match/substitution against it. That process would
start with something like this:
{
undef $/;
$bigstring = <SEARCH>;
}
Or you could use Mark-Jason Dominus's Tie::File module to treat search.txt
as an array and then splice out the text between the delimiters and splice
in what you get from the HTML.
------------------------------
Date: Sat, 08 Feb 2003 20:11:13 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: file output
Message-Id: <pan.2003.02.08.18.42.06.58728@kamelfreund.de>
On Sat, 08 Feb 2003 16:43:54 +0000, piet wrote:
> I am using a script that reads some stuff from a list of html files
> (thanks to David Dorward, who got me started). The script writes the
> results to a new file results.txt.
>
> Now, I also have a plain text file called search.txt. The problem is, I
> need to replace some lines within this file with the result of my
> script. The block of lines that need to be replaced are delimited by
> two tags like this
>
> //begin results
> xxxxxxxxxxxxxxxxxx xxx
> xxxx xxxx xxxxxx xxxxx
> //end results
I didn't read further,
but if you want to remove the text elements between the two lines
//begin results and //end results, there's a simple way:
open INPUT, "your_input_file" or die "Can't open infile: $!";
open OUTPUT, ">your_output_file" or die "Can't open outfile: $!";
while (<INPUT>) {
next if m{//begin results} .. m{//end results};
print OUTPUT;
}
Best Wishes,
Janek
------------------------------
Date: 09 Feb 2003 01:18:02 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: File question in perl...Please help
Message-Id: <slrnb4bb2a.sb.abigail@alexandra.abigail.nl>
Mehul (mehul111@yahoo.com) wrote on MMMCDXLVI September MCMXCIII in
<URL:news:e743165d.0302060716.42bbc0d7@posting.google.com>:
!! Hi,
!! I want to modify a text file ( which is an input for some other
!! script ) in my perl script. How do I check if the file is in use by
!! that other script or not, so that I don't modify that text file while
!! the other script is using it?
Define "in use". If you mean, "how can I detect whether another
process has an open file handle to a specific file", then there's no
cross-platform answer. You may be able to use utilities like 'fuser' or
'lsof', but they may not be available on your platform, or they might
require privilidges you do not have.
As for not modifying a text file that another program is using, detecting
whether another process uses another file is neither necessary, nor
sufficient. Suppose you determine a file is not in use, then start
modifying it. But while you are modifying it, another process comes
along and starts using the file?
To get exclusive access to a file, one needs to obtain a lock on the
file. But the effects of the lock are system dependend. Unix systems
typically have non-mandatory locks. So, unless all process accessing the
file cooperate, it's not possible to prevent two processes interfering
with each other.
Read the "perlipc" manual page.
Abigail
--
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
for (??;(??)x??;??)
{??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'
------------------------------
Date: 7 Feb 2003 09:29:07 -0800
From: helfax@hotmail.com (Matthew Beason)
Subject: File rotation with Perl
Message-Id: <8b30e085.0302070929.55fa2a22@posting.google.com>
I'm hoping to gather a few suggestions on the best method for "file
rotation" in Perl. I've created a script which is executed via cron
and creates a mksysb to an NFS mounted partition. I would like to add
a few lines of code that would look at the number of existing mksysbs
for that host and remove all but the two latest files. I realize my
code isn't the best. Please understand that I've just started with
Perl but am working hard to sharpen my skills!
Here is the script:
#!/usr/bin/perl -w
use strict;
if (! -e "/rescue"){
mkdir ("/rescue", 0755);
}
my $mount = system("mount","diablo\:/mksysb","/rescue");
$mount == 0 or die "\n";
my $h = `/usr/bin/hostname`;
chomp($h);
my $d = `/usr/bin/date +"%m%d%Y%H%M"`;
chomp($d);
my @args = ("mksysb","-i","/rescue/$h.$d.mksysb");
my $mksysb = system(@args);
$mksysb == 0 or die "\n";
my $umount = system("umount","/rescue");
$umount == 0 or die "\n";
I was thinking of using readdir() and some regular expression pattern
matching. However, I couldn't quite figure out the best way to do
this.
Any suggestions or pointers that anyone could offer would be
appreciated.
Matt
------------------------------
Date: Fri, 07 Feb 2003 17:59:29 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: File rotation with Perl
Message-Id: <x7hebggef3.fsf@mail.sysarch.com>
>>>>> "MB" == Matthew Beason <helfax@hotmail.com> writes:
MB> I'm hoping to gather a few suggestions on the best method for "file
MB> rotation" in Perl. I've created a script which is executed via cron
MB> and creates a mksysb to an NFS mounted partition. I would like to add
MB> a few lines of code that would look at the number of existing mksysbs
MB> for that host and remove all but the two latest files. I realize my
MB> code isn't the best. Please understand that I've just started with
MB> Perl but am working hard to sharpen my skills!
MB> Here is the script:
MB> #!/usr/bin/perl -w
MB> use strict;
strict and -w. good.
MB> if (! -e "/rescue"){
unless is more readable than if ! for most people.
MB> mkdir ("/rescue", 0755);
MB> }
MB> my $mount = system("mount","diablo\:/mksysb","/rescue");
no need to escape :.
MB> $mount == 0 or die "\n";
you could have merged those two above with
die unless system(...) == 0 ;
system(...) == 0 or die ;
MB> my $h = `/usr/bin/hostname`;
MB> chomp($h);
MB> my $d = `/usr/bin/date +"%m%d%Y%H%M"`;
use strftime from POSIX
MB> chomp($d);
MB> my @args = ("mksysb","-i","/rescue/$h.$d.mksysb");
add more whitespace to your code to make it easier to pick out the
individual elements.
my @args = ( "mksysb", "-i", "/rescue/$h.$d.mksysb" );
MB> my $mksysb = system(@args);
MB> $mksysb == 0 or die "\n";
same as above.
MB> my $umount = system("umount","/rescue");
MB> $umount == 0 or die "\n";
ditto
MB> I was thinking of using readdir() and some regular expression pattern
MB> matching. However, I couldn't quite figure out the best way to do
MB> this.
do a readdir in a loop and a stat on each file. make a structure with
the last modified time and file name. sort based on the time stamp and
shift off the top two (keep them). unlink the rest.
you can then take the most recent name and use it to generate the next
one (if that is workable based on the file name).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: 8 Feb 2003 13:23:20 -0800
From: helfax@hotmail.com (Matthew Beason)
Subject: Re: File rotation with Perl
Message-Id: <8b30e085.0302081323.16e72e4c@posting.google.com>
Uri,
Thanks for the code review/advice! I appreciate it! I'm writing the
file rotation portion as we speak!
Matt
Uri Guttman <uri@stemsystems.com> wrote in message news:<x7hebggef3.fsf@mail.sysarch.com>...
> >>>>> "MB" == Matthew Beason <helfax@hotmail.com> writes:
>
> MB> I'm hoping to gather a few suggestions on the best method for "file
> MB> rotation" in Perl. I've created a script which is executed via cron
> MB> and creates a mksysb to an NFS mounted partition. I would like to add
> MB> a few lines of code that would look at the number of existing mksysbs
> MB> for that host and remove all but the two latest files. I realize my
> MB> code isn't the best. Please understand that I've just started with
> MB> Perl but am working hard to sharpen my skills!
>
> MB> Here is the script:
>
> MB> #!/usr/bin/perl -w
>
> MB> use strict;
>
> strict and -w. good.
>
> MB> if (! -e "/rescue"){
>
> unless is more readable than if ! for most people.
>
> MB> mkdir ("/rescue", 0755);
> MB> }
>
> MB> my $mount = system("mount","diablo\:/mksysb","/rescue");
>
> no need to escape :.
>
> MB> $mount == 0 or die "\n";
>
> you could have merged those two above with
>
> die unless system(...) == 0 ;
> system(...) == 0 or die ;
>
> MB> my $h = `/usr/bin/hostname`;
> MB> chomp($h);
> MB> my $d = `/usr/bin/date +"%m%d%Y%H%M"`;
>
> use strftime from POSIX
>
> MB> chomp($d);
>
> MB> my @args = ("mksysb","-i","/rescue/$h.$d.mksysb");
>
> add more whitespace to your code to make it easier to pick out the
> individual elements.
>
> my @args = ( "mksysb", "-i", "/rescue/$h.$d.mksysb" );
>
>
> MB> my $mksysb = system(@args);
> MB> $mksysb == 0 or die "\n";
>
> same as above.
>
> MB> my $umount = system("umount","/rescue");
> MB> $umount == 0 or die "\n";
>
> ditto
>
> MB> I was thinking of using readdir() and some regular expression pattern
> MB> matching. However, I couldn't quite figure out the best way to do
> MB> this.
>
> do a readdir in a loop and a stat on each file. make a structure with
> the last modified time and file name. sort based on the time stamp and
> shift off the top two (keep them). unlink the rest.
>
> you can then take the most recent name and use it to generate the next
> one (if that is workable based on the file name).
>
> uri
------------------------------
Date: 10 Feb 2003 07:27:57 -0800
From: jwcane@enw-ltd.com (Jack Cane)
Subject: Get vs. Post to Perl
Message-Id: <3f29ccb2.0302100727.739d6725@posting.google.com>
This relates to my earlier message on SQL queries to Perl-CGI.
With further testing, I find that the following query works when the
.pl file is requested directly in an HTML "Get" request. However, a
"Post" request fails with a Perl Application Error ('...memory could
not be "read"').
Any ideas?
==================
my $querystring = "select LastName, FirstName, MidInitial, UserName
from MemberNames where MbrNr > 1 and Mbrnr < 27";
==================
------------------------------
Date: Mon, 10 Feb 2003 17:52:40 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Get vs. Post to Perl
Message-Id: <dlpf4vs52rog3n6010lm3r4957tvnb523g@4ax.com>
Jack Cane wrote:
>With further testing, I find that the following query works when the
>.pl file is requested directly in an HTML "Get" request. However, a
>"Post" request fails with a Perl Application Error ('...memory could
>not be "read"').
>
>Any ideas?
This smells like you're doing your own form parameters parsing. Don't.
GET vs. POST shouldn't make a difference.
--
Bart.
------------------------------
Date: 10 Feb 2003 15:02:44 -0800
From: jwcane@enw-ltd.com (Jack Cane)
Subject: Re: Get vs. Post to Perl
Message-Id: <3f29ccb2.0302101502.31eccb21@posting.google.com>
Bart Lateur <bart.lateur@pandora.be> wrote in message news:<dlpf4vs52rog3n6010lm3r4957tvnb523g@4ax.com>...
> Jack Cane wrote:
>
> >With further testing, I find that the following query works when the
> >.pl file is requested directly in an HTML "Get" request. However, a
> >"Post" request fails with a Perl Application Error ('...memory could
> >not be "read"').
> >
> >Any ideas?
>
> This smells like you're doing your own form parameters parsing. Don't.
> GET vs. POST shouldn't make a difference.
Bart,
Not sure what you mean. Here is the code I am trying to use:
my $row1 = param( "ROWSTART" );
my $row2 = param( "ROWEND" );
my $querystring = "select LastName, FirstName, MidInitial, UserName
from MemberNames where MbrNr > ".$row1." and Mbrnr < ".$row2;
I found that, when removing the $row variables and hard-coding the row
number, the query succeeds.
Another query, without form variables, also fails. That code is:
my $querystring = "Select m.FirstName, m.MidInitial, m.LastName,
a.Email, a.address1, a.city, a.staat, a.zipcode, a.phonenr from
MemberNames m, MbrAddress a where (m.MbrNr > 1 and m.mbrNr < 27) and
a.MbrNum = m.MbrNr";
tks,
jwc
------------------------------
Date: 7 Feb 2003 10:15:02 -0800
From: jimh@facetcorp.com (Jim)
Subject: Getting error of perl_get_sv : symbol not found from dynamic linker
Message-Id: <79673d4e.0302071015.e6e84dc@posting.google.com>
After upgrading to perl5.8.0 I started getting the following
error when trying to run "perltidy", a Perl reformatting script:
dynamic linker: /usr/local/bin/perl: symbol not found: perl_get_hv
# nm perl5.005 | grep -i perl_get_sv
[1696] | 134582040| 51|FUNC |GLOB |0 |9 |perl_get_sv
# nm perl5.6.0 | grep -i perl_get_sv
[1982] | 134593592| 51|FUNC |GLOB |0 |9 |perl_get_sv
# nm perl5.8.0 | grep -i perl_get_sv
[1876] | 134657440| 43|FUNC |GLOB |0 |9 |Perl_get_sv
I can see that that the 'p' has been uppercased in the perl5.8.0
version where its lowercase in previous versions. Is this what is
causing the error?
Thanks,
Jim
------------------------------
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 4533
***************************************