[22278] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4499 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 1 14:05:45 2003

Date: Sat, 1 Feb 2003 11:05:08 -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           Sat, 1 Feb 2003     Volume: 10 Number: 4499

Today's topics:
    Re: APL's relation to perl <bik.mido@tiscalinet.it>
    Re: Crossposting (was: Fetchrow Question) <me@privacy.net>
        Example perl code & newgroup charters <fma@doe.carleton.ca>
    Re: Example perl code & newgroup charters <tassilo.parseval@post.rwth-aachen.de>
    Re: Example perl code & newgroup charters <fma@doe.carleton.ca>
        Finding out whether program is running. (Brian Salter-Duke)
    Re: Finding out whether program is running. <tassilo.parseval@post.rwth-aachen.de>
    Re: Finding out whether program is running. <abigail@abigail.nl>
    Re: Finding out whether program is running. (Walter Roberson)
        Newsgroup charter? <fma@doe.carleton.ca>
    Re: Newsgroup charter? <family2@aracnet.com>
    Re: Newsgroup charter? <jurgenex@hotmail.com>
    Re: Newsgroup charter? <flavell@mail.cern.ch>
    Re: Newsgroup charter? (Tad McClellan)
    Re: Newsgroup charter? <fma@doe.carleton.ca>
        no -e allowed in setuid scripts? (John Wiersba)
    Re: no -e allowed in setuid scripts? (Alan Barclay)
    Re: Oracle DBD <wolf@code-wizards.com>
    Re: Oracle DBD <rereidy@indra.com>
        Parse a logfile - 1st column DateStamp; extract latest  (shree)
    Re: Parse a logfile - 1st column DateStamp; extract lat <jl@lammtarra.fslife.co.uk>
    Re: Parse a logfile - 1st column DateStamp; extract lat (Tad McClellan)
    Re: Parse a logfile - 1st column DateStamp; extract lat <spam@thecouch.homeip.net>
        passing arguments as key=>value pairs & setting default <bik.mido@tiscalinet.it>
    Re: passing arguments as key=>value pairs & setting def <usenet@tinita.de>
    Re: passing arguments as key=>value pairs & setting def <usenet@tinita.de>
        Perl DBI and Mysql LAST_INSERT_ID() Problem <alex@alexbanks.com>
        Perl-CGI: Return to file problem <md0nilhe@mdstud.DIESPAMchalmers.se>
        sending multiple files via ftp (rick)
    Re: sending multiple files via ftp (Ben Morrow)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 01 Feb 2003 10:58:50 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: APL's relation to perl
Message-Id: <l84n3voa2j371ur21lvtug6r6crq3rrrf9@4ax.com>

On 29 Jan 2003 10:47:54 -0800, kcline17@hotmail.com (Kevin Cline)
wrote:

>> 	for my ($x,$y) ((1..3)*(1..5)) {
>> 	  # do something...
>> 	}
>
>How is this different from the more usual:
>  foreach my $x (1..3) {
>    foreach my $y (1..5) {
>      # do something ...
>    }
>  }

In no way except that it *might* be conceptually more clear and
elegant *in some cases*.

Let me explain: that Perl supports a syntax that *can* resemble that
of natural languages is well known and fascinating.

Now, for me, (at least some part of) mathematical language is quite
natural and intuitive as well, and I guess I'm not the only one.

Coming back to this issue,

On Wed, 22 Jan 2003 20:26:43 -0500, Benjamin Goldberg
<goldbb2@earthlink.net> wrote:

>According Apocolypse 4, you'll be able to do:
>
>	for @foo -> $a, $b {  # two at a time
>		...
>	}
>
>Clear, if @foo contains $x, $y pairs, this will be doable.

Well, this sounds encouraging, but still not fully satisfactory
*according to my own personal tastes*.

In the example above @foo wouldn't contain *pairs*, but a sequence of
values that can be paired... to me a list of *pairs* is a list (finite
sequence) of lists (each with two elements).

Currently a list of lists is implemented as a list of array
references, so a hypothetical syntax more adhering to the *current*
convention could be (supposing that the cartesian product is yielded
by juxtaposition):

  for my [$x,$y] (@foox)(@fooy) { ... }

But then one runs into a series of issues. First, a user might wonder
why he has to write '[$x,$y]', when logically it is a '($x,$y)'; this
could be solved by a sort automatic dereferencing, but I guess that
OTOH such a "feature" may cause major annoyances in (most) other
contexts and so should probably avoided.

More seriously, assuming the above hypothetical convention, what
should (@foox)(@fooy)(@fooz) return? Obviously we would like the
product to be associative and return triples.

But what is a triple? Mathematically, given three sets[*] A,B,C, it
can be either an element of (AxB)xC or of Ax(BxC). These two sets are
not identical, but are isomorphic and we usually make the isomorphism
implicit by simply writing AxBxC.

Coming back to Perl (or rather, programming languages concepts), the
"list operator" given by parentheses "()", is idempotent in a sense
that *could* be made precise: parentheses "inside" other parentheses
silently evaporate and this is the reason why we don't have *real*
lists of lists.

OTOH square parentheses are not "idempotent": [[$a,$b],$c] is
something different from [$a,[$b,$c]].

So what we would like here (with reference to the above issue) is an
intermediate behaviour between these two cases: a pair of parentheses
that can be included in (), but is idempotent. Well at this point I'm
becoming very sloppy, but I guess you can understand what I mean; if
you don't I'll clarify...

Otherwise an ad hoc syntax just for cycles might be adopted (that is,
a sort of shortcut for nested iterations), but initially I was not
thinking *only* to cycles.


I'm sorry for the long post and I hope that at least it will generate
an interessing discussion...


[*] Here we're not dealing with *sets* but with *finite sequences*,
however this is a minor detail.


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


------------------------------

Date: Sat, 1 Feb 2003 21:57:09 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Crossposting (was: Fetchrow Question)
Message-Id: <b1g968$132f7a$1@ID-172104.news.dfncis.de>


"Smiley" <smiley@uvgotemail.com> wrote in message
news:v3mt6q29lb7eec@corp.supernews.com...
> > My post to alt.perl at all?  Surely there's nobody cluefull who'd
> > answer in alt.perl who wouldn't answer in the mainstream Perl groups?
>
> I don't understand, do you find something wrong with alt.perl?  Why is it
> not a mainstream Perl group and what do you consider to be the mainstream
> Perl groups?  Is there some taboo against posting in alt.perl that I don't
> know about?

You'll get much better answers in comp.lang.perl.misc

alt.perl is mostly full of newbies and clueless newbies.  Every now and then
some of the comp.lang.perl.misc regulars keep an eye on this group to ensure
that bad advice is not being propagated.




------------------------------

Date: Sat, 01 Feb 2003 03:24:28 -0500
From: fred <fma@doe.carleton.ca>
Subject: Example perl code & newgroup charters
Message-Id: <3E3B843C.5080805@doe.carleton.ca>

Hello,

I'm using Perl v5.6.1 built for cygwin-multi.
It runs on cygwin  1.3.19-1.  I'm going thru
some example code in "man perlintro":

 > my $variables = {
 >     scalar  =>  {
 >                  description => "single item",
 >                  sigil => '$',
 >                 },
 >     array   =>  {
 >                  description => "ordered list of items",
 >                  sigil => '@',
 >                 },
 >     hash    =>  {
 >                  description => "key/value pairs",
 >                  sigil => '%',
 >                 },
 > };
 >
 > print "Scalars begin with a $variables->{'scalar'}->{'sigil'}\n";

All it prints is

> Scalars begin with a $

I don't want to jump to conclusions
and say it's wrong, but it sure seems
strange for the point being illustrated.
Is it correct?  If not, what might be
wrong?  Do other users of this perl
version (and/or cygwin version) have
the same problem?

I tried to find the charter for these
newsgroups via google (searching for
charter in the subject line, as well
as in general for some of the groups).
Can anyone refer me to this?  Thanks.

Fred



------------------------------

Date: 1 Feb 2003 10:11:27 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Example perl code & newgroup charters
Message-Id: <b1g6gf$r6b$1@nets3.rz.RWTH-Aachen.DE>

Also sprach fred:

> I'm using Perl v5.6.1 built for cygwin-multi.
> It runs on cygwin  1.3.19-1.  I'm going thru
> some example code in "man perlintro":

That's a good idea! Yet I wonder why cygwin's perl5.6.1 has this
manpage. It was introduced in perl5.8.0 and hence shouldn't exist for
older perls.

> > my $variables = {
> >     scalar  =>  {
> >                  description => "single item",
> >                  sigil => '$',
> >                 },
> >     array   =>  {
> >                  description => "ordered list of items",
> >                  sigil => '@',
> >                 },
> >     hash    =>  {
> >                  description => "key/value pairs",
> >                  sigil => '%',
> >                 },
> > };
> >
> > print "Scalars begin with a $variables->{'scalar'}->{'sigil'}\n";
> 
> All it prints is
> 
>> Scalars begin with a $
> 
> I don't want to jump to conclusions
> and say it's wrong, but it sure seems
> strange for the point being illustrated.
> Is it correct?  If not, what might be
> wrong?  Do other users of this perl
> version (and/or cygwin version) have
> the same problem?

The output you get is absolutely right and what I would expect from the
above snippet. Can you explain which output you expected? Is your
confusion perhaps based on the fact that

    $variables->{'scalar'}->{'sigil'}

gets interpolated into a double-quotish string?

> I tried to find the charter for these
> newsgroups via google (searching for
> charter in the subject line, as well
> as in general for some of the groups).
> Can anyone refer me to this?  Thanks.

First of all, you posted to a non-existing group. comp.lang.perl does no
longer exist (even though a lot of newsservers still have it). See
'perldoc -q newsgroups' for details.

As for a charta, I don't know about alt.perl. comp.lang.perl.misc has an
inofficial one that is regularly posted to this group. Search for 

    group:comp.lang.perl.misc "Posting Guidelines"

on groups.google.com and sort by date. The first hit is the most current
version of it. It's good that you ask since you are expected to read
them before actively taking part in this group. Knowing the conventions
in this group will protect you from some unpleasant rants.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Sat, 01 Feb 2003 13:24:05 -0500
From: fred <fma@doe.carleton.ca>
Subject: Re: Example perl code & newgroup charters
Message-Id: <3E3C10C5.5000605@doe.carleton.ca>

Actually, I tried to cancel my post when
I figured out my problem.  It's quite
dumb, really, so I hopt to be forgiven for
not elaborating; in short, I was mistaken
about what was being illustrated by the
code.

Tassilo v. Parseval wrote:
> Also sprach fred:
> 
> 
>>I'm using Perl v5.6.1 built for cygwin-multi.
>>It runs on cygwin  1.3.19-1.  I'm going thru
>>some example code in "man perlintro":
> 
> 
> That's a good idea! Yet I wonder why cygwin's perl5.6.1 has this
> manpage. It was introduced in perl5.8.0 and hence shouldn't exist for
> older perls.

Not sure.  But I did confirm that the
man page is as you said (for 5.8).

>>I tried to find the charter for these
>>newsgroups via google (searching for
>>charter in the subject line, as well
>>as in general for some of the groups).
>>Can anyone refer me to this?  Thanks.
> 
> 
> First of all, you posted to a non-existing group. comp.lang.perl does no
> longer exist (even though a lot of newsservers still have it). See
> 'perldoc -q newsgroups' for details.
> 
> As for a charta, I don't know about alt.perl. comp.lang.perl.misc has an
> inofficial one that is regularly posted to this group. Search for 
> 
>     group:comp.lang.perl.misc "Posting Guidelines"
> 
> on groups.google.com and sort by date. The first hit is the most current
> version of it. It's good that you ask since you are expected to read
> them before actively taking part in this group. Knowing the conventions
> in this group will protect you from some unpleasant rants.
> 
> Tassilo

Thanks for the pointers, Tassilo.

Fred



------------------------------

Date: Sat, 01 Feb 2003 09:29:38 GMT
From: b_duke@octa4.net.invalid (Brian Salter-Duke)
Subject: Finding out whether program is running.
Message-Id: <6sM_9.1586$YU1.37055@news.optus.net.au>

I have this problem. From within a perl script I need to know whether a
particular program is actually running. The program was not started from
the perl script. I have tried using system to run ps with various
options and this sort-of works. Is there a better way? The program is
actually a daemon and basically I want to say:-

Is the daemon running? 

If yes, maybe stop it running

If no, maybe start it.

I do not multiple versions of the daemon running.

I welcome feedback.

Brian.

-- 
Brian Salter-Duke          Humpty Doo, Nr Darwin, Australia
     My real address is b_duke(AT)octa4(DOT)net(DOT)au
               Use this for reply or followup


------------------------------

Date: 1 Feb 2003 10:18:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Finding out whether program is running.
Message-Id: <b1g6t6$rbb$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Brian Salter-Duke:

> I have this problem. From within a perl script I need to know whether a
> particular program is actually running. The program was not started from
> the perl script. I have tried using system to run ps with various
> options and this sort-of works. Is there a better way? The program is
> actually a daemon and basically I want to say:-
> 
> Is the daemon running? 
> 
> If yes, maybe stop it running
> 
> If no, maybe start it.
> 
> I do not multiple versions of the daemon running.
> 
> I welcome feedback.

The most obvious solution might be 

    chomp (my $running = `pidof NAME`);
    if ($running) {
        ...
    }

provided pidof exists.

If you want a more Perlish solution, have a look at Proc::ProcessTable
from the CPAN.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: 01 Feb 2003 13:46:26 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Finding out whether program is running.
Message-Id: <slrnb3njti.evm.abigail@alexandra.abigail.nl>

Brian Salter-Duke (b_duke@octa4.net.invalid) wrote on MMMCDXLI September
MCMXCIII in <URL:news:6sM_9.1586$YU1.37055@news.optus.net.au>:
^^  I have this problem. From within a perl script I need to know whether a
^^  particular program is actually running. The program was not started from
^^  the perl script. I have tried using system to run ps with various
^^  options and this sort-of works. Is there a better way? The program is
^^  actually a daemon and basically I want to say:-
^^  
^^  Is the daemon running? 
^^  
^^  If yes, maybe stop it running
^^  
^^  If no, maybe start it.
^^  
^^  I do not multiple versions of the daemon running.
^^  
^^  I welcome feedback.


Often, daemons write their PID to a file /var/run/daemon_name. 
You could see if that file exists, and if it exists, if the PID
mentioned in it is running.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54" and s/<<EOT/<<EOT/e and print;
Just another Perl Hacker
EOT


------------------------------

Date: 1 Feb 2003 15:41:30 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Finding out whether program is running.
Message-Id: <b1gpra$lcm$1@canopus.cc.umanitoba.ca>

In article <6sM_9.1586$YU1.37055@news.optus.net.au>,
Brian Salter-Duke <b_duke@octa4.net.invalid> wrote:
:I have this problem. From within a perl script I need to know whether a
:particular program is actually running. The program was not started from
:the perl script. I have tried using system to run ps with various
:options and this sort-of works. Is there a better way?

You mention 'ps': are we to assume that you are willing to restrict
the code to Unix? To a particular major stream of Unix (e.g.,
BSD or SVSV)? To a particular operating system? To a particular
version of a particular operating system?

Does the code need to be prepared for the possibility that someone
else might have started a program with the same name? The first
element that shows up in the process table is usually only the last
component of the path (and it isn't even certain to be that),
and it would certainly be easy enough for someone to create a
a completely different path to someone that happened to have that
same name.
-- 
Can a statement be self-referential without knowing it?


------------------------------

Date: Sat, 01 Feb 2003 04:35:05 -0500
From: fred <fma@doe.carleton.ca>
Subject: Newsgroup charter?
Message-Id: <3E3B94C9.7090203@doe.carleton.ca>

Hello,

Could someone please direct me to the
charters for these groups?  I did a
Google Groups search foro "charter"
in the subject (and in the body, for
some of the groups), can't find any.

Thanks.

Fred



------------------------------

Date: Sat, 01 Feb 2003 06:35:42 -0600
From: Abernathey Family <family2@aracnet.com>
Subject: Re: Newsgroup charter?
Message-Id: <3E3BBF1E.B8BD000F@aracnet.com>

fred wrote:
> 
> Hello,
> 
> Could someone please direct me to the
> charters for these groups?  I did a
> Google Groups search foro "charter"
> in the subject (and in the body, for
> some of the groups), can't find any.
--snip--
perldoc -f charter<grin>


------------------------------

Date: Sat, 01 Feb 2003 16:05:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Newsgroup charter?
Message-Id: <NeS_9.9461$dC3.7824@nwrddc02.gnilink.net>

Abernathey Family wrote:
> fred wrote:
>>
>> Hello,
>>
>> Could someone please direct me to the
>> charters for these groups?  I did a
>> Google Groups search foro "charter"
>> in the subject (and in the body, for
>> some of the groups), can't find any.
> --snip--
> perldoc -f charter<grin>

    "No documentation for perl function `charter' found"

Might be useful to check your advice before posting it.
To the OP: other gave the right answer already.

jue




------------------------------

Date: Sat, 1 Feb 2003 17:59:54 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Newsgroup charter?
Message-Id: <Pine.LNX.4.53.0302011727580.30553@lxplus082.cern.ch>

On Feb 1, fred inscribed on the eternal scroll:

> Could someone please direct me to the charters for these groups?

[comp.lang.perl deleted from f'ups, as it no longer officially
exists.]

Technically, the "charter" for a big-8 group is whatever the
proponents said it was at the time of the group's official creation.

The aims of a group can develop with time, e.g when new groups are
created which more-accurately cover topics that were originally
on-topic for the group in question.  If you want to know the
currently-accepted mores of a group, it's better to look for a
new-readers FAQ or posting guidelines FAQ than to worry over-much
about finding the original "charter" as such.

Of course, this group (c.l.p.misc) has a posting guidelines FAQ that
is regularly posted and would be hard to miss...

As for the original _charter_, that would have been in the CFV and
RESULT postings, so if that is your question: the canonical place to
find that for big-8 groups is news.groups and news.announce.newgroups.

So search for comp.lang.perl.misc as the subject, on the group
news.announce.newgroups, and that is where it will be.  As indeed it
is, from 1995, though it's not a lot to speak about, since it says
(paraphrasing) that topics for comp.lang.perl.misc are the same as
they were for comp.lang.perl except for those that got their own
group.  And that comp.lang.perl will be officially deleted after
three months.  So it's high time ;-)

The alt.* hierarchy works differently, of course.

cheers


------------------------------

Date: Sat, 1 Feb 2003 11:42:15 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newsgroup charter?
Message-Id: <slrnb3o1nn.5rb.tadmc@magna.augustmail.com>

Abernathey Family <family2@aracnet.com> wrote:
> fred wrote:


>> Could someone please direct me to the
>> charters for these groups?


> perldoc -f charter<grin>


What a waste.

you could, with about 30 seconds of cognitive effort, give an answer
that gets a person started.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 01 Feb 2003 13:34:14 -0500
From: fred <fma@doe.carleton.ca>
Subject: Re: Newsgroup charter?
Message-Id: <3E3C1326.5060907@doe.carleton.ca>

Thanks, all.  I got an informative
reply (below) on the thread that I
cancelled.

Fred

Tassilo v. Parseval wrote:
 >
 > First of all, you posted to a non-existing group. comp.lang.perl does
 > no longer exist (even though a lot of newsservers still have it).
 > See 'perldoc -q newsgroups' for details.
 >
 > As for a charta, I don't know about alt.perl. comp.lang.perl.misc has
 > an inofficial one that is regularly posted to this group. Search for
 > group:comp.lang.perl.misc "Posting Guidelines"
 >
 > on groups.google.com and sort by date. The first hit is the most
 > current version of it. It's good that you ask since you are expected
 > to read them before actively taking part in this group. Knowing the
 > conventions in this group will protect you from some unpleasant
 > rants.
 >
 > Tassilo



------------------------------

Date: 1 Feb 2003 09:49:26 -0800
From: jrw32982@yahoo.com (John Wiersba)
Subject: no -e allowed in setuid scripts?
Message-Id: <d1c10fb8.0302010949.7b3eaf1d@posting.google.com>

I'm curious:  what is the insecure scenario which the above error
message is trying to protect against?

1) If the perl binary itself is setuid, then that seems at least as
insecure as having it read a script from the command line.  If the
perl binary is not setuid, then either 2) a setuid script file with
#!...perl is being executed, in which case -e is not being used, or 3)
perl is being called by another program which is setuid, in which case
why not let that program call perl -e as it wants to?

I guess I must be missing something but, in any case, it sure is
inconvenient.  My case falls into #3 above -- a setuid program wants
to make use of perl's services via -e without creating a separate file
to hold the one line script.  But the error message forces a separate
script file with no apparent increase in security.

Can anyone explain?

-- John Wiersba


------------------------------

Date: 1 Feb 2003 18:24:06 GMT
From: gorilla@elaine.furryape.com (Alan Barclay)
Subject: Re: no -e allowed in setuid scripts?
Message-Id: <1044123846.546037@elaine.furryape.com>

In article <d1c10fb8.0302010949.7b3eaf1d@posting.google.com>,
John Wiersba <jrw32982@yahoo.com> wrote:
>I'm curious:  what is the insecure scenario which the above error
>message is trying to protect against?

setuid scripts are an instance of a perl program running in Taint
mode.

In taint mode, all filenames must be untainted before being used. It
may be that there is no risk in -e, however there is a possibility,
and therefore the safe thing is to ensure that the program detaints
the value before using it, so that the programmer is forced to think
about the risk.



------------------------------

Date: Sat, 01 Feb 2003 17:37:41 +0100
From: "Wolfgang Hommel" <wolf@code-wizards.com>
Subject: Re: Oracle DBD
Message-Id: <pan.2003.02.01.16.37.41.440827@code-wizards.com>

Hi there,

> I went through this about a year ago and it took me a week to get
> everything installed properly.  Fortunately, Oracle 9i is reported to be
> more Linux friendly than previous versions.

Last time I checked (half a year ago), DBD::Oracle didn't compile with
Oracle 9i... it required an Oracle 8i client installed, but can
communicate with 9i servers without problems as well.

The thing about ODBC is that I haven't found a free Oracle ODBC driver for
Linux yet. On the other hand, if a company can afford an Oracle DB, it
probably also has the pocket money for those drivers :-)


Regards, Wolfgang


------------------------------

Date: Sat, 01 Feb 2003 09:54:58 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Oracle DBD
Message-Id: <3E3BFBE2.5020800@indra.com>

DBD::Oracle compiles with all versions of 9i on Linux (RH).

Wolfgang Hommel wrote:
> Hi there,
> 
> 
>>I went through this about a year ago and it took me a week to get
>>everything installed properly.  Fortunately, Oracle 9i is reported to be
>>more Linux friendly than previous versions.
> 
> 
> Last time I checked (half a year ago), DBD::Oracle didn't compile with
> Oracle 9i... it required an Oracle 8i client installed, but can
> communicate with 9i servers without problems as well.
> 
> The thing about ODBC is that I haven't found a free Oracle ODBC driver for
> Linux yet. On the other hand, if a company can afford an Oracle DB, it
> probably also has the pocket money for those drivers :-)
> 
> 
> Regards, Wolfgang



------------------------------

Date: 1 Feb 2003 05:35:17 -0800
From: srigowrisn@hotmail.com (shree)
Subject: Parse a logfile - 1st column DateStamp; extract latest mods to an ItemNumber
Message-Id: <49b5740e.0302010535.7ee87eca@posting.google.com>

Dear Unix scripting experts,

I have a pipe separated log file of over 100,000 lines - a small
section of it is shown below. Its made up of

TimeStamp in YYYYMMDDHHMMSS
format|ItemNumber|Attribute1|Attribute2|Attribute3

Sample Input File
20020731114502|0144058Y01|CHRM|LHSG|MISC
20030109174500|0144058Y01|PLAS|RHSG|MISC
20021210114501|0144058Y01|PLAS|RHSG|MISC
20021212114500|0164058E01|PLAS|RHSG|MISC
20020731114502|0170273A03|PLAS|MISC|MISC
20020731114502|0170273P03|SILV|MISC|MISC
20030118194502|0170273P03|PLAT|MISC|MISC
20020731114502|0185228C19|PLAS|MISC|MISC
20020924114501|0185228C19|ASSY|SUB|MISC

You will notice that some of the ItemNumbers were modified on
different dates over time. I need to find a way to extract the latest
modified line of each ItemNumber. For any given ItemNumber, all date
stamps corresponding to it are unique and the log file itself isn't in
any sorted order. Hence, once the file is processed, in the output
there should be only 1 line per item number and can look like.

Desired Output
20030109174500|0144058Y01|PLAS|RHSG|MISC
20021212114500|0164058E01|PLAS|RHSG|MISC
20020731114502|0170273A03|PLAS|MISC|MISC
20030118194502|0170273P03|PLAT|MISC|MISC
20020924114501|0185228C19|ASSY|SUB|MISC

Can anyone suggest a snippett, I can apply? My environment is Unix Sun
OS 5.6. As such I have access to binaries that come preinstalled on
unix boxes including awk, sed and perl.

Thanks in advance.

Shree


------------------------------

Date: Sat, 1 Feb 2003 14:29:36 -0000
From: "John L" <jl@lammtarra.fslife.co.uk>
Subject: Re: Parse a logfile - 1st column DateStamp; extract latest mods to an ItemNumber
Message-Id: <b1glel$v5b$1@news6.svr.pol.co.uk>


"shree" <srigowrisn@hotmail.com> wrote in message news:49b5740e.0302010535.7ee87eca@posting.google.com...
> Dear Unix scripting experts,
>
> I have a pipe separated log file of over 100,000 lines - a small
> section of it is shown below. Its made up of
>
> TimeStamp in YYYYMMDDHHMMSS
> format|ItemNumber|Attribute1|Attribute2|Attribute3
>
> Sample Input File
> 20020731114502|0144058Y01|CHRM|LHSG|MISC
> 20030109174500|0144058Y01|PLAS|RHSG|MISC
> 20021210114501|0144058Y01|PLAS|RHSG|MISC
> 20021212114500|0164058E01|PLAS|RHSG|MISC
> 20020731114502|0170273A03|PLAS|MISC|MISC
> 20020731114502|0170273P03|SILV|MISC|MISC
> 20030118194502|0170273P03|PLAT|MISC|MISC
> 20020731114502|0185228C19|PLAS|MISC|MISC
> 20020924114501|0185228C19|ASSY|SUB|MISC
>
> You will notice that some of the ItemNumbers were modified on
> different dates over time. I need to find a way to extract the latest
> modified line of each ItemNumber. For any given ItemNumber, all date
> stamps corresponding to it are unique and the log file itself isn't in
> any sorted order. Hence, once the file is processed, in the output
> there should be only 1 line per item number and can look like.

> [ snip ]

> Can anyone suggest a snippett, I can apply? My environment is Unix Sun
> OS 5.6. As such I have access to binaries that come preinstalled on
> unix boxes including awk, sed and perl.

Are you sure perl was standard on Solaris 2.6? Not that it matters.

sort -t'|' -k2,2 -k1,1nr log | awk -F'|' '$2 != last { print; last = $2 }'

If you had a stable sort, you could use sort -u in place of the awk, but
Solaris hasn't, so you can't.

John.





------------------------------

Date: Sat, 1 Feb 2003 11:33:43 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Parse a logfile - 1st column DateStamp; extract latest mods to an ItemNumber
Message-Id: <slrnb3o17n.5ci.tadmc@magna.augustmail.com>

shree <srigowrisn@hotmail.com> wrote:

> Its made up of
> 
> TimeStamp in YYYYMMDDHHMMSS
> format|ItemNumber|Attribute1|Attribute2|Attribute3


> I need to find a way to extract the latest
> modified line of each ItemNumber.


> Can anyone suggest a snippett, I can apply?


------------------------------------
#!/usr/bin/perl
use strict;
use warnings;

my %seen;
while ( <DATA> ) {
   my($time, $id) = split /\|/;
   if ( exists $seen{$id} )
      { next unless $time gt $seen{$id}{time} }
   $seen{$id} = { time => $time, data => $_ };
}

print $seen{$_}{data} for sort keys %seen;

__DATA__
20020731114502|0144058Y01|CHRM|LHSG|MISC
20030109174500|0144058Y01|PLAS|RHSG|MISC
20021210114501|0144058Y01|PLAS|RHSG|MISC
20021212114500|0164058E01|PLAS|RHSG|MISC
20020731114502|0170273A03|PLAS|MISC|MISC
20020731114502|0170273P03|SILV|MISC|MISC
20030118194502|0170273P03|PLAT|MISC|MISC
20020731114502|0185228C19|PLAS|MISC|MISC
20020924114501|0185228C19|ASSY|SUB|MISC
------------------------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Sat, 01 Feb 2003 11:30:08 -0500
From: Mina Naguib <spam@thecouch.homeip.net>
Subject: Re: Parse a logfile - 1st column DateStamp; extract latest mods to an ItemNumber
Message-Id: <kCS_9.7345$Cc6.203099@wagner.videotron.net>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1



shree wrote:
| Dear Unix scripting experts,
|
| I have a pipe separated log file of over 100,000 lines - a small
| section of it is shown below. Its made up of
|
| TimeStamp in YYYYMMDDHHMMSS
| format|ItemNumber|Attribute1|Attribute2|Attribute3
|
| Sample Input File
| 20020731114502|0144058Y01|CHRM|LHSG|MISC
| 20030109174500|0144058Y01|PLAS|RHSG|MISC
| 20021210114501|0144058Y01|PLAS|RHSG|MISC
| 20021212114500|0164058E01|PLAS|RHSG|MISC
| 20020731114502|0170273A03|PLAS|MISC|MISC
| 20020731114502|0170273P03|SILV|MISC|MISC
| 20030118194502|0170273P03|PLAT|MISC|MISC
| 20020731114502|0185228C19|PLAS|MISC|MISC
| 20020924114501|0185228C19|ASSY|SUB|MISC
|
| You will notice that some of the ItemNumbers were modified on
| different dates over time. I need to find a way to extract the latest
| modified line of each ItemNumber. For any given ItemNumber, all date
| stamps corresponding to it are unique and the log file itself isn't in
| any sorted order. Hence, once the file is processed, in the output
| there should be only 1 line per item number and can look like.
|
| Desired Output
| 20030109174500|0144058Y01|PLAS|RHSG|MISC
| 20021212114500|0164058E01|PLAS|RHSG|MISC
| 20020731114502|0170273A03|PLAS|MISC|MISC
| 20030118194502|0170273P03|PLAT|MISC|MISC
| 20020924114501|0185228C19|ASSY|SUB|MISC

Hey Shree

It's ugly (all 1-liners are) but it'll work:

perl -naF'\|' -e '$i{$F[1]} = $_ if ($F[0] > $i{$F[1]}); END {print sort
values %i}' infilename > outfilename

If you want it sorted by the item id as in your "desired output":

perl -naF'\|' -e '$i{$F[1]} = $_ if ($F[0] > $i{$F[1]}); END {map {print
$i{$_}} sort keys %i}' infilename > outfilename

For large datasets these little scripts will eat up a lot of memory (I'd guess
1.3 times the size of the data itself).  They can be re-written to keep track
of where the data is in the file, then re-iterate over the file and prints it
out...

Best of luck.

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+O/YQeS99pGMif6wRApj+AKDBA9vpY/vtBC1Vvzs7LtZxQwbV0gCgwfIi
N/TX7a1qOpHVmd/KW62BITM=
=bDQd
-----END PGP SIGNATURE-----



------------------------------

Date: Sat, 01 Feb 2003 10:58:52 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: passing arguments as key=>value pairs & setting default options
Message-Id: <q44n3v0l5e4ir3m7qjivj79tsi3dq39cl6@4ax.com>

If I write a sub to be used with a syntax of the kind:

  test(foo => "myfoo", baz => "mybaz");

how can I set up defaults for (some of) the arguments? A
straightforward solution that occurred to me (BTW, I'm aware that
TIMTOWTDI!!) is:

  sub test {
      my %params=@_;
      my %options=(foo => "foo-default",
		   bar => "bar-default",
		   baz => "baz-default");
      @options{keys %params}=values %params;
      print $options{$_} for sort keys %options;
  }

What I personally find not completely satisfying, even if it is not an
unbearable concern, is to have to use an accessory hash just to take a
slice. I tried also the following:

  sub test1 {
      my %options=(foo => "foo-default",
		   bar => "bar-default",
		   baz => "baz-default");
      @options{keys %{{@_}}}=values %{{@_}};
      print $options{$_} for sort keys %options;
  }

and it *seems* to work as expected, but then I wonder if there are any
issues with this syntax (apart, possibly, readability ones).

Also, it seems awkward in any case to make an anonymous hash and then
dereferencing it: is there a direct way to coerce an array into an
anonymous hash, and possibly without duplicating the effort behind the
scenes (as I suspect is happening with the code above for "test1")?


Michele
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


------------------------------

Date: 1 Feb 2003 10:36:09 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: passing arguments as key=>value pairs & setting default options
Message-Id: <tinh9mlm7$17l$tina@news01.tinita.de>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> If I write a sub to be used with a syntax of the kind:

>   test(foo => "myfoo", baz => "mybaz");

> how can I set up defaults for (some of) the arguments? A
> straightforward solution that occurred to me (BTW, I'm aware that
> TIMTOWTDI!!) is:

>   sub test {
>       my %params=@_;
>       my %options=(foo => "foo-default",
> 		   bar => "bar-default",
> 		   baz => "baz-default");
>       @options{keys %params}=values %params;

sub test {
  my %options = (
    foo => "foo-default",
    bar => "bar-default",
    baz => "baz-default",
    @_
  );
  # ...
}

hth, tina

-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


------------------------------

Date: 1 Feb 2003 12:14:14 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: passing arguments as key=>value pairs & setting default options
Message-Id: <tinh9mq5t$1bj$tina@news01.tinita.de>

Tina Mueller <usenet@tinita.de> wrote:

> sub test {
>   my %options = (
>     foo => "foo-default",
>     bar => "bar-default",
>     baz => "baz-default",
>     @_
>   );
>   # ...
> }

or what i like even more:
use constant DEFAULTS =>
  ( foo => "foo-default", bar => "bar-default", baz => "baz-default");

sub test {
  my %options = (
    DEFAULTS, @_
  );
}
# read in Damian's OO-Perl,
# becomes useful as soon as you need the defaults elsewhere
# in the program

tina
-- 
http://www.tinita.de/        \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/      \     / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/   \    \ _,_\ __/\ __/_| /__/ perception


------------------------------

Date: Sat, 1 Feb 2003 13:39:33 -0000
From: "Alex Banks" <alex@alexbanks.com>
Subject: Perl DBI and Mysql LAST_INSERT_ID() Problem
Message-Id: <3e3bce1a$0$245$cc9e4d1f@news.dial.pipex.com>

This works when I use the command line interface for MySQL, but not when I
send instructions through DBI...

In my simplified example, I have two tables...

create table onetb (pkey int not null primary key auto_increment,
description text null);
create table twotb (pkey int not null, fkey int not null, primary key (pkey,
fkey) );

I want to insert a value into onetb, but then grab the primary key to use as
the fkey value of twotb. Here's my Perl:

use DBI;
$dbh = DBI -> connect ("DBI:mysql:fabdb","user","password");
$sql = "insert into onetb (pkey, description) values (NULL,'Description goes
here')";
$sth = $dbh -> prepare($sql);
$sth -> execute; #fine

$sql = "insert into twotb (pkey, fkey) values (2,LAST_INSERT_ID())";
$sth = $dbh -> prepare($sql);
$sth -> execute; #error

I get an error in my Apache logfile from MySQL saying I'm there's an error
in my SQL near LAST_INSERT_ID());.

Can anyone offer a solution?

Alex




------------------------------

Date: Sat, 01 Feb 2003 16:38:57 +0100
From: henrik nilsson <md0nilhe@mdstud.DIESPAMchalmers.se>
Subject: Perl-CGI: Return to file problem
Message-Id: <3E3BEA11.2080604@mdstud.DIESPAMchalmers.se>

Hello,

In my script, the user has a choice to get the outdata on h/is/er screen 
or as a file. Both options work fine.

However, when I try to first return the script outdata to the user's 
screen and *then* to a file at the user's end, the screen output comes 
out OK, but the contents of the file is printed right below it, as 
opposed to being returned as a file.

The file return routine looks something like this:

sub returntofile {
	unless (-e "bas.txt") { exit; }
	my $content_length = (-s "bas.txt");
	print "Content-Type:application/octet-stream
	Content-Disposition:attachment; filename=bas.txt
	Content-Length:$content_length\n\n";
	binmode(STDOUT);
	open(DOWNLOAD, "bas.txt") or &err;
	binmode(DOWNLOAD);
	while (<DOWNLOAD>) { print $_; }
	close(DOWNLOAD) or &err;
}

What am I doing wrong?

Thanks,

Henrik N



------------------------------

Date: 1 Feb 2003 04:44:23 -0800
From: rick_va@yahoo.com (rick)
Subject: sending multiple files via ftp
Message-Id: <d55af2de.0302010444.20867a90@posting.google.com>

Hello Everyone,

rather than re-inventing the wheel I thought I would post as see if
someone has written something similar to this..

I am in need of a perl script that does the following ..

takes a number of files say 20 or so and ftp's them to a server .. 
now I dont want this to run sequentially doing something like that I
can
just write a little shell script that submits one after anonther but
rather
I want a shotgun type effect where it reads all the file names and
creates an separate ftp job for each file and then sends it to the
server .. I am trying to emulate what one of our mainframes is doing
 .. because I keep getting calls from our Mainframe programmers saying
we are tired of resubmitting jobs
manually when they fail and I can understand that since there are
1000's of these type jobs

thanx in advance


------------------------------

Date: Sat, 1 Feb 2003 13:02:44 +0000 (UTC)
From: mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: sending multiple files via ftp
Message-Id: <b1gghk$p4i$1@wisteria.csv.warwick.ac.uk>

rick_va@yahoo.com (rick) wrote:
>Hello Everyone,
>
>rather than re-inventing the wheel I thought I would post as see if
>someone has written something similar to this..
>
>I am in need of a perl script that does the following ..
>
>takes a number of files say 20 or so and ftp's them to a server .. 
>now I dont want this to run sequentially doing something like that I
>can
>just write a little shell script that submits one after anonther but
>rather
>I want a shotgun type effect where it reads all the file names and
>creates an separate ftp job for each file and then sends it to the
>server ..

This should be relatively straightforward to write using Net::FTP and fork().
Or, if you prefer, you could just invoke "ftp < commands &" using system once
for each file: these will then run simultaneously, but you will have problems
detecting errors.

Ben


------------------------------

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 4499
***************************************


home help back first fref pref prev next nref lref last post