[12553] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6153 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 28 08:07:35 1999

Date: Mon, 28 Jun 99 05:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 28 Jun 1999     Volume: 8 Number: 6153

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: Command line parameters / Wildcard characters / Rec <eman@cc.gatech.edu>
        Foreach on hash gives undefined value <thomas@bibsyst.no>
        From Sybase::DBlib to DBI::mysql (Jon Eslund)
    Re: From Sybase::DBlib to DBI::mysql <garethr@cre.canon.co.uk>
    Re: How to store hashes <garethr@cre.canon.co.uk>
    Re: Learning Perl exercises using reverse <swiftkid@bigfoot.com>
    Re: Linux better than perl? (Marcel Grunauer)
    Re: My script works! PLEASE HELP!!! <garethr@cre.canon.co.uk>
    Re: Perl under Win32--file date. <swiftkid@bigfoot.com>
        please help, changing characters..... hamed53@my-deja.com
        printf and formate to wirte  number in #.###,## <claudio@elettrodata.it>
        reading Outlook NT emails (baga@gmx.net)
    Re: reading Outlook NT emails <gellyfish@gellyfish.com>
    Re: Removing spaces from string <JFedor@datacom-css.com>
    Re: Returning output from a secondary perl script? <alister@ihug.co.nz>
    Re: Returning output from a secondary perl script? <swiftkid@bigfoot.com>
        Server side issues... <dr_avalanche1959@yahoo.com>
    Re: TIMEOUT <Ch1ckEn@hotmail.com>
    Re: Trapping validation errors in XML:Parser (Arved Sandstrom)
    Re: Trapping validation errors in XML:Parser <matt.sergeant@ericsson.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 28 Jun 1999 10:24:01 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage930565441.6182@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 10 Sep 1998

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last major update of the Perl FAQ was in Summer of
1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://cpan.perl.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://cpan.perl.org/
    http://www.perl.com/CPAN/
    http://cpan.perl.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.
Another possibility is to use one of the FTP-via-email services; for
more information on doing that, send mail to <mail-server@rtfm.mit.edu>
(not to me!) with these lines in the body of the message, flush left:

    setdir usenet-by-group/news.announce.newusers
    send Anonymous_FTP:_Frequently_Asked_Questions_(FAQ)_List

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Mon, 28 Jun 1999 07:42:27 -0400
From: Eric Anderson <eman@cc.gatech.edu>
Subject: Re: Command line parameters / Wildcard characters / Recursive    directories
Message-Id: <37775FA3.AAE84CFB@cc.gatech.edu>

Alan Curry wrote:

> Work with the system, not against it.

Thanks for the advice. Your method sounds like a much better way of
doing things. I'm in favor of anything that requires less reinvention of
the wheel. Now I have to see if there is some sort of port of the find
utility for windows because unless I am mistaken, I don't believe that
windows has such a program. Again, thanks for the advice.

-- 
Eric Anderson
Computer Science, Georgia Tech
Co-op, Southern Regional Education Board
ICQ# 1279816


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

Date: Mon, 28 Jun 1999 12:37:50 +0200
From: Thomas Weholt <thomas@bibsyst.no>
Subject: Foreach on hash gives undefined value
Message-Id: <3777507E.C327CEA3@bibsyst.no>

Hi,

When the following script is run, it prints out a entry in the
%records_hash that doesn`t exists, and reports "use of unintitialized
value". Why?

#!/usr/bin/perl -w

use MLDBM;
use Fcntl;

tie (%record_hash, "MLDBM", "/tmp/test.db", O_CREAT|O_RDWR, 0666)  or
die "ERROR : $!\n\n";

my $record1 = {
        name => "Thomas",
        age => "24",
        telephone => "93031387",
        emails => [ "thomas\@bibsyst.no", "u970130\@studbo.hit.no",
"weholt\@c2i.net" ]
        };

$record_hash{ $record1->{name} } = $record1;

my $record2 = {
        name => "Vegard",
        age => "30+",
        telephone => "820-lim",
        emails => [ "vegard\@bibsyst.no", "tuben\@karlson.se" ]
        };

$record_hash{ $record2->{name} } = $record2;


my $record3 = {
        name => "Han Roger",
        age => "2?",
        telephone => "820-weinerbrod",
        emails => [ "roger\@bibsyst.no", "sonnavtroms\@c2i.net" ]}

$record_hash{ $record3->{name} } = $record3;

        foreach $person (keys %record_hash)
        {
                my $tmp = $record_hash{$person};
                print
"--------------------------------------------------------\n";
                print "name \t\t: ", $tmp->{name}, "\n";
                print "age \t\t: ", $tmp->{age}, "\n";
                print "telephone \t: ", $tmp->{telephone}, "\n";
                print "emails \t\t: @{$tmp->{emails}} \n";
        }

untie %record_hash;


Thomas Weholt,
Norway



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

Date: 28 Jun 1999 11:52:05 +0200
From: d98-jas@hemul.nada.kth.se (Jon Eslund)
Subject: From Sybase::DBlib to DBI::mysql
Message-Id: <30c9094lkje.fsf@hemul.nada.kth.se>

I want to use a couple of scripts, that use Sybase::DBlib, with DBI
and MySQL.  Here is a sample script.

#!/usr/bin/perl

use Sybase::DBlib;

my $dbh = Sybase::DBlib->dblogin($dbname, $dbpwd, $db);

my $sqlquery = "SELECT * FROM temp_table";
my @resultSet = $dbh->sql($sqlquery);

foreach $row (@resultSet) {
  print "id=$row->[0] value=$row->[1] <br>\n";
}

The script using DBI would look something like this.

#!/usr/bin/perl

use DBI;

my $dbh = DBI->connect($db, $dbname, $dbpwd);

my $sqlquery = "SELECT * FROM temp_table";

my $sth = $dbh->prepare($sqlquery);
$sth->execute;

#How do I get the array of references (@resultSet) from $sth?

foreach $row (@resultSet) {
  print "id=$row->[0] value=$row->[1] <br>\n";
}

I know that the scripts are not complete and will not connect to any
database but that's not the issue. I just want to get that array. :)

In all the mysql documentation and tutorials I've read you have always
extracted one row at the time. I want to get all the rows in one chunk.

And oh, need I have to say that I am a Perl beginner. :)

-- 
___\ Jon Eslund


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

Date: Mon, 28 Jun 1999 10:23:41 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: d98-jas@hemul.nada.kth.se
Subject: Re: From Sybase::DBlib to DBI::mysql
Message-Id: <siiu88bp3m.fsf@cre.canon.co.uk>

Jon Eslund <d98-jas@hemul.nada.kth.se> wrote:
> use DBI;
> my $dbh = DBI->connect($db, $dbname, $dbpwd);
> my $sqlquery = "SELECT * FROM temp_table";
> my $sth = $dbh->prepare($sqlquery);
> $sth->execute;
> 
> How do I get the array of references (@resultSet) from $sth?

>From the DBI manpage:
 
     fetchall_arrayref

         The fetchall_arrayref method can be used to fetch all
         the data to be returned from a prepared and executed
         statement handle. It returns a reference to an array
         which contains one reference per row.  If there are no
         rows to return, fetchall_arrayref returns a reference to
         an empty array [...]

     selectall_arrayref

         This utility method combines the prepare, execute,  and
         fetchall_arrayref entries elsewhere in this document into
         a single call [...]

-- 
Gareth Rees


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

Date: Mon, 28 Jun 1999 09:28:35 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: How to store hashes
Message-Id: <sipv2gbrng.fsf@cre.canon.co.uk>

Timo Hummel <thummel@junior-net.de> wrote:
> I want to store hashes in a file. What's the best way to do this?

One simple way is to use Data::Dumper to write out the data and `do' to
read it back.  For example:
   
    use Data::Dumper;
    use vars '$foo';

    # Create a hash.
    $foo = { one => 1, two => 2, three => 3 };

    # Write it to a file.
    open FOO, ">foo" or die "Can't open foo: $!";
    print FOO Data::Dumper->Dump([$foo], ['foo']);
    close FOO or die "Can't close foo: $!";

    # ...

    # Read it back from the file.
    do 'foo';

This approach has disadvantages compared to a solution using DBM or a
relational database server: it doesn't support random access for read or
update, the whole file must be written each time something is changed,
and it gets slower as the hash gets larger.  But it's very
straightforward.

-- 
Gareth Rees


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

Date: Mon, 28 Jun 1999 16:21:45 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Learning Perl exercises using reverse
Message-Id: <7l8p4a$3uo5@news.cyber.net.pk>

@array = qw/1 2 3 4 5 6/;
print join ',' , reverse @array;




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

Date: Mon, 28 Jun 1999 10:27:57 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Linux better than perl?
Message-Id: <37794e0b.4921096@enews.newsguy.com>

On 28 Jun 1999 02:12:45 GMT, joey@hecnyyvr.com (J.Y.) wrote:

>Linux better than perl?
>-JY

"I think we should build a SQL database".

"What color do you want that database?"

"I think mauve has the most RAM."


Marcel



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

Date: Mon, 28 Jun 1999 11:14:44 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: My script works! PLEASE HELP!!!
Message-Id: <sid7ygbmqj.fsf@cre.canon.co.uk>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> I'm using strings as sets of integers

It's worth checking CPAN to see if anyone has written an appropriate
module for your needs.  It appears to me that the module Bit::Vector
will provide the functionality you need.  See
http://www.cpan.org/modules/by-module/Bit/Bit-Vector-5.7.tar.gz

If your requirements are such that Bit::Vector is inappropriate, try
comp.lang.perl.misc again, with a bit more about what you're trying to
achieve.

-- 
Gareth Rees


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

Date: Mon, 28 Jun 1999 16:28:35 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Perl under Win32--file date.
Message-Id: <7l8ph2$4321@news.cyber.net.pk>

The exact answer would be:

$date = localtime ( ( stat '/autoexec.bat' ) [ 9 ] );

--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift  ICQ: 4265451
FAX: (815) 846-2877

Jeremy <jdsv@hotmailSpAmSuX.com> wrote in message
news:BZBd3.9574$xp4.319496@news.uswest.net...
>     How do I retrieve the date on a file with Perl under Win32?
>
>     -Jeremy





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

Date: Mon, 28 Jun 1999 11:34:48 GMT
From: hamed53@my-deja.com
Subject: please help, changing characters.....
Message-Id: <7l7mko$egp$1@nnrp1.deja.com>

hi
can you please help me on this:
i have this string:
"begin-farsi hello hamed -f-RuAO-f- -f-tAsX-f- end-farsi";
as you can see this string is formated like this:
"begin-farsi" + normal text (hello hamed) + "-f-some text-f-" + "-f-
some text-f-" end-farsi
i might have unlimited number of these "-f-some text-f-".
the -f- tells me to change the characters to what ever i want (or
convert them) in side the to -f-s
for example "-f-RuAO-f-" to "-f-QWRd-f-"
so at the end i want to have some thing like this:
"begin-farsi hello hamed QWRd SDfd end-farsi";
i couldnt explain it better, i hope you get what actually i like to do!
:)
thanks for the help
hamed


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 28 Jun 1999 12:14:18 +0200
From: "Claudio Villa Santa" <claudio@elettrodata.it>
Subject: printf and formate to wirte  number in #.###,##
Message-Id: <7l7hu6$roe$1@ffx2nh5.news.uu.net>

Hi,

I have't understund how i can format a number using printf , I search an
explample but I don't find it.

Some one can send me an example to format a number in following mode:

#.###,##  ( 1.896,45 )  ( in Italy we use point to separate thousand )

Thanks

Greatings

Claudio




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

Date: Mon, 28 Jun 1999 09:13:18 GMT
From: baga@gmx.net (baga@gmx.net)
Subject: reading Outlook NT emails
Message-Id: <37773bba.10535429@news.techfak.uni-kiel.de>

Hello,

I try to convert emails that are send by Outlook (or Outlook Express?)
from a NT system into readable plain text.
Does someone know a Perl script doing that?

Thanks a lot,
  Hans

baga@gmx.net


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

Date: 28 Jun 1999 10:44:32 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: reading Outlook NT emails
Message-Id: <37774400@newsread3.dircon.co.uk>

baga@gmx.net <baga@gmx.net> wrote:
> Hello,
> 
> I try to convert emails that are send by Outlook (or Outlook Express?)
> from a NT system into readable plain text.
> Does someone know a Perl script doing that?
> 

If you look at <http://reference.perl.com/query.cgi?mail> you might find
something will be of use ...

/J\
-- 
"In last week's show Lee Mack suggested that David Copperfield was a
smarmy fucking twat. Well done Lee" - Channel 4 Continuity Announcer


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

Date: Mon, 28 Jun 1999 05:45:56 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Removing spaces from string
Message-Id: <7l7ee7$l37$1@plonk.apk.net>


Abigail wrote in message ...
>By using magical Perl recursion:


    Abigail, you can also use the special Star regex too:

    $klaas  =~ s/\s+/\<*\> /g;

Works wonders on those hard to get spaces!

Jody




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

Date: Mon, 28 Jun 1999 22:19:29 +1200
From: "Aaron Lister" <alister@ihug.co.nz>
Subject: Re: Returning output from a secondary perl script?
Message-Id: <7l7j74$q6d$1@newsource.ihug.co.nz>

How do you generate the output from within the secondary script?
I've used print statements, also the exit method, and even die which is
supposed to be trappable via the eval method...

by the way, this is win32.

Any ideas why I can't get it to work (other than that I am a complete
idiot).

Aaron.








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

Date: Mon, 28 Jun 1999 16:17:58 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Returning output from a secondary perl script?
Message-Id: <7l8ot9$3uo4@news.cyber.net.pk>

Here is a simple example.

Run 1.pl


1.pl
===

$content = `perl 2.pl`;

print 'I received some data from 2.pl which I put in $content, here it is:';
print "\n$content";


2.pl
===

print "This is 2.pl reporting!";


--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
ICQ: 4265451
FAX: (815) 846-2877

Aaron Lister <alister@ihug.co.nz> wrote in message
news:7l7j74$q6d$1@newsource.ihug.co.nz...
> How do you generate the output from within the secondary script?
> I've used print statements, also the exit method, and even die which is
> supposed to be trappable via the eval method...

<snip>




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

Date: Mon, 28 Jun 1999 11:41:46 +0200
From: Anders Johansson <dr_avalanche1959@yahoo.com>
Subject: Server side issues...
Message-Id: <3777435A.18F0B310@yahoo.com>

Is there a book available on
server part, like the Web client
programming - for server?

pointers to urls with the information 
would be appriciated.


/Anders


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

Date: Mon, 28 Jun 1999 09:16:58 +0000
From: GiN <Ch1ckEn@hotmail.com>
Subject: Re: TIMEOUT
Message-Id: <37773D89.EBCF76DF@hotmail.com>

thanks!!!



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

Date: Mon, 28 Jun 1999 06:44:13 -0300
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: Trapping validation errors in XML:Parser
Message-Id: <Arved_37-2806990644130001@dyip-114.chebucto.ns.ca>

In article <7l65kv$vcl$1@nnrp1.deja.com>, pelau@my-deja.com wrote:

> I'm tired of seeing "not well-formed at line ..."
> errors. I'm using the XL::Parser in Stream mode.
> Is there a way to nicely trap those errors and
> just move on to the next tag in the file?
> 
XML::Parser dies on parse errors, so you'd have to go into the module code
if you wanted to change this behaviour.

I'm not sure why you'd want to, though - it's fundamentally simple to
ensure that XML is at least "well-formed", as opposed to being "valid".
Ignoring errors at this level ensures that Expat's context stack etc etc
is all out of whack, your various handlers aren't getting proper input, so
why bother continuing?

I'd be reserving your irritation for whoever is writing the XML markup.
Blaming XML::Parser for croaking on parse errors is like blaming lint for
finding mistakes.

Arved


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

Date: Mon, 28 Jun 1999 11:07:15 +0100
From: Matt Sergeant <matt.sergeant@ericsson.com>
Subject: Re: Trapping validation errors in XML:Parser
Message-Id: <37774952.DDFC9D29@ericsson.com>

pelau@my-deja.com wrote:
> 
> I'm tired of seeing "not well-formed at line ..."
> errors. I'm using the XL::Parser in Stream mode.
> Is there a way to nicely trap those errors and
> just move on to the next tag in the file?

No. There's no way you could possibly recover the file, and an XML
parser isn't required to try and recover it for you.

If you just want to trap the error and do something else, use perl's
exception handling routine eval(). (see "perldoc -f eval")

Matt.


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 6153
**************************************

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