[18469] in Perl-Users-Digest
Perl-Users Digest, Issue: 637 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 5 14:06:17 2001
Date: Thu, 5 Apr 2001 11:05:22 -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: <986493921-v10-i637@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 5 Apr 2001 Volume: 10 Number: 637
Today's topics:
$text in a text file - how do I get it to print? <alan@scotlpuk.com>
Re: $text in a text file - how do I get it to print? <bmb@ginger.libs.uga.edu>
Re: $text in a text file - how do I get it to print? (Tad McClellan)
Re: $text in a text file - how do I get it to print? nobull@mail.com
Re: 7300 Uninitialized Value warnings with DBD::CSV 0.1 <webmaster@webdragon.unmunge.net>
@INC question <dantes@geocities.com>
altivec support? <nospam@yale.edu>
Re: array and hash presentation as text <bmb@ginger.libs.uga.edu>
Re: array and hash presentation as text (Tad McClellan)
Re: Can module distinguish between "use" and exec invoc (Mark Jason Dominus)
Re: Can module distinguish between "use" and exec invoc (Sweth Chandramouli)
Re: CGI Form to Generated Table ( )
Re: General Personal Development Strategy lvirden@cas.org
Re: General Personal Development Strategy lvirden@cas.org
help needed converting beteen sybase::ctlib and win32:: Darrick
help needed converting beteen sybase::ctlib and win32:: Darrick
Re: help needed with sorting Hash <moverho1@nycap.rr.com>
Re: Hmmm... Which PERL Book Is Best Suited For This??? <uri@sysarch.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 5 Apr 2001 16:05:19 +0100
From: "Alan Fleming" <alan@scotlpuk.com>
Subject: $text in a text file - how do I get it to print?
Message-Id: <dN%y6.3890$bL6.702047@news2-win.server.ntlworld.com>
I have a program which reads info from a plain text file, containing
variable names, eg:
Hi, my name is $name, and I am $age years old...
What I would like to be able to do in perl, is have the variables printed as
their contents, rather than the var-name. One problem I have is that I will
never know what variables will be contained in the file, so I can't simply
search for a var-name and replace it with it's contents. I'd like to have
some code which would allow me to search for a $ followed by xxx, where xxx
is the actual variable name.
I'm not explaining too well, but I think you can get at what I'm meaning.
If you need more info to help me, just let me know.
Alan
------------------------------
Date: Thu, 5 Apr 2001 11:38:40 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: $text in a text file - how do I get it to print?
Message-Id: <Pine.A41.4.21.0104051137580.16576-100000@ginger.libs.uga.edu>
On Thu, 5 Apr 2001, Alan Fleming wrote:
> I have a program which reads info from a plain text file, containing
> variable names, eg:
This is frequently asked:
perldoc -q variables
Brad
------------------------------
Date: Thu, 5 Apr 2001 10:26:00 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: $text in a text file - how do I get it to print?
Message-Id: <slrn9cp03o.iu7.tadmc@tadmc26.august.net>
Alan Fleming <alan@scotlpuk.com> wrote:
>I have a program which reads info from a plain text file, containing
>variable names, eg:
>
>Hi, my name is $name, and I am $age years old...
>
>What I would like to be able to do in perl, is have the variables printed as
>their contents, rather than the var-name.
Perl FAQ, part 4:
"How can I expand variables in text strings?"
>One problem I have is that I will
>never know what variables will be contained in the file, so I can't simply
>search for a var-name and replace it with it's contents.
You could have perl do the replacement for you:
perldoc -f do
(you want the "do EXPR" form)
>I'd like to have
>some code which would allow me to search for a $ followed by xxx, where xxx
>is the actual variable name.
Why would you like that?
If I were you, I would like to "get it done" without having to
write such code.
:-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 05 Apr 2001 18:45:24 +0100
From: nobull@mail.com
Subject: Re: $text in a text file - how do I get it to print?
Message-Id: <u9snjnqlzf.fsf@wcl-l.bham.ac.uk>
Brad Baxter <bmb@ginger.libs.uga.edu> writes:
> On Thu, 5 Apr 2001, Alan Fleming wrote:
> > I have a program which reads info from a plain text file, containing
> > variable names, eg:
>
> This is frequently asked:
>
> perldoc -q variables
See also answers in the newsgroup to the last few dozen occourances of
this question because the FAQ omits the obvious, simple but hazardous
solution.
This is bad because:
1) The simple solution is more powerfull.
2) Lots of people work out the simple solution for themselves without
realising the dangers.
3) "Don't give people powerfull tools in case they hurt themselves"
goes against the Perl ethos.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 5 Apr 2001 17:57:21 GMT
From: "Scott R. Godin" <webmaster@webdragon.unmunge.net>
Subject: Re: 7300 Uninitialized Value warnings with DBD::CSV 0.1025 ! (mildly urgent)
Message-Id: <9aibm1$21f$0@216.155.32.238>
In article <9ae1l5$n0g$0@216.155.33.72>,
"Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote:
| In article <9aal4v$6qn$0@216.155.32.18>,
| "Scott R. Godin" <webmaster@webdragon.unmunge.net> wrote:
|
| | just out of curiosity (and since a message to someone else reminded me
| | that I could also do this :) I checked my weblogs with tail -f to see if
| | anything shows up that I was unaware of with one of my scripts, and lo!
| | there's about 7300 lines of this:
| |
| | [Mon Apr 2 14:24:09 2001] ncmapslistdbi.cgi: Use of uninitialized value
| | at /opt/lib/perl5/site_perl/DBD/CSV.pm line 197.
| | [Mon Apr 2 14:24:09 2001] ncmapslistdbi.cgi: Use of uninitialized value
| | at /opt/lib/perl5/site_perl/DBD/CSV.pm line 197, <GEN1> chu
| | nk 1.
|
| Hmm.. apparently the version on the ISP is slightly newer than mine ..
| note change below
|
| | the offending code section:
| | -=-
| | package DBD::CSV::Table;
| |
| | @DBD::CSV::Table::ISA = qw(DBD::File::Table);
| |
| | sub fetch_row ($$) {
| | my($self, $data) = @_;
| | my $fields;
| | if (exists($self->{cached_row})) {
| | $fields = delete($self->{cached_row});
| | } else {
|
| undef $!; ### <-- the offending line 197?
|
| (according to the line numbering in less, anyway.
|
| I'm still stuck on this, and *any* assistance would still be much
| appreciated.
|
| | my $csv = $self->{csv_csv};
| | local $/ = $csv->{'eol'};
| | $fields = $csv->getline($self->{'fh'});
| | if (!$fields) {
| | die "Error while reading file " . $self->{'file'} . ": $!" if $!;
| | return undef;
| | }
| | }
| | $self->{row} = (@$fields ? $fields : undef);
| | }
| | -=-
| | I'm sure there's a reason for this -- but not 100% certain as to what.
| |
| | the script body itself can be viewed here, in the most recent version
| |
| | <http://216.155.0.50/~sgodin/misc/codesample.htm>
| |
| | (too long to post here)
| |
| | I looked at my code again and cannot really see where this might be
| | coming from. ANY help would be appreciated.. I'm QUITE sure my ISP would
| | prefer and appreciate that I don't fill their weblogs with 7300 lines of
| | this crap every time my script gets accessed. :/
| |
| | Any assistance appreciated.
*sigh* days pass and no response either here or on the Mailing lists
I've posted to -- have I got everyone stumped? Or did I somehow wind up
in killfiles without realizing it?
I revised the subject line slightly since the version number of the
module is slightly different.
--
unmunge e-mail here:
#!perl -w
print map {chr(ord($_)-3)} split //, "zhepdvwhuCzhegudjrq1qhw";
# ( damn spammers. *shakes fist* take a hint. =:P )
------------------------------
Date: Thu, 5 Apr 2001 11:09:40 -0400
From: "Brian Alexandre" <dantes@geocities.com>
Subject: @INC question
Message-Id: <9ai1ob01ri9@enews1.newsguy.com>
I'm compiling perl from source on a Linux box. I (just to try it) decided to
make the install path /usr/Perl/ and I go through the configure script
without any trouble, changing the appropriate path values. But when I run
'make install' and it installs perl, the @INC array always contains the
default path of /usr/local/lib/.... which does not exist. I can't find any
reference to '/usr/local/lib' in the configure.sh file, or any other file
I've checked.
Can anyone tell me from what file or script @INC is initially populated?
------------------------------
Date: Thu, 5 Apr 2001 15:08:04 GMT
From: "ivo welch" <nospam@yale.edu>
Subject: altivec support?
Message-Id: <9ai1oj$pn0$1@news.ycc.yale.edu>
Has anyone written perl support for the Mac G4's altivec features?
/iaw
------------------------------
Date: Thu, 5 Apr 2001 11:14:39 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: array and hash presentation as text
Message-Id: <Pine.A41.4.21.0104051108120.16576-100000@ginger.libs.uga.edu>
On Thu, 5 Apr 2001, Tad McClellan wrote:
> Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>
> >Brad (I'm not data)
>
> Shoot!
>
> We never get any TV stars hanging out with us here :-(
Well, I do look like a star.
Visit my site: www.yanni.com
Brad
------------------------------
Date: Thu, 5 Apr 2001 11:12:05 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: array and hash presentation as text
Message-Id: <slrn9cp2q5.j6t.tadmc@tadmc26.august.net>
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>On Thu, 5 Apr 2001, Tad McClellan wrote:
>> Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>>
>> >Brad (I'm not data)
>>
>> Shoot!
>>
>> We never get any TV stars hanging out with us here :-(
>
>Well, I do look like a star.
So you twinkle then?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 05 Apr 2001 16:06:43 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Can module distinguish between "use" and exec invocations?
Message-Id: <3acc9813.1200$371@news.op.net>
In article <Y8%y6.25191$iU.4775483@news1.rdc1.md.home.com>,
Sweth Chandramouli <sweth+perl@gwu.edu> wrote:
>In article <3acc28e2.8e3$1a2@news.op.net>,
>Mark Jason Dominus <mjd@plover.com> wrote:
>>In article <%4Ky6.22413$iU.4184631@news1.rdc1.md.home.com>,
>>Sweth Chandramouli <sweth+perl@gwu.edu> wrote:
>>> This only works from inside a subroutine invoked
>>>from outside of the module, though--right?
>>
>>Right, but a smart guy like you should be able to figure it out from
>>this hint.
> Well, I haven't been a smart guy since just after FTSD '96,
>which explains why I can't see it.
if ((caller)[0]) {
$MODE = "Module";
} else {
$MODE = "Standalone.\n";
}
sub Sweths_Subroutine_that_needs_to_know_that_could_be_invoked_from_anywhere {
if ($MODE eq 'Module') [
print "I was invoked as a module.\n";
} else {
print "I was invoked as a standalone program.\n";
}
}
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Thu, 05 Apr 2001 16:43:15 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: Can module distinguish between "use" and exec invocations?
Message-Id: <Dg1z6.25659$iU.4806977@news1.rdc1.md.home.com>
In article <m3bsqbtny9.fsf@mumonkan.sunstarsys.com>,
Joe Schaefer <joe+usenet@sunstarsys.com> wrote:
>And what Perl function should the outside caller use in order to load
>your module?
[...]
>Run slower tests, and put the suggested code snippet outside of any
>subroutines in your module.
Gah. My apologies; I should have been able to figure that
one out on my own. Thanks for explaining what should have been obvious.
-- Sweth, ashamed.
--
Sweth Chandramouli ; <sweth+perl@gwu.edu>
------------------------------
Date: Thu, 05 Apr 2001 16:00:19 GMT
From: "( ) | 3 ]" <obiwan@mahood.com>
Subject: Re: CGI Form to Generated Table
Message-Id: <3ACC96A1.4A9774A7@mahood.com>
Outsource.
Tim Sutton wrote:
> I need to prepare a page for my company's intranet, and need to let workers fill out form data to book equipment for weeks
> at a time. I need a script that
> will take their form data, then add it to a table that is dynamically updated. Any suggestions? Thanks!
------------------------------
Date: 5 Apr 2001 16:00:22 GMT
From: lvirden@cas.org
Subject: Re: General Personal Development Strategy
Message-Id: <9ai4qm$sl7$1@srv38.cas.org>
According to John Hall <jhall@ifxonline.com>:
:I am curious if someone can give me a more constructive method/procedure for
:figuring out ways of writing perl code.
That would be great, wouldn't it?
:Will the fact that I don't know C cripple me? [I notice a
:lot of things in perldoc say 'similar to how it's done in C'].
I think that a good understanding of the standard C library is still pretty
important. Since that is the technology that underlies a significant portion
of Perl, knowing it will enable you to comprehend concepts quicker.
--
--
"See, he's not just anyone ... he's my son." Mark Schultz
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting
------------------------------
Date: 5 Apr 2001 16:06:36 GMT
From: lvirden@cas.org
Subject: Re: General Personal Development Strategy
Message-Id: <9ai56c$sl7$2@srv38.cas.org>
According to Martien Verbruggen <mgjv@tradingpost.com.au>:
:On Thu, 04 Jan 2001 01:29:53 GMT,
: John Hall <jhall@ifxonline.com> wrote:
:> I see a lot of "you work stupid" and "RTFM" on this list.
:
:Mostly when it is deserved.
Treating someone poorly, regardless of their inappropriate behavior, seldom
converts them to one's point of view, creates barriors, and in all likelihood
burns bridges which, one day, one may regret having burned (imagine if
you will finding yourself across the hiring desk from someone that you
might have treated that way...)
--
--
"See, he's not just anyone ... he's my son." Mark Schultz
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting
------------------------------
Date: 5 Apr 2001 17:13:32 GMT
From: Darrick
Subject: help needed converting beteen sybase::ctlib and win32::odbc
Message-Id: <9ai93s35m9@news2.newsguy.com>
Hello,
I'm a newbie to Perl, and Data access, I was wondering if someone could help me out... I have a script that reads a text file defines fields that i wish to retrieve, and posts to a odbc source.. ie.. (sql or MS Access) this script is written using SYBASE::CTLIB... I wish to use WIN32::ODBC... I have not fully comprehended the syntax of the win32::odbc yet... I'm still at the beginning of my learning curve... Below is an example of the script; I am hopeful that someone will help me along my way in the conversion between the two modules... Any pointers, suggestions, or code examples would be very helpful... I have done some extensive searching for example code, without very much luck... I have grasped the connection, form query, and inserting fields to odbc source... I am currently having problems with retrieving results from my transaction and printing them to screen...
I have started to convert the script to win32::odbc, i am having trouble interpreting the two "ct_callback statments" and all past "$X->ct_execute("use database");"... once again any help would be great...
Thank You...
Darrick Brockway
mailto://darrick.brockway@eds.com
sample follows:
use Sybase::CTlib;
$uid = 'sa';
$pwd = 'sa';
$srv = 'odbc-server';
ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
ct_callback(CS_SERVERMSG_CB, "srv_cb");
$X = Sybase::CTlib->ct_connect($uid,$pwd,$srv);
%months = qw(
January 01
February 02
March 03
April 04
May 05
June 06
July 07
August 08
September 09
October 10
November 11
December 12);
$linenumb = 0;
#uudecode filter
$lnum = 0;
while (<>) {
$logfile[$lnum] = $_;
#print ("$lnum $logfile[$lnum]");
$lnum = $lnum + 1;
}
$client = "";
$server = "";
$start = "";
$end = "";
$btype = "";
$type = "";
$size = 0;
$status = "";
$i = 0;
$verify =0;
#print ("-----$filename-----\n");
while ($logfile[$i] ne "") {
while ($logfile[$i] =~ /'/) {
$logfile[$i] =~ s/'/./;
}
if ($logfile[$i] =~ /\bJob Operation - Verify/) {
$verify = 1;
}
# server
if ($logfile[$i] =~ /\bJob server:/) {
chomp ($server = $logfile[$i]);
$server =~ s/Job server: //;
}
# client
if ($logfile[$i] =~ /\bJob name:/) {
chomp ($client = $logfile[$i]);
$client =~ s/Job name: //;
$client =~ s/ -.*//;
}
# start
if ($logfile[$i] =~ /\bJob started:/) {
chomp ($tempstring = $logfile[$i]);
$tempstring =~ s/Job started: //;
$tempstring =~ s/\w*, //;
$tempstring =~ s/,//;
$tempstring =~ s/:/ /;
$tempstring =~ s/at //;
@datetemp = split (/ /, $tempstring);
$datetemp[0] = $months{$datetemp[0]};
if ($datetemp[5] eq "PM") { $datetemp[3] = $datetemp[3] + 12;}
if ($datetemp[5] eq "AM") {
if ($datetemp[3] eq 12) { $datetemp[3] = 0;}}
$start = $datetemp[2] . "-" . $datetemp[0] . "-" . $datetemp[1]
. " " . $datetemp[3] . ":" . $datetemp[4];
}
# end
if ($logfile[$i] =~ /\bJob ended:/) {
chomp ($tempstring = $logfile[$i]);
$tempstring =~ s/Job ended: //;
$tempstring =~ s/\w*, //;
$tempstring =~ s/,//;
$tempstring =~ s/:/ /;
$tempstring =~ s/at //;
@datetemp = split (/ /, $tempstring);
$datetemp[0] = $months{$datetemp[0]};
if ($datetemp[5] eq "PM") { $datetemp[3] = $datetemp[3] + 12;}
if ($datetemp[5] eq "AM") {
if ($datetemp[3] eq 12) { $datetemp[3] = 0;}}
$end = $datetemp[2] . "-" . $datetemp[0] . "-" . $datetemp[1]
. " " . $datetemp[3] . ":" . $datetemp[4];
}
# type
if ($logfile[$i] =~ /\bJob type:/) {
chomp ($type = $logfile[$i]);
$type =~ s/Job type: //;
}
# btype
if ($logfile[$i] =~ /\bBackup Type:/) {
chomp ($btype = $logfile[$i]);
$btype =~ s/Backup Type: //;
$btype =~ s/ -.*//;
}
# size
if ($verify == 0) {
if ($logfile[$i] =~ /\bProcessed /) {
chomp ($tempsize = $logfile[$i]);
$tempsize =~ s/Processed //;
$tempsize =~ s/,//g;
$tempsize =~ s/ bytes.*//;
$size = $size + $tempsize;
}}
# status
if ($logfile[$i] =~ /\bJob completion status:/) {
chomp ($status = $logfile[$i]);
$status =~ s/Job completion status: //;
}
$i = $i + 1;
}
#print ("$client\n");
#print ("$server\n");
#print ("$type\n");
#print ("$btype\n");
#print ("$size\n");
#print ("$status\n");
#print ("$start\n");
#print ("$end\n");
$statement = "INSERT INTO table VALUES ('$client','$server','$type','$btype',$size,'$status','$start','$end','";
$i = 0;
while ($logfile[$i] ne "") {
$statement = $statement . $logfile[$i];
$i = $i + 1;
}
$statement = $statement . "')";
$X->ct_execute("use database");
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
$restype == CS_CMD_SUCCEED);
if(@names = $X->ct_col_names()) {
# print "@names\n";
}
if(@types = $X->ct_col_types()) {
# print "@types\n";
}
while(@dat = $X->ct_fetch) {
# print "@dat\n";
}
}
if ($client ne "") {
$X->ct_execute("$statement");
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
$restype == CS_CMD_SUCCEED);
if(@names = $X->ct_col_names()) {
# print "@names\n";
}
if(@types = $X->ct_col_types()) {
# print "@types\n";
}
while(@dat = $X->ct_fetch) {
# print "@dat\n";
}
}
}
sub msg_cb {
my($layer, $origin, $severity, $number, $msg, $osmsg, $dbh) = @_;
printf STDERR "\nOpen Client Message: (In msg_cb)\n";
printf STDERR "Message number: LAYER = (%ld) ORIGIN = (%ld) ",
$layer, $origin;
printf STDERR "SEVERITY = (%ld) NUMBER = (%ld)\n",
$severity, $number;
printf STDERR "Message String: %s\n", $msg;
if (defined($osmsg)) {
printf STDERR "Operating System Error: %s\n", $osmsg;
}
CS_SUCCEED;
}
sub srv_cb {
my($dbh, $number, $severity, $state, $line, $server,
$proc, $msg) = @_;
# If $dbh is defined, then you can set or check attributes
# in the callback, which can be tested in the main body
# of the code.
printf STDERR "\nServer message: (In srv_cb)\n";
printf STDERR "Message number: %ld, Severity %ld, ",
$number, $severity;
printf STDERR "State %ld, Line %ld\n", $state, $line;
if (defined($server)) {
printf STDERR "Server '%s'\n", $server;
}
if (defined($proc)) {
printf STDERR " Procedure '%s'\n", $proc;
}
printf STDERR "Message String: %s\n", $msg; CS_SUCCEED;
}
==================================
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: 5 Apr 2001 17:13:32 GMT
From: Darrick
Subject: help needed converting beteen sybase::ctlib and win32::odbc
Message-Id: <9ai93s25m9@news2.newsguy.com>
Hello,
I'm a newbie to Perl, and Data access, I was wondering if someone could help me out... I have a script that reads a text file defines fields that i wish to retrieve, and posts to a odbc source.. ie.. (sql or MS Access) this script is written using SYBASE::CTLIB... I wish to use WIN32::ODBC... I have not fully comprehended the syntax of the win32::odbc yet... I'm still at the beginning of my learning curve... Below is an example of the script; I am hopeful that someone will help me along my way in the conversion between the two modules... Any pointers, suggestions, or code examples would be very helpful... I have done some extensive searching for example code, without very much luck... I have grasped the connection, form query, and inserting fields to odbc source... I am currently having problems with retrieving results from my transaction and printing them to screen...
I have started to convert the script to win32::odbc, i am having trouble interpreting the two "ct_callback statments" and all past "$X->ct_execute("use database");"... once again any help would be great...
Thank You...
Darrick Brockway
mailto://darrick.brockway@eds.com
sample follows:
use Sybase::CTlib;
$uid = 'sa';
$pwd = 'sa';
$srv = 'odbc-server';
ct_callback(CS_CLIENTMSG_CB, \&msg_cb);
ct_callback(CS_SERVERMSG_CB, "srv_cb");
$X = Sybase::CTlib->ct_connect($uid,$pwd,$srv);
%months = qw(
January 01
February 02
March 03
April 04
May 05
June 06
July 07
August 08
September 09
October 10
November 11
December 12);
$linenumb = 0;
#uudecode filter
$lnum = 0;
while (<>) {
$logfile[$lnum] = $_;
#print ("$lnum $logfile[$lnum]");
$lnum = $lnum + 1;
}
$client = "";
$server = "";
$start = "";
$end = "";
$btype = "";
$type = "";
$size = 0;
$status = "";
$i = 0;
$verify =0;
#print ("-----$filename-----\n");
while ($logfile[$i] ne "") {
while ($logfile[$i] =~ /'/) {
$logfile[$i] =~ s/'/./;
}
if ($logfile[$i] =~ /\bJob Operation - Verify/) {
$verify = 1;
}
# server
if ($logfile[$i] =~ /\bJob server:/) {
chomp ($server = $logfile[$i]);
$server =~ s/Job server: //;
}
# client
if ($logfile[$i] =~ /\bJob name:/) {
chomp ($client = $logfile[$i]);
$client =~ s/Job name: //;
$client =~ s/ -.*//;
}
# start
if ($logfile[$i] =~ /\bJob started:/) {
chomp ($tempstring = $logfile[$i]);
$tempstring =~ s/Job started: //;
$tempstring =~ s/\w*, //;
$tempstring =~ s/,//;
$tempstring =~ s/:/ /;
$tempstring =~ s/at //;
@datetemp = split (/ /, $tempstring);
$datetemp[0] = $months{$datetemp[0]};
if ($datetemp[5] eq "PM") { $datetemp[3] = $datetemp[3] + 12;}
if ($datetemp[5] eq "AM") {
if ($datetemp[3] eq 12) { $datetemp[3] = 0;}}
$start = $datetemp[2] . "-" . $datetemp[0] . "-" . $datetemp[1]
. " " . $datetemp[3] . ":" . $datetemp[4];
}
# end
if ($logfile[$i] =~ /\bJob ended:/) {
chomp ($tempstring = $logfile[$i]);
$tempstring =~ s/Job ended: //;
$tempstring =~ s/\w*, //;
$tempstring =~ s/,//;
$tempstring =~ s/:/ /;
$tempstring =~ s/at //;
@datetemp = split (/ /, $tempstring);
$datetemp[0] = $months{$datetemp[0]};
if ($datetemp[5] eq "PM") { $datetemp[3] = $datetemp[3] + 12;}
if ($datetemp[5] eq "AM") {
if ($datetemp[3] eq 12) { $datetemp[3] = 0;}}
$end = $datetemp[2] . "-" . $datetemp[0] . "-" . $datetemp[1]
. " " . $datetemp[3] . ":" . $datetemp[4];
}
# type
if ($logfile[$i] =~ /\bJob type:/) {
chomp ($type = $logfile[$i]);
$type =~ s/Job type: //;
}
# btype
if ($logfile[$i] =~ /\bBackup Type:/) {
chomp ($btype = $logfile[$i]);
$btype =~ s/Backup Type: //;
$btype =~ s/ -.*//;
}
# size
if ($verify == 0) {
if ($logfile[$i] =~ /\bProcessed /) {
chomp ($tempsize = $logfile[$i]);
$tempsize =~ s/Processed //;
$tempsize =~ s/,//g;
$tempsize =~ s/ bytes.*//;
$size = $size + $tempsize;
}}
# status
if ($logfile[$i] =~ /\bJob completion status:/) {
chomp ($status = $logfile[$i]);
$status =~ s/Job completion status: //;
}
$i = $i + 1;
}
#print ("$client\n");
#print ("$server\n");
#print ("$type\n");
#print ("$btype\n");
#print ("$size\n");
#print ("$status\n");
#print ("$start\n");
#print ("$end\n");
$statement = "INSERT INTO table VALUES ('$client','$server','$type','$btype',$size,'$status','$start','$end','";
$i = 0;
while ($logfile[$i] ne "") {
$statement = $statement . $logfile[$i];
$i = $i + 1;
}
$statement = $statement . "')";
$X->ct_execute("use database");
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
$restype == CS_CMD_SUCCEED);
if(@names = $X->ct_col_names()) {
# print "@names\n";
}
if(@types = $X->ct_col_types()) {
# print "@types\n";
}
while(@dat = $X->ct_fetch) {
# print "@dat\n";
}
}
if ($client ne "") {
$X->ct_execute("$statement");
while(($rc = $X->ct_results($restype)) == CS_SUCCEED) {
next if($restype == CS_CMD_DONE || $restype == CS_CMD_FAIL ||
$restype == CS_CMD_SUCCEED);
if(@names = $X->ct_col_names()) {
# print "@names\n";
}
if(@types = $X->ct_col_types()) {
# print "@types\n";
}
while(@dat = $X->ct_fetch) {
# print "@dat\n";
}
}
}
sub msg_cb {
my($layer, $origin, $severity, $number, $msg, $osmsg, $dbh) = @_;
printf STDERR "\nOpen Client Message: (In msg_cb)\n";
printf STDERR "Message number: LAYER = (%ld) ORIGIN = (%ld) ",
$layer, $origin;
printf STDERR "SEVERITY = (%ld) NUMBER = (%ld)\n",
$severity, $number;
printf STDERR "Message String: %s\n", $msg;
if (defined($osmsg)) {
printf STDERR "Operating System Error: %s\n", $osmsg;
}
CS_SUCCEED;
}
sub srv_cb {
my($dbh, $number, $severity, $state, $line, $server,
$proc, $msg) = @_;
# If $dbh is defined, then you can set or check attributes
# in the callback, which can be tested in the main body
# of the code.
printf STDERR "\nServer message: (In srv_cb)\n";
printf STDERR "Message number: %ld, Severity %ld, ",
$number, $severity;
printf STDERR "State %ld, Line %ld\n", $state, $line;
if (defined($server)) {
printf STDERR "Server '%s'\n", $server;
}
if (defined($proc)) {
printf STDERR " Procedure '%s'\n", $proc;
}
printf STDERR "Message String: %s\n", $msg; CS_SUCCEED;
}
==================================
Posted via http://nodevice.com
Linux Programmer's Site
------------------------------
Date: Thu, 05 Apr 2001 17:04:33 GMT
From: "Mark" <moverho1@nycap.rr.com>
Subject: Re: help needed with sorting Hash
Message-Id: <BA1z6.4088$wQ1.357348@typhoon.nyroc.rr.com>
Hash Value Sorting
maybe this will help?
1. #!/usr/local/bin/perl
2.
3. %Inventory = (car=>45_000.00,bike=>120.00,plane=>
450_000.00,lamp=>40.00);
4. $sortHash = \%Inventory;
5. @keyList = sort sortHashByValue keys %Inventory;
6. foreach $key (@keyList){
7. print "key==>$key, \tprice==>$Inventory{$key}\n";
8. }
9.
10. sub sortHashByValue(){
11. $$sortHash{"$a"} <=> $$sortHash{"$b"};
12. }
------------------------------
Date: Thu, 05 Apr 2001 15:13:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Hmmm... Which PERL Book Is Best Suited For This???
Message-Id: <x7snjns7le.fsf@home.sysarch.com>
>>>>> "l" == lvirden <lvirden@cas.org> writes:
l> According to Uri Guttman <uri@sysarch.com>:
l> :only the online perl docs (over 1100
l> :pages) are the complete reference.
l> If the online perl docs were a 'complete reference' then there probably
l> would be no need for the Camel book...
you are mistaken about the meaning of the word reference. there is only
one perl reference out there and that is the online docs. period. all
other perl text is either explanation, examples, clarification etc. none
have any authority above and beyond the docs, even the camel. camel 3 is
based on 5.6, and what happens when 5.6.1 (or who knows 5.8) comes out?
all of asudden camel 3 becomes outdated. and knowing how long it takes
for books to get published it will be outdated for some time after that.
so there is a need for books as hey cover stuff and explain it in ways
that the docs don't or can't. but they will never replace the docs as
they can't be as accurate or up to date.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 637
**************************************