[23276] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5496 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 13 00:05:51 2003

Date: Fri, 12 Sep 2003 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 12 Sep 2003     Volume: 10 Number: 5496

Today's topics:
    Re: $SIG{__DIE__} doesn't make sense when using CGI::Ca <zoooz@gmx.de>
        damian classes (was Re: Hierarchical structures with ob <uri@stemsystems.com>
    Re: DBD::CSV questions and is there a DBD::XML? (trwww)
    Re: DBI problem : How can I load quickly one huge table <r_reidy@comcast.net>
    Re: Hierarchical structures with objects <jkeen@concentric.net>
        Matching { } braces ??? <NoSpamPlease@bellsouth.net>
    Re: Matching { } braces ??? <NoSpamPlease@bellsouth.net>
    Re: Perl DBMS <ge0rge@Talk21.com>
    Re: Perl DBMS <dave334234@inter.com>
    Re: Perl DBMS <noreply@gunnar.cc>
    Re: Perl DBMS <flavell@mail.cern.ch>
    Re: Perl DBMS (Tad McClellan)
    Re: Perl DBMS <ebohlman@earthlink.net>
    Re: Perl DBMS <noreply@gunnar.cc>
    Re: Perl DBMS (Jay Tilton)
    Re: Perl DBMS (Tom)
        Removing numbers from a text file (bob)
    Re: Removing numbers from a text file <mgjv@tradingpost.com.au>
    Re: system command question <syscjm@gwu.edu>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 13 Sep 2003 01:50:54 +0200
From: Amir Kadic <zoooz@gmx.de>
Subject: Re: $SIG{__DIE__} doesn't make sense when using CGI::Carp
Message-Id: <bjtm7h$nhopk$1@ID-142982.news.uni-berlin.de>

Jo Oberman wrote:

> When running the skript I get the following message (notice the wrong
> module and line number)
> 
> Just some text
> ERROR-Message: I'm dying. Please help! at
> d:/dev_soft/apache/Perl/lib/CGI/Carp.pm line 301.

To me this seems alright: the exception is _raised_
( by calling die()) in Carp.pm, but it is still 
_your_ handler that is called.

Or am I wrong?

Amir




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

Date: Fri, 12 Sep 2003 22:33:28 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: damian classes (was Re: Hierarchical structures with objects)
Message-Id: <x7r82l7i2v.fsf_-_@mail.sysarch.com>

>>>>> "JEK" == James E Keenan <jkeen@concentric.net> writes:

  JEK>  I follow the practice of separating construction of the object
  JEK> (new()) from initialization (_init()) as advocated by Damian
  JEK> Conway in "Object-Oriented Perl."  I've always found this very
  JEK> straightforward and wonder what the advantages of constructing a
  JEK> hierarchy of objects would be.

and if you want to learn more about OO Perl, modules and regexes from
damian conway, you can take classes with with him in boston on sept 29 -
oct 2.

	http://www.stemsystems.com/class

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Class in Boston - Sept 2003 -- http://www.stemsystems.com/class


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

Date: 12 Sep 2003 17:33:37 -0700
From: toddrw69@excite.com (trwww)
Subject: Re: DBD::CSV questions and is there a DBD::XML?
Message-Id: <d81ecffa.0309121633.5acf1eed@posting.google.com>

"Andrew Crook" <andrew@NOSPAM_andicrook.demon.co.uk> wrote in message news:<bjplk0$pii$1$830fa78d@news.demon.co.uk>...
> > You might be able to retrieve XML via a SQL call and then use an XML
> > parser on that data returned from your query.  Many XML parsers exist
> > for Perl.
> 
> No I don't want the results returned in xml I would like to query a xml file
> as a database source using SQL!

You query XML documents with XPath. Different paradigm, different query language.

> did you mean there this a means to use SQL to query a xml source but the
> result is in the form of xml, which I would then have to parse.

XML is not a RDBMS.

> The actual result would be preferred as a standard record set, but the means
> to do the latter would be better than nothing and may be useful in the
> future.
> 

SELECT * FROM table WHERE foo=5
while ( my @record = $sth->fetchrow_array() ) { ...

//record[@foo = 5]
foreach my $record ( $nodeset->get_nodelist() ) { ...

Dont be afraid of XML. Its not that hard.

Todd W.


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

Date: Fri, 12 Sep 2003 21:43:51 -0600
From: Ron Reidy <r_reidy@comcast.net>
Subject: Re: DBI problem : How can I load quickly one huge table with DBI ??.
Message-Id: <3F629277.1030905@comcast.net>

Since this is Oracle, you have a couple of options:

1.  Use SQL*Loader.  You will **never, ever** be able to write anything 
that will match the speed.  Because of the volume of data, this willbe 
your best option.  make sure you are using the direct method (1).
2.  Use direct inserts with the "/*+ append */" hint (1)
3.  Rewrite this using the Oracle::OCI module.  I am not sure, but you 
may be able to use array processing with this module.  If you can use 
array processing, it will be orders of magnitude faster than single inserts.

(1)  Note:  The direct method will leave your indexes in an invalid 
state.  When the load is completed, they will need to be rebuilt.  Also, 
any triggers you have on these tables will not fire with this method.

In addition to Tim's suggestions, you should be connecting using the 
BEQUEATH SQL*Net connection protocol.  Network traffic could be an issue 
here.

Last, you should look into using the Oracle events system (talk with 
your DBA, or look at the Oracle docs).  This will tell you what is 
slowing you code down.  No matter what you are doing, if you are doing 
Oracle development, you need to know how to use this tool.

Tim Haynes wrote:
> Vincent Le-Texier <texier@ebi.ac.uk> writes:
> 
> 
>>If the query is :
>>
>>my $str_trans  = "INSERT INTO transcript (id,embl_acc) VALUES (?,?)";
>>my $s_trans = $dbh->prepare($str_trans);
>>
>>Foreach entries I want to load into the transcript table , I do :
>>$s_trans->bind_param(1,$id);
>>$s_trans->bind_param(2,$embl_acc);
>>
>>and $s_trans->execute;
> 
> 
> OK. At least you're not preparing it as well as executing it every time :)
> 
> 
>>I would like to known, if there are objects and methods with perl DBI to
>>load by block of statements (execute one statement every 3000 entries for
>>example) instead of each entry.
> 
> 
> Two thoughts:
> 
> a) do you have any indexes or primary keys on the table while you're
> inserting all this stuff? You don't want the hold-up of maintaining the
> index every time, so only create such things after all the data's in place;
> 
> b) sure you can batch things up, with transactions. Turn off auto_commit
> behaviour e.g. like:
> 
>  | $dbh=DBI->connect("dbi:[stuff]", "", "", {AutoCommit => 0})
> 
> and then in your main loop, maintain a counter of number of rows and every
> few hundred, do a commit. Fill in the blanks in the following:
> 
>  | $rowcount=0;
>  | $sth=$dbh->prepare (some_insert_statement);
>  | 
>  | while (looping_over_input_values) {
>  |   $rc=$sth->bind_param(1, something);
>  |   $rc=$sth->bind_param(2, somethingelse);
>  |   $rc=$sth->execute;
>  | 
>  |   if(!($rowcount%100)) {
>  |     $handle->commit;
>  |   }
>  |   $rowcount++;
>  | }
>  | $handle->commit;        # don't forget this after they're all in
> 
> HTH,
> 
> ~Tim


-- 
Ron Reidy
Oracle DBA



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

Date: 12 Sep 2003 22:14:40 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Hierarchical structures with objects
Message-Id: <bjtggg$far@dispatch.concentric.net>


"Gerry Grieve" <grieve@astro.ubc.ca> wrote in message
news:bjtac8$r6$1@nntp.itservices.ubc.ca...
>
> I have some data (course Info) which I'm trying to model as an
> Object "panda_course" which stores the data into a hash.  Besides other
things,
> a "panda_course" can have one or more "sections" which are modelled as
another
> Object & the references are stored in an array @ {
$panda_course->{sections}.
> This part works;
>
The points which Brian Harnish has already made are well taken.  You need to
show us a little of your input data for us to see why your object is not
being constructed properly, and you should use Data::Dumper to get a picture
of the object.

But I would like to know why you are attempting to construct a complicated
(IMHO) object hierarchy when you could get away with constructing a single
object which blesses a multi-dimensional hash into a class.  I recently
faced a similar problem:  Modelling a weekly schedule of treatment groups in
a hospital setting.  I construct just one object where each group (analogous
to your panda_course) can have multiple sessions within a week.  I follow
the practice of separating construction of the object (new()) from
initialization (_init()) as advocated by Damian Conway in "Object-Oriented
Perl."  I've always found this very straightforward and wonder what the
advantages of constructing a hierarchy of objects would be.

The code for such an approach would look roughly like this:

sub new {
    my ($class, $source, $self, $dataref);
    ($class, $source) = @_;

    # bless a ref to an empty hash into the invoking class
    $self = bless {}, ref($class) || $class;

    # prepare the database by using &_init
    $dataref = _init($source);

    # initialize the object from the prepared values (Damian, p. 98)
    %$self = %$dataref;
    return $self;
}

sub _init {
    my $source = shift;
    my (%data);

    open(IN, $source) || die "cannot open $source for reading: $!";
    while (<IN>) {

        # parse the data here; store in %data

    close(IN) || die "cannot close $source: $!";
    return \%data;
}

Jim Keenan




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

Date: Fri, 12 Sep 2003 21:45:32 -0400
From: "Rodney" <NoSpamPlease@bellsouth.net>
Subject: Matching { } braces ???
Message-Id: <HCu8b.4128$Ci3.637@bignews3.bellsouth.net>

In the example below, I'm testing if a string contains either the { or }
braces.  The problem is that it is causing me a syntax error.  The { on the
end of  line #1  is pairing with the  }  on line #11 that is within the
=~m/\}/  pattern search.

Can anyone explain how to avoid this?

-------------------------------------------------------
#1       if ($bodytest_line =~ m/\{/)     {
#2            $StartBraceComment = 1;
#3            $bodyTextLen = length($bodytest_line);
#4            $bodyLineCommentStartPos = index($bodytest_line, "{");
#5            $bodyLineCommentText = substr($bodytest_line,
$bodyLineCommentStartPos, $bodyTextLen);
#6            $bodyLineCommentText = "<I><Font
COLOR=$CommentColor>$bodyLineCommentText";
#7            $bodyLineNotCommentText = substr($bodytest_line, 0,
$bodyLineCommentStartPos);
#8            $bodyLineNotCommentText =
&OpalKeywords($bodyLineNotCommentText);
#9            $bodyLineNotCommentText =
&OpalQuotedText($bodyLineNotCommentText);
#10
#11            if ($bodyLineCommentText =~ m/\}/)     {
#12               $bodyLineCommentText2Len  = length($bodyLineCommentText);
#13               $bodyLineCommentEndPos2   = index($bodyLineCommentText,
"}");
#14               $bodyLineCommentText2     = substr($bodyLineCommentText,
0, $bodyLineCommentEndPos2);
#15               $bodyLineCommentText2     =
"$bodyLineCommentText</FONT></I>";
#16               $StartBraceComment = 0;
#17            }
#18      }



Thanks,
-- 
 ...
    `·.¸¸.·´¯`·.¸¸.·´¯`·->  rodney




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

Date: Fri, 12 Sep 2003 23:24:03 -0400
From: "Rodney" <NoSpamPlease@bellsouth.net>
Subject: Re: Matching { } braces ???
Message-Id: <v2w8b.700$fm2.682@bignews1.bellsouth.net>

Purl,

I'm editing using conTEXT... It has a PERL syntax highlighter built in.
When I paste the code I included ( as an example in the last post )  into
conTEXT and highlight one of the braces... it is suppose to show me the
matching brace by highlighting it too.   This code is throwing it off.

Also... this code is part of a larger code write.  The problem started when
I added the search for the { } braces.  Now my error code tells me:

"Missing right curly or square bracket at
/u/web/XXXXXX/cgi-local/OPALconvert.pl line 485, at end of line
syntax error at /u/web/XXXXXXXX/cgi-local/OPALconvert.pl line 485, at EOF
/u/web/XXXXXXXX/cgi-local/OPALconvert.pl had compilation errors."


Note: line 485 is the last line.  This indicates to me that the problem is
associated with the Braces.

Any help would be appreciated.
Thanks,

-- 
 ...
    `·.¸¸.·´¯`·.¸¸.·´¯`·->  rodney





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

Date: Fri, 12 Sep 2003 23:34:53 +0100
From: "ge0rge" <ge0rge@Talk21.com>
Subject: Re: Perl DBMS
Message-Id: <bjthmi$m4bv9$1@ID-175222.news.uni-berlin.de>

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bjtbju$n7jti$1@ID-184292.news.uni-berlin.de...
> ge0rge wrote:
> > "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> > news:bjsue0$n7l0a$1@ID-184292.news.uni-berlin.de...
> >
> >> Please do not top post!
> >> http://web.presby.edu/~nnqadmin/nnq/nquote.html
> >
> > which says '... they also agree that it's usually in bad taste to
> > correct mistakes publicly'
>
> That was a quote out of context, which btw is bad everywhere.
> Actually, the quoting style document describes various kind of
> newsgroups, and to anybody who has followed _this_ group for a while,
> it stands perfectly clear that you'd better expect public corrections
> if you don't respect the posting guidelines.

Out of context? Perfectly clear to me. Here's another quote then - 'This
document is a description of the traditionally accepted "quoting style" in
Usenet newsgroup postings. Please do not consider this to be a "regulatory"
document ("Thou shalt do it this way because we say so!") ...'

>
> > MS is the principal culprit IMO, not the newbees.
>
> May be true. But pointing out to a newbie that there are posting
> guidelines is a way to help them benefit from this group. It does
> _not_ make him/her a "culprit".

I never said the newbie was culpable. MS is. Don't blame the users, fix the
code - as the saying goes. My IT colleagues who together amongst themselves
must have umpteenth years of computing experience also always top post their
emails. I've learnt to be unconcerned by such a pecadillo. The content is
more important than the form.

BTW, you do realise this is a bit of a wind up.

ge0rge
--
Where it is a duty to worship the sun it is pretty sure to be a crime to
examine the laws of heat.
                -- Christopher Morley





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

Date: Fri, 12 Sep 2003 23:55:55 +0100
From: "Dave" <dave334234@inter.com>
Subject: Re: Perl DBMS
Message-Id: <8as8b.1005$WI3.13044@newsfep4-glfd.server.ntli.net>

#!/usr/bin/perl

print "Content type:text/html\n\n";

my $path = `pwd`;
chomp $path;

opendir(DIR, $path) || print "Could not open $path";
@files = grep { /\.db$/ } readdir(DIR);
closedir(DIR);

my $new_file ="";
my @databases;

foreach $file (@files){

 @info = split(/\./, $file, 2);


 if($info[0] ne $new_file){

    push(@databases, $info[0]);
 }

 $new_file = $info[0];


}

#!/usr/bin/perl

print "Content type:text/html\n\n";

my $path = `pwd`;
chomp $path;

opendir(DIR, $path) || print "Could not open $path";
@files = grep { /\.db$/ } readdir(DIR);
closedir(DIR);

my $new_file ="";
my @databases;

foreach $file (@files){

 @info = split(/\./, $file, 2);


 if($info[0] ne $new_file){

    push(@databases, $info[0]);
 }

 $new_file = $info[0];


}



foreach $file (@databases){

 print "$file\n\n";

 dbmopen(%hash, $file, 0666) || print "Could not open $file ($!)";

## $! gives the error "Invalid Argument"

 foreach $key (keys %hash){

   print "$key : $hash{$key}\n";
 }

 dbmclose(%hash);

}

Ok heres my code. ( sorry that i didnt reply to the requested messages - the
original posts have dissapeared from Outlook!)

Dit not make sense to top post, thus meaning that u dont have to scroll
through pages and pages of stuff just to get the info you want!

Thanks

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bjtbju$n7jti$1@ID-184292.news.uni-berlin.de...
> ge0rge wrote:
> > "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> > news:bjsue0$n7l0a$1@ID-184292.news.uni-berlin.de...
> >
> >> Please do not top post!
> >> http://web.presby.edu/~nnqadmin/nnq/nquote.html
> >
> > which says '... they also agree that it's usually in bad taste to
> > correct mistakes publicly'
>
> That was a quote out of context, which btw is bad everywhere.
> Actually, the quoting style document describes various kind of
> newsgroups, and to anybody who has followed _this_ group for a while,
> it stands perfectly clear that you'd better expect public corrections
> if you don't respect the posting guidelines.
>
> > MS is the principal culprit IMO, not the newbees.
>
> May be true. But pointing out to a newbie that there are posting
> guidelines is a way to help them benefit from this group. It does
> _not_ make him/her a "culprit".
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>




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

Date: Sat, 13 Sep 2003 01:06:50 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl DBMS
Message-Id: <bjtjhq$ncvc2$1@ID-184292.news.uni-berlin.de>

ge0rge wrote:
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
> news:bjtbju$n7jti$1@ID-184292.news.uni-berlin.de...
>> ge0rge wrote:
>>> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message 
>>> news:bjsue0$n7l0a$1@ID-184292.news.uni-berlin.de...
>>>> Please do not top post! 
>>>> http://web.presby.edu/~nnqadmin/nnq/nquote.html
>>> 
>>> which says '... they also agree that it's usually in bad taste
>>> to correct mistakes publicly'
>> 
>> That was a quote out of context, which btw is bad everywhere. 
>> Actually, the quoting style document describes various kind of 
>> newsgroups, and to anybody who has followed _this_ group for a
>> while, it stands perfectly clear that you'd better expect public
>> corrections if you don't respect the posting guidelines.
> 
> Out of context? Perfectly clear to me. Here's another quote then -
> 'This document is a description of the traditionally accepted
> "quoting style" in Usenet newsgroup postings. Please do not
> consider this to be a "regulatory" document ("Thou shalt do it this
> way because we say so!") ...'

Dear George,

Do you have any particular reason for questioning my simple pointer
about top posting?

You'd better study the posting guidelines for _this group_ before
starting a discussion like this. The clpmisc guidelines at
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html,
which express the consensus of _this_ group, say:

     "Intersperse your comments *following* each section of quoted
     text to which they relate. Unappreciated followup styles are
     referred to as "Jeopardy" (because the answer comes before the
     question), or "TOFU".

     Reversing the chronology of the dialog makes it much harder to
     understand (some folks won't even read it if written in that
     style). For more information on quoting style, see:

     http://web.presby.edu/~nnqadmin/nnq/nquote.html "

In other words, the purpose with referring to the general document
about quoting style is to _further explain_ the reason why that
particuar rule is applied in this group.

> My IT colleagues who together amongst themselves must have
> umpteenth years of computing experience also always top post their 
> emails.

Emails is one thing, Usenet groups is another.

> I've learnt to be unconcerned by such a pecadillo. The content is 
> more important than the form.

Then you belong to the minority here. The consensus of _this_ group is
pretty clear. Please respect that.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 13 Sep 2003 01:36:50 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl DBMS
Message-Id: <Pine.LNX.4.53.0309130126160.5502@lxplus002.cern.ch>

On Fri, Sep 12, ge0rge inscribed on the eternal scroll:

> Out of context? Perfectly clear to me. Here's another quote then - 'This
> document is a description of the traditionally accepted "quoting style" in
> Usenet newsgroup postings. Please do not consider this to be a "regulatory"
> document ("Thou shalt do it this way because we say so!") ...'

Indeed.  The advice is to do it not because the FAQ or RFC says you
must, but because the body of other serious participants expect it,
and when they killfile you for ignoring the social mores of the group,
you'll be lucky if one of them bothers to tell you about it.

> > > MS is the principal culprit IMO, not the newbees.

There was (and may still be, for all that I know) an FAQ for
microsoft.* groups which instructs participants to snip the quotage to
the minimum needed for setting context, and place their responses
after the relevant quoted parts.  Does that sound familiar?  For big-8
usent groups, that is even more the expectation.  As for other
hierarchies, I recall an FAQ for alt.english.usage which explained to
its participants that OE placed the cursor at the top of the quoted
material because that was the natural place to start snipping
irrelevant comments before placing one's responses below the relevant
quoted parts to which one referred.  Sounds familiar?

> BTW, you do realise this is a bit of a wind up.

Oh yes.

Did I mention that the best adjunct to participating in usenet is a
well-tended killfile?

-- 
                   Procrastination gives you something to look forward
                           to putting off tomorrow.  -spotted on ahbou


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

Date: Fri, 12 Sep 2003 19:44:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl DBMS
Message-Id: <slrnbm4q48.b2f.tadmc@magna.augustmail.com>

ge0rge <ge0rge@Talk21.com> wrote:

> My IT colleagues who together amongst themselves
> must have umpteenth years of computing experience also always top post their
> emails.


email is not usenet. It is a different dynamic entirely.


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


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

Date: 13 Sep 2003 01:05:59 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: Perl DBMS
Message-Id: <Xns93F4CDEB8C228ebohlmanomsdevcom@130.133.1.4>

"Dave" <dave334234@inter.com> wrote in
news:8as8b.1005$WI3.13044@newsfep4-glfd.server.ntli.net: 

> #!/usr/bin/perl

Name the two things missing here...

> print "Content type:text/html\n\n";
> 
> my $path = `pwd`;
> chomp $path;
> 
> opendir(DIR, $path) || print "Could not open $path";
> @files = grep { /\.db$/ } readdir(DIR);
> closedir(DIR);

You know, don't you, that @files will contain *only* the base names of the 
matching files, *not* their full paths?

> my $new_file ="";
> my @databases;
> 
> foreach $file (@files){
> 
>  @info = split(/\./, $file, 2);
> 
> 
>  if($info[0] ne $new_file){
> 
>     push(@databases, $info[0]);
>  }
> 
>  $new_file = $info[0];
> 
> 
> }

Why are you making separate passes over arrays, instead of doing this 
filtering as you read the filenames?

> foreach $file (@databases){
> 
>  print "$file\n\n";
> 
>  dbmopen(%hash, $file, 0666) || print "Could not open $file ($!)";

Uh oh.  Remember that bit about not having the full path names?

> 
> ## $! gives the error "Invalid Argument"
> 
>  foreach $key (keys %hash){
> 
>    print "$key : $hash{$key}\n";
>  }
> 
>  dbmclose(%hash);
> 
> }


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

Date: Sat, 13 Sep 2003 03:30:42 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl DBMS
Message-Id: <bjts0a$n1n2a$1@ID-184292.news.uni-berlin.de>

Dave wrote:

<code snipped>

> Ok heres my code.

It includes some errors, and Eric pointed out some of those.

I think you need to read up on DBM files, the fact that there are 
different kinds, etc. A start may be 
http://search.cpan.org/author/JHI/perl-5.8.0/lib/AnyDBM_File.pm

 From the code you posted it seems as if the data is stored in 
Berkeley format, and the DB_File module and/or the Berkeley DB library 
is probably not installed on your Windows box.

Below follows some code that reads .db files, prints the contents, and 
saves the data as SDBM databases. SDBM is portable between Unix and 
Windows, and each database consists of two files with .dir respective 
 .pag extensions.

> Dit not make sense to top post, thus meaning that u dont have to scroll
> through pages and pages of stuff just to get the info you want!

Please study the messages about top posting more carefully. ;-)

# Code starts here

#!/usr/bin/perl
use strict;
use warnings;
use CGI::Carp 'fatalsToBrowser';
use DB_File;
use SDBM_File;
use Fcntl;

print "Content-type: text/html\n\n";

my $path = `pwd`;
chomp $path;

opendir DIR, $path or die "Could not open $path\n$!";
my @files = grep { /\.db$/ } readdir DIR;
closedir DIR;

foreach my $file (@files) {
   tie my %hash, 'DB_File', "$path/$file", 0666
    or die "Couldn't open... $!";

   print "$_ : $hash{$_}\n" for keys %hash;

   # Copy data to SDBM
   tie my %hash2, 'SDBM_File', "$path/".(substr $file, 0, -3),
    O_CREAT | O_RDWR, 0666 or die "Couldn't open... $!";
   %hash2 = %hash;
   untie %hash2;

   untie %hash;
}

# Code ends here

Hope that helps!

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Sat, 13 Sep 2003 01:38:32 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Perl DBMS
Message-Id: <3f626cbe.27493142@news.erols.com>

"ge0rge" <ge0rge@Talk21.com> wrote:

: My IT colleagues who together amongst themselves
: must have umpteenth years of computing experience also always top post their
: emails.

The first rule of writing is to write for the audience.  The audience in
clpm prefers articles that meet certain style expectations.  Whatever
goes on in other newsgroups, in email, or among your colleagues is
irrelevant.

: The content is more important than the form.

Then why do novels, proposals, screenplays, instruction manuals, and
musical scores all have distinct and recognizable forms?

In a forum like clpm, presentation can be more important than content,
since readers are not at all obliged to be interested in what an author
has to say.  Cooperation is a matter of pragmatism.  Make readers work
at figuring out what you're saying and they're less likely to work at
helping.



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

Date: 12 Sep 2003 19:13:22 -0700
From: tom@ztml.com (Tom)
Subject: Re: Perl DBMS
Message-Id: <59b4279a.0309121813.57f9a7d4@posting.google.com>

"ge0rge" <ge0rge@Talk21.com> wrote in message news:<bjthmi$m4bv9$1@ID-175222.news.uni-berlin.de>...
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> news:bjtbju$n7jti$1@ID-184292.news.uni-berlin.de...
> > ge0rge wrote:
> > > "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> > > news:bjsue0$n7l0a$1@ID-184292.news.uni-berlin.de...
> > >
> > >> Please do not top post!
> > >> http://web.presby.edu/~nnqadmin/nnq/nquote.html
> > >
> > > which says '... they also agree that it's usually in bad taste to
> > > correct mistakes publicly'
> >
> > That was a quote out of context, which btw is bad everywhere.
> > Actually, the quoting style document describes various kind of
> > newsgroups, and to anybody who has followed _this_ group for a while,
> > it stands perfectly clear that you'd better expect public corrections
> > if you don't respect the posting guidelines.
> 
> Out of context? Perfectly clear to me. Here's another quote then - 'This
> document is a description of the traditionally accepted "quoting style" in
> Usenet newsgroup postings. Please do not consider this to be a "regulatory"
> document ("Thou shalt do it this way because we say so!") ...'
> 
 .
 .

Well, you know what they say, when in Rome do as the Romans do.

Tom
ztml.com


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

Date: 12 Sep 2003 19:42:25 -0700
From: utsuxs@hotmail.com (bob)
Subject: Removing numbers from a text file
Message-Id: <51c3a5d3.0309121842.4a4cc618@posting.google.com>

What would be the most efficient way to remove numbers from a text
file.
eg.  I want "abcde123fghi" to be "abcdefghi".  Should load the file
into an array and create another file with characters that are not
numbers?  With 100k character file for example that could take awhile.
 Any suggestions?
thank you.


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

Date: Sat, 13 Sep 2003 13:07:42 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Removing numbers from a text file
Message-Id: <slrnbm52fu.jbb.mgjv@martien.heliotrope.home>

On 12 Sep 2003 19:42:25 -0700,
	bob <utsuxs@hotmail.com> wrote:
> What would be the most efficient way to remove numbers from a text
> file.

(untested)

$ perl -pi -e 's/\d//g' filename

or

$ perl -pi -e 'tr/0-9//d' filename

There might be more efficient ways, but I don't think it's worth looking
for them, so I won't.

> eg.  I want "abcde123fghi" to be "abcdefghi".  Should load the file
> into an array and create another file with characters that are not
> numbers?

Why should it load the file into an array? 

>           With 100k character file for example that could take awhile.

100k is nothing. Why do you think that "could take awhile'? What do you
define as acceptible performance? I'm sure the above on a reasonable
machine with 100k of input would run more than fast enough. Loading a
100k into an array or scalar and then doing the same would not take much
more or less time. In any case, it's unlikely you'd notice the
difference.

Martien
-- 
                        | 
Martien Verbruggen      | 
                        | The gene pool could use a little chlorine.
                        | 


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

Date: Fri, 12 Sep 2003 18:59:32 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: system command question
Message-Id: <3F624FD4.3000409@gwu.edu>

Andreas Kahari wrote:
> In article <3F61EB8C.8000604@gwu.edu>, Chris Mattern wrote:
> 
>>Himal wrote:
>>
>>>I there a reason why a command will not work if i do system "$cmd &>
>>>xyz.log" even though it works if I do system "$cmd"
>>
>>Most likely, the shell perl is using to parse your command is
>>not csh.  Exactly why this is so would depend on your configuration.
>>Try this, which will work for sh/ksh/bash: system "$cmd >xyz.log 2>&1"
> 
> 
> There is no reason for it to be csh.  The manual for the system
> command says:
> 
>     If  there  is only  one  scalar  argument, the  argument  is
>     checked for shell metacharacters, and  if there are any, the
>     entire argument is passed to  the system's command shell for
>     parsing (this is "/bin/sh -c"  on Unix platforms, but varies
>     on other  platforms).  If there are  no shell metacharacters
>     in the argument, it is  split into words and passed directly
>     to "execvp", which is more efficient.
> 
> So it's either /bin/sh (on Unix systems) or no shell at all.,
> if you haven't done some pretty freakish changes in the default
> configuration.
> 

Ah, OK, I thought it used the user's shell.  OK, then,
system "$cmd >xyz.log 2>&1" should be the answer, assuming
the OP is on a Unix system (which seems logical, since he's
trying to use csh syntax).

                  Chris Mattern



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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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