[19354] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1549 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 17 09:05:43 2001

Date: Fri, 17 Aug 2001 06:05:11 -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: <998053511-v10-i1549@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 17 Aug 2001     Volume: 10 Number: 1549

Today's topics:
    Re: capitalisation/DBD/mysql <paul@net366.com>
    Re: capitalisation/DBD/mysql <peb@bms.umist.ac.uk>
    Re: capitalisation/DBD/mysql <ilya@martynov.org>
    Re: capitalisation/DBD/mysql <paul@net366.com>
    Re: capitalisation/DBD/mysql <bart.lateur@skynet.be>
    Re: capitalisation/DBD/mysql <paul@net366.com>
    Re: Determining array length <tinamue@zedat.fu-berlin.de>
    Re: Determining array length <Tassilo.Parseval@post.rwth-aachen.de>
        FAQ: How do I close a file descriptor by number? <faq@denver.pm.org>
    Re: Help!  Multiple line extract from file based on use (Anno Siegel)
    Re: Help!  Multiple line extract from file based on use <bart.lateur@skynet.be>
    Re: Locating Files <Koen@invalidmiddle-earth.be>
    Re: need opinions (Yves Orton)
    Re: Need Perl module or regexp to slurp specific XML re (Yves Orton)
        OT active perl and dos <spamfree@sorted2000.net>
    Re: OT active perl and dos (Tassilo v. Parseval)
    Re: OT active perl and dos <bart.lateur@skynet.be>
    Re: OT: Why is there so much white space in perl docume (Helgi Briem)
        perl packages & ASP <ted_godwin@mindspring.com>
    Re: Processing a scalar in the same way of a filehandle (Rafael Garcia-Suarez)
        Search string how <nospam@nospam.nl>
    Re: Simple Problem <Graham.T.Wood@oracle.com>
    Re: Simple Problem <dscarlett@optushome.com.au>
    Re: Simple Problem <peb@bms.umist.ac.uk>
    Re: test post (Anno Siegel)
    Re: what does this message mean? <samneric@tigerriverOMIT-THIS.com>
    Re: what does this message mean? <Tassilo.Parseval@post.rwth-aachen.de>
    Re: what does this message mean? <samneric@tigerriverOMIT-THIS.com>
    Re: what does this message mean? <bart.lateur@skynet.be>
    Re: why does this code print - HASH(0x80f764c) <Graham.T.Wood@oracle.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 17 Aug 2001 11:32:40 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: capitalisation/DBD/mysql
Message-Id: <998044286.14210.0.nnrp-13.d4f094e4@news.demon.co.uk>

I gave up, and trashed the whole installation of Perl, resinatlled it, and
it is OK.

Sadly, Windows and LINUX are different. I have failed to DBI->connect under
the LINUX, but I can't get access to STDERR I think. I can only output to a
browser.

After connect fails, in Windows, I can say

    if (DBI::errstr) {print DBI::errstr . "\n<BR>";}

so I can see the error, because after a connect fails $dbh->errstr is empty
because there is no $dbh handle.

In LINUX, I can say

    print $dbh->errstr . "\n<BR>";

which is NULL, but if I say

    print DBI::errstr . "\n<BR>";

I get 500 Internal Server Error which usually means I have a PERL script
error of a major nature.

Any stunning ideas what I can do? I imagine my MySQL DB has a password, user
or hostname I don't know, or something, and I want to find out what! I have
read the manual./ My brain hurts. I have the most respect for you guys who
actually UNDERSTAND this stuff!

Paul




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

Date: Fri, 17 Aug 2001 11:41:03 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: capitalisation/DBD/mysql
Message-Id: <3B7CF4BF.85E8308B@bms.umist.ac.uk>

Paul Fortescue wrote:
> 
> Old thread was getting confusing ...
> 
> On Windows 2000, ActivePerl, IIS
> I have installed, using PPM
> 
>     DBD
>     DBI::mysql
> 
> which appear to have worked.
> 
> I write in .pl
> 
>     use CGI;
> 
> now either
> 
>     DBI->install_driver('mysql'); OR
>     DBI->connect(DBI:mysql:database=d;hostname=localhost);
> 
> produce
> 
>     'Perhaps the capitalisation of DBD 'mysql' isn't right. at sql.pl line
> 18'

looks to me like your connect line is wrong.

Shouldn't it be something like :-

DBI->connect('DBI:mysql:d:localhost')

Paul


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

Date: 17 Aug 2001 14:39:45 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: capitalisation/DBD/mysql
Message-Id: <877kw3hswe.fsf@abra.ru>


PF> Old thread was getting confusing ...
PF> On Windows 2000, ActivePerl, IIS
PF> I have installed, using PPM

PF>     DBD
PF>     DBI::mysql

PF> which appear to have worked.

PF> I write in .pl

PF>     use CGI;

PF> now either

PF> DBI-> install_driver('mysql'); OR
PF> DBI-> connect(DBI:mysql:database=d;hostname=localhost);

It should be 

DBI-> connect('dbi:mysql:database=d;hostname=localhost');


-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Fri, 17 Aug 2001 11:47:22 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: capitalisation/DBD/mysql
Message-Id: <998045166.14523.0.nnrp-13.d4f094e4@news.demon.co.uk>

All of those dsn's work under windows, ie

DBI-> connect('dbi:mysql:database=d;hostname=localhost');


DBI->connect('DBI:mysql:d:localhost')

but not under Linux, and the script seems to 'stop' after that line, ie if I
put print "HERE<BR>\n"; it doesn't.




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

Date: Fri, 17 Aug 2001 12:38:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: capitalisation/DBD/mysql
Message-Id: <pj3qntktg6tmult4kiphcsnu9atemavaeb@4ax.com>

Paul Fortescue wrote:

>DBI-> connect('dbi:mysql:database=d;hostname=localhost');
>
>
>DBI->connect('DBI:mysql:d:localhost')
>
>but not under Linux, and the script seems to 'stop' after that line, ie if I
>put print "HERE<BR>\n"; it doesn't.

So what's in DBI::errstr? Or better still: as a fourth parameter, use an
anonymous hash with the entry for "RaiseError" as true (1).

	$dbh = DBI-> connect('dbi:mysql:database=d;hostname=localhost',
	   '', '', { RaiseError => 1 });

And you'd better bug the DBI-users mailing list. That's where the people
hang out, who are interested in this kind of problems.

	<http://lists.perl.org/showlist.cgi?name=dbi-users>

It's quite a noisy list, expect, ooh, fifteen to thirty posts a day, and
most people not snipping much in their replies.

And what were you saying about a browser? Are you running this as CGI?
Then the result of STDERR is in the server's error log. Can't you test
through the shell, or even telnet? You can always do

	BEGIN {
	      open STDERR, ">&STDOUT";
	}

or the module CGI::Carp might help, too.

-- 
	Bart.


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

Date: Fri, 17 Aug 2001 13:48:37 +0100
From: "Paul Fortescue" <paul@net366.com>
Subject: Re: capitalisation/DBD/mysql
Message-Id: <998052443.17200.0.nnrp-13.d4f094e4@news.demon.co.uk>

> So what's in DBI::errstr? Or better still: as a fourth parameter, use an
> anonymous hash with the entry for "RaiseError" as true (1).
>
> $dbh = DBI-> connect('dbi:mysql:database=d;hostname=localhost',
>    '', '', { RaiseError => 1 });
>
> And you'd better bug the DBI-users mailing list. That's where the people
> hang out, who are interested in this kind of problems.
>
> <http://lists.perl.org/showlist.cgi?name=dbi-users>
>
> It's quite a noisy list, expect, ooh, fifteen to thirty posts a day, and
> most people not snipping much in their replies.
>
> And what were you saying about a browser? Are you running this as CGI?
> Then the result of STDERR is in the server's error log. Can't you test
> through the shell, or even telnet? You can always do
>
> BEGIN {
>       open STDERR, ">&STDOUT";
> }
>
> or the module CGI::Carp might help, too.
>
> --
> Bart.

The  RaiseError was the answer, thanks. It all works now. I'll go off and
bug dbi-users.Thanks agian, all.




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

Date: 17 Aug 2001 10:55:26 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: Determining array length
Message-Id: <9lit6u$9k5lb$2@fu-berlin.de>

Tassilo v. Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
> On Fri, 17 Aug 2001 00:27:27 -0700, G Harper <admin@CLIPMEnova1.f2s.com> wrote:
> map { $_."<br>" } @mine; # append <br> to each array-element

uh?

probably you mean either
  @a = map { $_."<br>" } @a;
or
  map { $_.="<br>" } @a;
or simply
  $_.="<br>" for @a;

regards,
tina

-- 
http://www.tinita.de \  enter__| |__the___ _ _ ___
tina's moviedatabase  \     / _` / _ \/ _ \ '_(_-< of
search & add comments  \    \ _,_\ __/\ __/_| /__/ perception
---   Warning: content of homepage hopelessly out-dated   ---


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

Date: Fri, 17 Aug 2001 13:03:14 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Determining array length
Message-Id: <3B7CF9F2.9000201@post.rwth-aachen.de>

Tina Mueller wrote:
> Tassilo v. Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
> 
>>On Fri, 17 Aug 2001 00:27:27 -0700, G Harper <admin@CLIPMEnova1.f2s.com> wrote:
>>map { $_."<br>" } @mine; # append <br> to each array-element
>>
> 
> uh?
> 
> probably you mean either
>   @a = map { $_."<br>" } @a;

I indeed meant it. I had already typed it, reckognized there was a small 
typo in it and while correcting that killed the left side. :-/




-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Fri, 17 Aug 2001 12:17:07 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I close a file descriptor by number?
Message-Id: <7X7f7.191$V3.190622720@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  How do I close a file descriptor by number?

    This should rarely be necessary, as the Perl close() function is to be
    used for things that Perl opened itself, even if it was a dup of a
    numeric descriptor as with MHCONTEXT above. But if you really have to,
    you may be able to do this:

        require 'sys/syscall.ph';
        $rc = syscall(&SYS_close, $fd + 0);  # must force numeric
        die "can't sysclose $fd: $!" unless $rc == -1;

    Or, just use the fdopen(3S) feature of open():

        { 
            local *F; 
            open F, "<&=$fd" or die "Cannot reopen fd=$fd: $!";
            close F;
        }

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to

    news:news.answers

or to the many thousands of other useful Usenet news groups.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.

                                                           05.30
-- 
    This space intentionally left blank


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

Date: 17 Aug 2001 11:12:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help!  Multiple line extract from file based on user input.
Message-Id: <9liu6s$sm5$2@mamenchi.zrz.TU-Berlin.DE>

According to Lyle <lbeckm3@hotmail.com>:
> I am trying to write a perl script that will extract the given lines
> from a file based on a list the user types in, i.e.
> 
> Records to print: 2,15,34-60,87
> 
> Is it possible to do this without iterating through the file multiple
> times for each number or range?  I could see doing this in a sorted
> array but my brain can't get past the "how do I handle the ranges"
> such as the 34-60 listed above?  Also the order that the operator
> selects must remain the same, i.e. if the operator puts
> 
> ..print:  3,7,4,26
> 
> The file must be in that order in the end.  TIA!!

Here is a solution that avoids both slurping the file and string eval:

    my $s = '2,15,18-22,34-40,87';
    
    # build a list of pairs for each range.  The above becomes
    # [ [2,2], [15,15], [18,22], ...]
    
    my @ranges = map [ ( @$_, @$_)[ 0, 1]], map [ split /-/ ], split /,/, $s;
    
    # now build a lol of lines.  the i-th sublist corresponds to the
    # i-th range in @ranges.

    my @coll;
    while ( my $line = <DATA> ) {
        for ( 0 .. $#ranges ) {
            push @{ $coll[ $_]}, $line if
                $ranges[ $_]->[ 0] <= $. and $. <= $ranges[ $_]->[ 1];
        }
    }
    
    print @$_, "\n" for @coll;

    __DATA__
    (etc.)

Anno



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

Date: Fri, 17 Aug 2001 12:26:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Help!  Multiple line extract from file based on user input.
Message-Id: <023qntknh8sioqlt1svstn4qlj2e9hkkc8@4ax.com>

Craig Berry wrote:

>(my $selStr = shift) =~ s/(\d+)-(\d+)/join ',', $1 .. $2/eg;

I really like that one.

I do worry a bit in that the user supplied range selection string isn't
tested for syntax.

>print( ('dummy', <>)[split /,/, $selStr] );

But this slurps in the whole file. I would populate a hash, and include
the record if $. is in the hash.

	my %include; @include{/\d+/g} = ();
	while(<>) {
	     print if exists $include{$.}
	}

-- 
	Bart.


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

Date: Fri, 17 Aug 2001 12:25:51 GMT
From: Koen Verbeke <Koen@invalidmiddle-earth.be>
Subject: Re: Locating Files
Message-Id: <Pine.LNX.4.33.0108171428400.1936-100000@anfalas>

On Fri, 17 Aug 2001 at 8:06am, Tassilo von Parseval wrote concerning Re:...:

> Koen Verbeke wrote:
>
> > It looks like they're using Debian/GNU Linux. If they are, they probably
> > upgraded their system-perl to 5.6.0. That's not a good idea with Debian as
> > it depends on its own perl (/etc/alternatives). It is wise to leave it
> > alone. The system will be broken for a great part when not taken care of
> > this.
>
> This is, sorry, utterly nonsense. I am using Debian and I am certainly
> using Perl 5.6.1 without having compiled it myself. Perl 5.6.1 is in the
>   testing-distribution and I'd advise anyone to let Debian know which
> Perl is installed by using the provided .deb package.

I wasn't talking about woody. I was talking about potato.
And, because I've talked someone through this over the phone, I surely
recommend installing a second perl. Otherwise you get into upgrading more
than just perl.



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

Date: 17 Aug 2001 03:21:44 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: need opinions
Message-Id: <74f348f7.0108170221.e260067@posting.google.com>

derelixir@my-deja.com (derelixir) wrote in message news:<fd50a1dc.0108162211.327b5414@posting.google.com>...
> Hello...
> 
> I have a text file which contains something like this:
> 
> 500,California,87,88,90
> 501,Sepang,88,88,83
> 
> 500 & 501 are id and unique
> 
> I want to read this text file and duplicate the locations based on the
> id ...
> e.g.

And the code went where?  Post the code and we'll try to help.  No
code and all we can do is make assumptions from you spec.  And your
spec isnt really a spec, but a description.

> if it finds id 500, it will extract the location name, write it other
> file
> (newlocations.txt) and at the same time duplicate it but with the
> different location name...
> 
> basically the output will be something like this:

basically? So the output _doesnt_ look like this?

> California,87,88,90
> Hollywood,87,88,90
> (same data but with different location name)
> 
> I'm not sure of a better and less complicated way of doing it..
> One thing is maybe by using hash of array...
> 
> e.g.
> %locations = (
>             '500' => ["California", "Hollywood",  "Oklahoma"],
>             '501' => ["London", "Leeds" ],
>             '502' => ["Washington", "New York" ],
>             
> );
> 
> I'm thinking about long term on how to maintain it...
> because I might be adding more locations to the list 

A database might be a good idea.

Also you could write it to disk using Data::Dumper or any of a number
of similer tools, and then read it back.  But the database has more
options.

> e.g. 
>             '500' => ["California", "Hollywood",  "Oklahoma",
> "Connecticut",  "Philadelphia"],
> 
> in future...
> Maybe there are easier ways of doing it besides having to use this
> hash of array?

Well, you could turn the hash around:

$VAR = {
        'California'   => 500,
        'Hollywood'    => 500,
        'Leeds'        => 501,
        'London'       => 501,
        'New York'     => 502,
        'Oklahoma'     => 500,
        'Washington'   => 502
       };

But it wont be as efficient in terms of space.

> Any opinions are really appreciated....

Well, all of this is a guess as you dont give code, and dont say what
the uses are etc...

More info please.

Yves


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

Date: 17 Aug 2001 03:06:09 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Need Perl module or regexp to slurp specific XML records
Message-Id: <74f348f7.0108170206.59b87f53@posting.google.com>

SNIP

> RECAP: Given the following fixed XML records format:
> 
> <record id="012-8">
>   <name>John Doe</name>
>   <address>123 Main St.</address>
>   <city>Lake Elsinore</city>
>   <state>CA</state>
>   <phone>(123) 456-7890</phone>
>   <zip>12345</zip>
>   <email>jd@domain.com</email>
> </record>
> 
> objective: slurp into hash only records where, for example, <state> = NY
SNIP
> Taking all advice into consideration, as well as advice from Google search
> on Perl extraction techniques, could I do something like this?

As other have said already ths approach takes the data structure for
granted.  This means that if it changes, even slightly, then use a
propper parse.

OTOH If its unlikely to change then youll need to correct a few bugs.

Read up on context.

SNIP
> where: $user_parameter = 'NY';

Uhm, not a good idea to mix comments and code in posts... 
In future probably the above should be written:

my $user_parameter='NY'; 

But for maintainance pupose maybe you should do something like

my $match_cond=qr/<state>\s*NY\s*<\/state>/;

That way it is VERY clear what you are using for your match... 
I suppose there are other ways, but thats up to you.

> 
> local ($/) = '</record>';
> local @ARGV = 'filename.xml';

This line is just for testing purposes right? (local @argv)
Also I believe you have muddled the list concept up a bit:

local $/='</record>'; #scalar assignment
local @ARGV=qw(filename.xml); #see perlop for qw() #list assignment

> 
> foreach (grep(/<state>\s*$user_parameter\s*<\/state>/i, <>))

Hmm, if your file is very large and there are many records that will
match then using a for might cause you problems.  I would stick with 
a while personally...

while (<>) {
      next unless /$match_cond/io; # see perlre for the o modifier
      
> {
>   $id = m/\bid\s*=\s*"(.*?)"/i;  # should have mentioned id not just numeric

Hmm. :-) Yes. You should have.  The lizard is going to complain now..

But really the above line wont do... (minor really :-)
Once again the issue is list context. (You really should read up on
this idea.
It is crucial to Perl and is not seen in many other languages so you
need to grok
it properly. :( Cant remember where to look though. Could be perlsyn)

(my $id) = m/\bid\s*=\s*"(.*?)"/i;

>   $records{$id}{'id'} = $id;
>   $records{$id}{'state'} = $user_parameter;
>   $records{$id}{'name'} = m/<name>\s*(.*?)\s*<\/name>/i;
>   $records{$id}{'address'} = m/<address>\s*(.*?)\s*<\/address>/i;

And once again the list context is the problem...

   ($records{$id}{'name'}) = m/<name>\s*(.*?)\s*<\/name>/i;
   ($records{$id}{'address'}) = m/<address>\s*(.*?)\s*<\/address>/i;


>    ...
>   $states{$user_parameter}[$i++] = $id;  # need to store ids for each state
> }

And that should work fine.

Yves


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

Date: Fri, 17 Aug 2001 10:50:14 GMT
From: "spamfree" <spamfree@sorted2000.net>
Subject: OT active perl and dos
Message-Id: <GF6f7.428$EV3.100011@news1.cableinet.net>

Hi,
Sorry for being off topic but cannot get a reply in alt.msdos and other
groups after nearly 2 weeks!
Trying to debug a large perl script running active perl for windows Dos
Version 4.10.2222

Is it possible to print the output to a text file via dos?
The output scroll's and the /P and /W switches only work for dir listings.
No access to logs on remote server.

Thanks for any help

--
millside
_____________





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

Date: 17 Aug 2001 12:39:58 GMT
From: Tassilo.Parseval@post.rwth-aachen.de (Tassilo v. Parseval)
Subject: Re: OT active perl and dos
Message-Id: <9lj3au$l4o$1@nets3.rz.RWTH-Aachen.DE>

On Fri, 17 Aug 2001 10:50:14 GMT, spamfree <spamfree@sorted2000.net> wrote:
> Hi,
> Sorry for being off topic but cannot get a reply in alt.msdos and other
> groups after nearly 2 weeks!
> Trying to debug a large perl script running active perl for windows Dos
> Version 4.10.2222
> 
> Is it possible to print the output to a text file via dos?

Yes, of course:
script.pl > output.txt

> The output scroll's and the /P and /W switches only work for dir listings.

For that, you should use 'more':
script.pl | more

Tassilo
-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Fri, 17 Aug 2001 12:40:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: OT active perl and dos
Message-Id: <g74qnt8omd3aaonvfg2g91thapntplhn28@4ax.com>

spamfree wrote:

>Is it possible to print the output to a text file via dos?
>The output scroll's and the /P and /W switches only work for dir listings.

	perl yourscript.pl args... | more

	perl yourscript.pl args... >outfile.txt

-- 
	Bart.


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

Date: Fri, 17 Aug 2001 11:02:57 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: OT: Why is there so much white space in perl documentation??
Message-Id: <3b7cf748.2168596296@news.isholf.is>

On Thu, 16 Aug 2001 21:44:05 GMT, Carlos C. Gonzalez
<miscellaneousemail@yahoo.com> wrote:

>In article <slrn9no5uf.5sq.tadmc@tadmc26.august.net>, Tad McClellan at 
>tadmc@augustmail.com says...
>
>> Unix was designed for programmers.
>> 
>> Windows was designed for consumers.
>> 
>
>Good points Tad.  I agree.  
>
>> Not at all surprising that it easier to program on Unix,
>> it was designed to be easy to program. (because it was
>> programmers doing the designing, and they were designing
>> "for themselves")
>
>Windows sucks as far as a good programming platform.  I have to reboot my 
>computer (was Windows 95, now Windows 98) a minimum of 3 or 4 times a day 
>because of this or that memory violation or who knows what.  I used to 
>have to reboot double that before I got a memory booster.  Programs 
>freeze up, I get blue screens of death.  You name it.  Admittedly I am 
>stretching Windows by doing all I do on it but still.  I am constantly 
>having to pre-empt Windows and figure out how I am going to make sure 
>everything is saved, etc. in case Windows crashes again.  Knowing that 
>Windows WILL crash again is always in the back of my mind.   
>
>I tried Linux once and after installing it about 30 times and then trying 
>to work in it I realized that my productivity would crawl to an almost 
>full stop for a while I learned how to use it. Something I couldn't 
>afford at the time. 

Get Windows NT or Windows 2000.  I agree that 95/98/Me
are crap and will crash regularly, but I have never crashed
my Win2K system in more than a year and my NT4 system
very seldom (and that was due to network errors).  

I program in Perl on Windows, Solaris and Linux 
interchangeably with no problems.

As for your documentation problem. I use perldoc
all the time on Windows.  I don't see the problem.
I do use cmd.exe.  I'm not sure if Win9* have that.
I also use the Perl CD Bookshelf, an absolute godsend.

Regards,
Helgi Briem


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

Date: Fri, 17 Aug 2001 08:48:10 -0400
From: "TedWeb" <ted_godwin@mindspring.com>
Subject: perl packages & ASP
Message-Id: <9lj3tp$19j$1@slb2.atl.mindspring.net>

Hello everyone,

My perl packages don't have access to ASP intrinsic objects (i.e. Session,
Server, etc.). They are implemented through means of server side includes.
Is there anyway I can correct this, or do I have to send the intrinsic
objects through the specified routine argument list?

Many thanks,
Ted




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

Date: 17 Aug 2001 12:48:25 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Processing a scalar in the same way of a filehandle
Message-Id: <slrn9nq4v1.ibc.rgarciasuarez@rafael.kazibao.net>

Miguel Manso wrote in comp.lang.perl.misc:
} Hi there.
} 
} I've a scalar with a bunch of text. I'd like to process it on the
} "paragraph" way. It I has a filehandle, I would do this:
} 
} $/ = "";
} while(<FH>) {
}   my $p = $_;
} }
} 
} perl is wonderful :)
} 
} Now, I've $cnt and I'd like to be able to do the same thing. Is it possible?
} I've tried some things but none worked :(

Here's a way : split yourself your variable with a regexp that matches
paragraphs.

Example :

#!/usr/local/bin/perl
# Text with paragraphs P1...P4
$x = "P1\nP1\nP1\n\n\nP2\nP2\n\nP3\n\nP4\nP4\nP4\n";
@y = $x =~ /(.+(?:\n.+)*	# matches paragraphs
		(?:\n\n+|\n*\Z) # matches paragraph boundary or end-of-file
	    )/gx;
print "<$_>\n" for @y;
__END__

See perlre for details about the regular expression.

Also note that in future versions of Perl you should be able to read
from a scalar as if it were a file.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
# needs perl 5.7.1
open $fh,'<',\"Just another Perl hacker,\n";print while <$fh>;close $fh;


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

Date: Fri, 17 Aug 2001 14:51:58 +0200
From: Albert <nospam@nospam.nl>
Subject: Search string how
Message-Id: <3j4qntkqptl000mp9drpt830mdi6u30o5d@4ax.com>

Hello,

I need to search a string for values between 1 and 7.
If  a value exists I have to add a certain value to another value.
The value searched for  can look like "123457" it has to be search for
each value, thus for 1 for 2, for 3 etc.

How do I do this in perl?

Greetings,

Albert


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

Date: Fri, 17 Aug 2001 12:04:01 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: Simple Problem
Message-Id: <3B7CFA20.580DCF3A@oracle.com>

This is a multi-part message in MIME format.
--------------FB8AE85DB074AADDEB9EE76E
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Smiley wrote:

> I'm having trouble with a simple find and replace.  I must be tired or
> something because I can't figure out what the problem is.  This is the
> line:
>
> $form[$key] =~ s/\'//gi;
>
> It doesn't seem to want to get rid of the single quotes though.  Can
> anybody tell me what's wrong here?
>
> Thanks.

What else is happening?  Can you give us some input and output?

Graham Wood

--------------FB8AE85DB074AADDEB9EE76E
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard

--------------FB8AE85DB074AADDEB9EE76E--



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

Date: Fri, 17 Aug 2001 12:27:23 GMT
From: "David Scarlett" <dscarlett@optushome.com.au>
Subject: Re: Simple Problem
Message-Id: <L48f7.20008$A5.60001@news1.eburwd1.vic.optushome.com.au>

"Smiley" <gurm@intrasof.com> wrote in message
news:3b7ccee6.225130079@news1.on.sympatico.ca...
> I'm having trouble with a simple find and replace.  I must be tired or
> something because I can't figure out what the problem is.  This is the
> line:
>
> $form[$key] =~ s/\'//gi;
>
> It doesn't seem to want to get rid of the single quotes though.  Can
> anybody tell me what's wrong here?
>

Well, seeing how you use the name "$key", is form meant to be a hash? If so,
it should be:

$form{$key} =~ s/\'//gi;


--
David Scarlett
dscarlett@optushome.com.au
http://www.listen.to/artifice/
http://members.optushome.com.au/dscarlett/

"Damn it, Kif, where's the little umbrella? That's what makes it a scotch on
the rocks!"
        -Capt. Zapp Brannigann, Futurama






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

Date: Fri, 17 Aug 2001 14:04:29 +0100
From: Paul Boardman <peb@bms.umist.ac.uk>
Subject: Re: Simple Problem
Message-Id: <3B7D165D.813F6EBA@bms.umist.ac.uk>

Graham Wood wrote:
> 
> Smiley wrote:
> 
> > I'm having trouble with a simple find and replace.  I must be tired or
> > something because I can't figure out what the problem is.  This is the
> > line:
> >
> > $form[$key] =~ s/\'//gi;
> >
> > It doesn't seem to want to get rid of the single quotes though.  Can
> > anybody tell me what's wrong here?

> What else is happening?  Can you give us some input and output?

I agree with Graham.  Show us some error messages & a bit more of your
code & we might be able to help.

The following would be faster for your purposes

$form[$key] =~ tr/'//d;

Paul

p.s. comp.lang.perl no longer exists.


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

Date: 17 Aug 2001 11:48:54 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: test post
Message-Id: <9lj0b6$sm5$3@mamenchi.zrz.TU-Berlin.DE>

[posted and mailed]

According to John P <john@availcheck.com>:
> sorry but another test post.

Use test groups for test posts.

Anno


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

Date: Fri, 17 Aug 2001 08:07:18 -0400
From: Samneric <samneric@tigerriverOMIT-THIS.com>
Subject: Re: what does this message mean?
Message-Id: <MPG.15e6d305d3ff718d989685@news.usit.net>

meow wrote:
> yeah, i did run the makefile and install the module at my own_dir...
> in my script i did specified a perl seach path:
> 
> use lib "/path/to/my/install/module/directory/own_dir";
> 
> what's wrong in this?

Perhaps that your path is a "this" instead of a "these"?

The module docs say:
use lib LIST

Not:
use lib SCALAR

Try "use lib qw( SCALAR );" - supplying a LIST
instead of "use lib SCALAR;" - NOT supplying a LIST


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

Date: Fri, 17 Aug 2001 14:17:41 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: what does this message mean?
Message-Id: <3B7D0B65.3000507@post.rwth-aachen.de>

Samneric wrote:
> meow wrote:
> 
>>yeah, i did run the makefile and install the module at my own_dir...
>>in my script i did specified a perl seach path:
>>
>>use lib "/path/to/my/install/module/directory/own_dir";
>>
>>what's wrong in this?
>>
> 
> Perhaps that your path is a "this" instead of a "these"?
 >
 > The module docs say:
 > use lib LIST
 >
 > Not:
 > use lib SCALAR

But this can't be the reason. According to the docs, print() also takes 
a LIST as argument, yet 'print $a' works splendidly.

And I am very positive that I often write:

use lib "..";

with no obvious misfunction.


Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Fri, 17 Aug 2001 08:47:23 -0400
From: Samneric <samneric@tigerriverOMIT-THIS.com>
Subject: Re: what does this message mean?
Message-Id: <MPG.15e6dc49449effc7989686@news.usit.net>

Tassilo von Parseval wrote:
> Samneric wrote:
> > The module docs say: use lib LIST
> > Not: use lib SCALAR
> 
> But this can't be the reason. According to the docs, print() also takes 
> a LIST as argument, yet 'print $a' works splendidly.
> 
> And I am very positive that I often write:
> 
> use lib "..";
> with no obvious misfunction.

Sheeesh! I need more coffee...

Guess I should have read more closely the error that meow reported, which shows 
that perl found IO::Tty.pm (so lib isn't the problem):

> Can't locate loadable object for module IO::Tty in @INC
> (@INC contains: /$path1 /$path2 $path3  .)
> at /$path1/Tty.pm line 26

IO::Tty.pm uses these modules:
use IO::Handle;
use IO::File;

Maybe they aren't installed?...

Version 0.04 on CPAN has "do {" on line 26.

I'll take that to mean: "make another pot of coffee"...


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

Date: Fri, 17 Aug 2001 12:57:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: what does this message mean?
Message-Id: <v65qntkth17rms0godrd7cnfolo8dsqkqa@4ax.com>

meow wrote:

>yeah, i did run the makefile and install the module at my own_dir...
>in my script i did specified a perl seach path:
>
>use lib "/path/to/my/install/module/directory/own_dir";
>
>what's wrong in this?

It looks fine. Can you do a file search in that directory, and see if
the files are indeed there? Perhaps you accidently installed them at
another location. It's not hard at all to goof this up. Quite the
contrary.

-- 
	Bart.


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

Date: Fri, 17 Aug 2001 11:42:31 +0100
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: why does this code print - HASH(0x80f764c)
Message-Id: <3B7CF516.5AC9FA2B@oracle.com>

This is a multi-part message in MIME format.
--------------7574FA7E5ED9231EF3756DB6
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit



TuNNe|ing wrote:

> Why does this code.
> http://www.gimptroll.com/sorty.txt
>
> [begin code]
> #!/usr/bin/perl -w
>
> use CGI;
> use CGI qw/:standard :html3/;
> use CGI::Carp "fatalsToBrowser";
> use strict;
>
> my @row;
>
> push(@row,td ([("A","B","C","D")])); #push the header back on
>
> my @goods =  table({-style=>'font-size:
> 10pt'},{-border=>1,-width=>'90%'},
>             Tr(\@row)
>            );
>
> print "Content-type: text/html\n\n";
> print @goods;
> exit;
> [end code]
>
> print this:
> http://www.gimptroll.com/cgi-bin/sorty.cgi
>
> [result]
> HASH(0x80f764c)  A B C D
> [end result]
>
> I see if I take out the _{-style=>'font-size: 10pt'}_ it does not
> print the address, but then my fonts are not formated.
>
> Regards,
> Jason A. LeBlanc
> http://www.gimptroll.com

The Hash(blah) thing is printed when you print a reference to a hash
rather than dereferencing it and printing the value.  I'm guessing that
because your code works when you remove the first hash reference , the
table function is only expecting one hash reference containing your
style settings followed by Tr and an array reference for the data.  If
this is true, you might be able to make it work by combining your -style
=> 'fontsize: 10pt' with the other two. That is:

# 1 hash ref followed by Tr and 1 array ref
my @goods =  table({-style=>'font-size:10pt',
    -border=>1,-width=>'90%'}, Tr(\@row));

rather than

# 2 hash refs followed by Tr and 1 array ref
my @goods =  table({-style=>'font-size:
10pt'},{-border=>1,-width=>'90%'},
            Tr(\@row)
           );

Hope this helps.  NB This is a guess and I haven't tested it.

Graham Wood

--------------7574FA7E5ED9231EF3756DB6
Content-Type: text/x-vcard; charset=UTF-8;
 name="Graham.T.Wood.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Graham Wood
Content-Disposition: attachment;
 filename="Graham.T.Wood.vcf"

begin:vcard 
n:;Graham
x-mozilla-html:FALSE
adr:;;;;;;
version:2.1
email;internet:Graham.T.Wood@oracle.com
fn:Graham Wood
end:vcard

--------------7574FA7E5ED9231EF3756DB6--



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

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


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