[16777] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4189 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 31 11:10:25 2000

Date: Thu, 31 Aug 2000 08:10:14 -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: <967734614-v9-i4189@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 31 Aug 2000     Volume: 9 Number: 4189

Today's topics:
    Re: Jumping to the previous row with DBI (Martien Verbruggen)
    Re: Module, Code for paged search results? (Martien Verbruggen)
    Re: Module, Code for paged search results? <randy@theoryx5.uwinnipeg.ca>
        pack function mgopi@csa.iisc.ernet.in
    Re: Parsing a Excell table - or - a "Tab New_Line" text <info@digitaltango.com>
    Re: perl newbie seeks assistance michaeljgardner@my-deja.com
    Re: Q. relating to  perlfaq(4) / sort <ren.maddox@tivoli.com>
    Re: Q. relating to  perlfaq(4) / sort <ren.maddox@tivoli.com>
        Sending mail with Perl for Windows NT?? <Stuntman@koan.com>
    Re: Using SDBM_File to compare large files. c_j_marshall@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Fri, 1 Sep 2000 00:50:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Jumping to the previous row with DBI
Message-Id: <slrn8qsokm.ucf.mgjv@martien.heliotrope.home>

On Wed, 30 Aug 2000 15:11:52 +0200,
	Hans Eriksson <Hans.X.Eriksson@etx.ericsson.se> wrote:
> Hello!
> 
> Does anyone know if it is possible to go to the prevoius row when using
> the Perl DBI interface? I.e. -- Is it possible to "go back" when a
> $sth->fetchrow has been issued?

Unless you cache them yourself, I doubt very much it's possible. I've
never seen anything that would do the job. I've never seen anything like
that in any other database drivers (that I've worked with) either. I've
never needed it. I think you probably will have to cache the stuff
yourself and use that.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: Fri, 1 Sep 2000 00:53:50 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Module, Code for paged search results?
Message-Id: <slrn8qsore.ucf.mgjv@martien.heliotrope.home>

On 31 Aug 2000 08:09:08 +0200,
	Heinrichmeyer <fritz.heinrichmeyer@fernuni-hagen.de> wrote:
> Is there a ready to use module to represent database search results as
> pages (like in gdmsearch, altavista etc.)?

No. 

But using the DBI module, one of the DBD::* drivers and a few print
statements, you could probably quickly create some text output that you
could send to your printer.

gdmsearch I don't know. i didn't know altavista came in printed form.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Freudian slip: when you say one
Commercial Dynamics Pty. Ltd.   | thing but mean your mother.
NSW, Australia                  | 


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

Date: 31 Aug 2000 14:32:08 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Module, Code for paged search results?
Message-Id: <8olq98$bpp$1@canopus.cc.umanitoba.ca>

In comp.lang.perl.misc, 
    Heinrichmeyer <fritz.heinrichmeyer@fernuni-hagen.de> wrote:
> Is there a ready to use module to represent database search results as
> pages (like in gdmsearch, altavista etc.)?

You might want to look at DBIx::Recordset - documentation on
its use is available at, eg,
http://theoryx5.uwinnipeg.ca/CPAN/data/DBIx-Recordset/Recordset.html

best regards,
randy kobes


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

Date: 31 Aug 2000 14:19:53 GMT
From: mgopi@csa.iisc.ernet.in
Subject: pack function
Message-Id: <8olpi9$p3d$1@news.netmar.com>

can anybody explain what exactly a perl function does. does it find the bit
pattern
of the argument and puts them in an array or what.
thanx in advance


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Thu, 31 Aug 2000 13:28:17 GMT
From: "Etienne Laverdiere" <info@digitaltango.com>
Subject: Re: Parsing a Excell table - or - a "Tab New_Line" text file?
Message-Id: <R3tr5.208502$Gh.4105314@news20.bellglobal.com>

Hi all,
Thanks Bob and Jeff,

I read the last post of Jeff Zucker about the OBDC configuration to avoid a
strange Data Typing. However I did not understood many things. I still would
rather prefer to use the DBI: OBDC package.
I didn't correct my datatyping bug right now (neither the fact that it
cannot read more than 255 characters, plus all my "number fields" are
interpreted with a additional 0 following a dot.)

I am designing a quite large Intranet and I already use DBI:OBDC for the
entire query to a database. (My prototype is working on Access right now).
For a reason of portability, it would be better to minimize the ways I query
my database.

Anyway. I will try the WIN32 solution  if you think that the only way.


Best Regards for all,

Etienne Laverdiere
Montreal


Here's the code I am working on :


#example of using DBI with Excel
use DBI;
#use Data::Dumper;

my $drv  = 'ODBC:driver=Microsoft Excel Driver (*.xls)';
my $dir  = 'd:/data/base_prod.xls'; #an Excel file
my $table = '[Sheet1$]'; #a range name
my $dbh  = DBI->connect( "dbi:$drv;Dbq=$dir",,,{RaiseError=>1} )
or die $DBI::errstr;
$dbh->{LongReadLen}=100000;   # I tried that
$sth->{LongReadLen} =100000;  # and that
my $sth  = $dbh->prepare("select * from $table");
my $names=$sth->{NAME};

 ... # printing @$names

print "dbh: " . $dbh->{LongReadLen} . "\n<br><br><br><br>";
print "sth: " . $sth->{LongReadLen} . "\n<br><br><br><br>";
my $array_ref  = $dbh->selectall_arrayref($sth);

## and printing everything.. to field larger than 255 can be viewed. And it
stops the databases' parsing.



"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:39ADB61E.9F4E4AC@rochester.rr.com...
> Etienne Laverdiere wrote:
> >
> > Yes you are right. I have the same problem now.
> > "Mixed numbers and text in a given column don't work.!"
> > I must find a way to import any data of any type, like reading for all
field
> > 'type=>text' for a number or a real text.
> > I will continue searching. If you have a solution don't hesitate to
write it
> > here.
> >
> > Best Regards,
> >
> > Etienne Laverdiere
> > Montreal
> >
> ...
> Etienne, please see my reply to your note time-stamped Saturday at 11:51
> PM EDT for how to do what you want to do using OLE.  That method returns
> whatever the contents of each cell is.  If you can't find that note,
> here is the code:
>
>      use Win32::OLE;
>      use Data::Dumper;
>      # use existing instance if Excel is already running
>      eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')};
>      die "Excel not installed" if $@;
>      die "Excel not running" unless defined $ex;
>      $wb=$ex->Workbooks(1);
>      $ws=$wb->Worksheets(1);
>      $ref=$ws->Range("B2:E10")->Value;
>      print Dumper($ref);
>
> That uses the first worksheet of the first workbook.
> --
> Bob Walton




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

Date: Thu, 31 Aug 2000 14:41:38 GMT
From: michaeljgardner@my-deja.com
Subject: Re: perl newbie seeks assistance
Message-Id: <8olqqu$i91$1@nnrp1.deja.com>

In article <8ol5nu$qb8$1@nnrp1.deja.com>,
  billgreenwood@my-deja.com wrote:
> Hello group
>
> My name is bill greenwood and i am a prepress guy
> at a uk repro house, we have SGI system and i would
> like to use the power of perl and unix to make our
> lives a little easier.
>
> I need assistance with my first [of many i hope]
> perl script.
>
> My aim is to have a script that takes the name of a
> postscript file and copies that to memory, then

You mean it copies the contents of the file to memory??

> finds a text string within specified parameters
> "/Title(**********)def" with stars being  a
> variable wildcard text string, then and inserts/
> pastes the previously copied filename before the
> wildcard text string wherever it is found in the
> document.
>

So you file the string and insert the filename into the middle of it??
> Finaly saving the document to another directory and
> deleting the first or maybe even passing the file
> to another application.

Save revisions to new file, delete old.
>
> I will then attempt to make this script watch a
> drirectory for postsctipt/text files to action
> upon.
>

Save this for second lesson...
> i can be contacted direct at
> bill.greenwood@colourpath.co.uk
>
> many thnaks to all who take the time to reply
>
> thanks for listening
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

I'll start with the contents of the "from " file.

this is a file with /Title(**********)def whatever in it. The
file is composed of 1231243245235 characters etc.,
/Title(**********)def and some  other things in it


Now the Perl script
# DECLARE VARIABLES
my($fh1,$fh2,$fname1,$fname2,$filecontents);

# ASSIGN NAMES OF FILE, THIS COULD BE DONE WITH USER INPUT
# I.E. USING <STDIN> TO FILE A VARIABLE NAME
$fname1='d:\perlprog\pscript.txt';
$fname2='d:\perlprog\pscript2.txt';

# ASSIGN FILEHANDLES
$fh1='first filename';
$fh2='second filename';

# OPEN FROM FILE
open($fh1,$fname1)|| die "could not open ".$fname1;

# READ CONTENTS INTO A SINGLE SCALAR, IF FILE IS LARGE THIS
# MAY NOT BE A GOOD IDEA
while (<$fh1>){
     $filecontents.=$_;
};

# DONE WITH FILE SO CLOSE IT
close($fh1);

# USE REGEX TO REPLACE STRING IN THIS CASE
$filecontents=~s/(Title\()(\*{10}\)def)/\1$fname1\2/g;

# OPEN TO FILE SINGLE GT SIGN MEANS OVERWRITE EXISTING
open($fh2,'>'.$fname2);

# PRINT REVISED FILE CONTENTS TO IT
print $fh2 $filecontents;

# CLOSE THE NEW FILE
close($fh2);

# DELETE THE FIRST FILE
unlink($fname1);

And finally the contents of the new file;

this is a file with /Title(d:\perlprog\pscript.txt**********)def
whatever in it.
file is composed of 1231243245235 characters etc.,
/Title(d:\perlprog\pscript.txt**********)def and some  other things in
it


The from file is named d:\perlprog\pscript.txt and the to file is named
d:\perlprog\pscript2.txt on my machine.  You can the the names to
whatever you want.  I'm running under Windows, you may need to add
#! /usr/perl/bin as the first line for a UNIX machine.

HTH,
Michael


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 31 Aug 2000 08:42:15 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Q. relating to  perlfaq(4) / sort
Message-Id: <m3k8cx4keg.fsf@dhcp11-177.support.tivoli.com>

Abe Timmerman <abe@ztreet.demon.nl> writes:

> Nope, add the next line to your data:
> 
> 	321  45 567 789
> 
> If you want to sort numbers, use a numerical pack() format.
> 
> 	my @sorted = map substr($_, 4) => sort
> 		map pack(N => -(split)[1]) . $_ => @data;
> 

Yeah... my bad.  Always a struggle choosing between finishing that
last post or leaving on time.  As it was I was a couple of minutes
late for my destination.  I should have just held off on the post and
let someone else do it....

-- 
Ren Maddox
ren@tivoli.com


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

Date: 31 Aug 2000 09:01:09 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Q. relating to  perlfaq(4) / sort
Message-Id: <m3hf814jiy.fsf@dhcp11-177.support.tivoli.com>

Larry Rosler <lr@hpl.hp.com> writes:

> In article <m3pumq4aof.fsf@dhcp11-177.support.tivoli.com> on 30 Aug 2000 
> 18:00:00 -0500, Ren Maddox <ren.maddox@tivoli.com> says...
> >
> > In this case, I believe you are looking for something like:
> > 
> > #!/usr/local/bin/perl -w
> > use strict;
> > 
> > my @data = <DATA>;
> > print reverse sort {
> >    my @a_flds = split ' ', $a;
> >    my @b_flds = split ' ', $b;
> >    $a_flds[1] <=> $b_flds[1]
> > } @data;
> > 
> > __DATA__
> > 123 234 345 456
> > 231 456 789 999
> > 321 345 567 789
> 
> Needn't 'reverse' if you switch $a... and $b... in the comparison.

Yeah, I just threw that in because I knew I would want it later....
 
> > After a suitable GRT, you probably end up with something like:
> > 
> > #!/usr/local/bin/perl -w
> > use strict;
> > 
> > my @data = <DATA>;
> > print reverse map {
> >    substr $_, rindex $_, "\0"
> > } sort map {
> >    pack "A*xA*", (split)[1], $_
> > } @data;
> > 
> > __DATA__
> > 123 234 345 456
> > 231 456 789 999
> > 321 345 567 789
> 
> There is a small error in the extraction (1 + rindex...), and you 
> switched from numerical to alphabetic sort (which doesn't matter for 
> this data set, but would matter if the numbers don't have exactly the 
> same number of digits).

Imagine that... two of my posts in the same day both had null-related
bugs that I (naturally) didn't notice from the output.  I think I'll
be using "od -c" as a sanity check from now on....

> Numerical sorts are done with either a pack-N or a sprintf'ed sortkey.
> 
>   print reverse map {
>      substr $_, 4
>   } sort map {
>      pack 'NA*' => (split)[1], $_
>   } @data;
> 
>   print reverse map {
>      substr $_, 10
>   } sort map {
>      sprintf '%.10u%s' => (split)[1], $_
>   } @data;
> 
> In each case, the sortkeys may be shortened if the maximum integer is 
> restricted.  The shorter the sortkey, the faster the sort; but this is a 
> small effect.

I already replied to Abe about this mistake, but this does touch on a
question I've had.

How do you handle numeric comparison of arbitrary precision numbers?
I suppose you could just find the maximum magnitude and prepend with
0s, though you also have to handle negative numbers....

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 31 Aug 2000 07:54:50 -0700
From: "Robert Leonard III" <Stuntman@koan.com>
Subject: Sending mail with Perl for Windows NT??
Message-Id: <sqssafgnc5d7@corp.supernews.com>

I'm trying to write a little program to fire off an e-mail... but can't seem
to find any method to do this.

I am using  the latest and greatest from ActiveState on my Windows 2000
server...

Any ideas would be GREATLY appreciated!





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

Date: Thu, 31 Aug 2000 14:43:11 GMT
From: c_j_marshall@my-deja.com
Subject: Re: Using SDBM_File to compare large files.
Message-Id: <8olqtq$iag$1@nnrp1.deja.com>


>
> You may be able to use that feature when you combine it with a hash
> that associates each key with the corresponding record number in the
> file.  That way you can randomly hop around your data based on
> keys.
>
> Anno
>


Ah - so I guess it does the exact opposite of what I want. It takes a
hash and pushes it onto a file - I want to take a file and push it into
a hash.

Oh well, cheers anyway.

The build_index() on recipe 8.8 of the cookbook seems to be my best way
forward. There is after all, alledgedly, more than one way to do it.



Sent via Deja.com http://www.deja.com/
Before you buy.


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

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 V9 Issue 4189
**************************************


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