[12567] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6167 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 29 16:07:21 1999

Date: Tue, 29 Jun 99 13:00:21 -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           Tue, 29 Jun 1999     Volume: 8 Number: 6167

Today's topics:
    Re: Apples and Oranges (doug edmunds)
    Re: Apples and Oranges (doug edmunds)
        Associative array of a two dimensional array hollanderm@my-deja.com
    Re: blocking SIGINT and SIGQUIT <gellyfish@gellyfish.com>
    Re: Help with an array test (Marcel Grunauer)
    Re: How to convert a text file to 0-byte lenght? (Matthew Bafford)
    Re: Limits of Berkley DB/DB_File <david@kasey.umkc.edu>
    Re: MIME TYPE <mike@crusaders.no>
        My First Perl error...I'm just learning. av8tor@flash.net
    Re: newbie refs | uninitialised data prob (Anno Siegel)
        Nobody to help? (How to understand DBM types?) (blueman)
    Re: Object persistence -- how to? <david@kasey.umkc.edu>
    Re: Outputting Search results in parts (like yahoo) <rootbeer@redcat.com>
    Re: Pattern matching $1-$n not being pulled <upsetter@ziplink.net>
    Re: Pattern matching $1-$n not being pulled (Marcel Grunauer)
    Re: Pattern matching $1-$n not being pulled <jcreed@cyclone.jprc.com>
        printing to many filehandles simultaneously <l.suheimat@mdx.ac.uk>
    Re: printing to many filehandles simultaneously <tchrist@mox.perl.com>
    Re: Problem with CGI in IE but not Netscape <rootbeer@redcat.com>
        regexp text wrapping question <martin@guest-books.com>
        Robot email/poster for this group (John Stanley)
        sybperl help jessica.qing.wang@bankerstrust.com
    Re: why doesn't this for loop work <dgrisinger@exactis.com>
    Re: why doesn't this for loop work garthwebb@my-deja.com
    Re: Zip Support For Perl <rootbeer@redcat.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 29 Jun 1999 19:55:07 GMT
From: edmundsMUNGED@pacifierMUNGED.com (doug edmunds)
Subject: Re: Apples and Oranges
Message-Id: <37792477.5907138@news.pacifier.com>

On Tue, 29 Jun 1999 03:38:55 GMT, posting.account@lynxview.com
(William Herrera) wrote:

>You are doing the perl equivalent of an invalid pointer access. Don't
>do that :)

I was just trying variations on a theme from Perl Cookbook 
section 11.5  :)




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

Date: Tue, 29 Jun 1999 19:56:02 GMT
From: edmundsMUNGED@pacifierMUNGED.com (doug edmunds)
Subject: Re: Apples and Oranges
Message-Id: <37792205.5281527@news.pacifier.com>

On Tue, 29 Jun 1999 00:58:52 -0400, rjk@linguist.dartmouth.edu (Ronald
J Kimball) wrote:

>Scalar variables whose names are numbers (other than 0) are special
>regex variables, as $1, $2, etc, and are therefore read-only.
>Apparently this read-only protection extends to all scalar variables
>whose names begin with digits other than 0.  Go figure.

I agree. The problem is with the strings ($a) which don't start with 
a digit (other than 0).  If $a is defined, allowing $$a to point
to a different string (without warning) could cause some major
headaches.

The code below first assigns to $$a, then to $a, then (tries) to $$a
again.  Dumper results are identical, up to point of crash.

# --- code starts ------
#! perl -w  
use Data::Dumper;

print "test 1 \n";
undef $a;
$$a = "Two apples";
print "Before assignment to \$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";

$a = "Three thousand apples";
print "After assignment to \$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";

$$a = "Two apples";
print "Reassign to \$\$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";


print "test 2 \n";
undef $a;
$$a = "Two apples";
print "Before assignment to \$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";

$a = "3,000 apples";  #this is why it crashes
print "After assignment to \$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";

#this is where it crashes
$$a = "Two apples";
print "Reassign to \$\$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";
#--- code ends ------



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

Date: Tue, 29 Jun 1999 19:09:01 GMT
From: hollanderm@my-deja.com
Subject: Associative array of a two dimensional array
Message-Id: <7lb5k2$omp$1@nnrp1.deja.com>

I am starting to go beyond my understanding of arrays. . .

I am making an associative array, each value of which contains a 2-D
array.  This is what it looks like

for $temp (@temps) {
	open FILE, "$file";

	splics @ln, 0   # this is to clear the array before I use it 					#
again
	while (<FILE>) {
                    	push @ln, [ split ];
        }

        $line{$temp} =  @ln;
        close FILE;
}
(NOTE :  FILE contains multiple columns of data :
abc	123	234	324
fds	123	321	234
fdk	123	54	34
)

later, I say
@array = $line{$temp}, but perl doesn't seem to recognize @array as a
2-D array.  I don't really understand why.  Any insight would be
wonderful.  Thanks a million.

mike.


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


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

Date: 28 Jun 1999 22:20:30 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: blocking SIGINT and SIGQUIT
Message-Id: <7l8sfe$1f2$1@gellyfish.btinternet.com>

On 28 Jun 1999 21:19:39 GMT jaya wrote:
> so i am wondering if there is a way to wrap the original program in 
> something that will allow me to clear up any temp files created when
> the program sees a SIGINT.
> 
> also please let me know how you discovered the solution so that i can
> figure stuff like this out in the future.
> 

Look for stuff on the %SIG hash in the perlvar manpage ...

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Tue, 29 Jun 1999 19:11:24 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Help with an array test
Message-Id: <377a1a26.3097744@enews.newsguy.com>

On Tue, 29 Jun 1999 12:38:15 -0600, Jeff Beard
<jeffbREMOVETHIS@mcguckin.com> wrote:

>Hi,
>
>I need to test an array to see if all values are null. If they are, do
>one things if not, do another. I've been playing with loops that test if
>each element is null but I need to know if they're all null.
>

Not exactly sure whether this is what you mean, but I took it to mean
"all elements should be 0", not "undef". Anyway, here it goes:

@test = (0, 0, 0, 0);

if (join('',@test) eq '0'x@test) {
	# all elements are 0
}


Marcel



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

Date: Tue, 29 Jun 1999 19:08:34 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: How to convert a text file to 0-byte lenght?
Message-Id: <slrn7ni4nm.i6.*@dragons.duesouth.net>

On Tue, 29 Jun 1999 22:26:11 +0500, Faisal Nasim" <swiftkid@bigfoot.com>
held some poor sysadmin at gunpoint, and typed the following into
comp.lang.perl.misc: 
: But look, I shortened my sig

Good!

: --

It's '-- ', though.

Hope This Helps,

: Faisal Nasim

--Matthew


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

Date: Tue, 29 Jun 1999 19:23:48 +0000
From: "David L. Nicol" <david@kasey.umkc.edu>
To: swiftkid@bigfoot.com
Subject: Re: Limits of Berkley DB/DB_File
Message-Id: <37791D44.D5912B21@kasey.umkc.edu>

Faisal Nasim wrote:
 
> $db { 'yourname' } = "Cool Kid";
> $db { 'yourname' } = "Whiz Kid";
> 
> That is possible! (read the man page)

Hmmm -- you need to use the provided API to iterate
through.

	   # iterate through the btree using seq
           # and print each key/value pair.
           $key = $value = 0 ;
           for ($status = $x->seq($key, $value, R_FIRST) ;
                $status == 0 ;
                $status = $x->seq($key, $value, R_NEXT) )
             {  print "$key -> $value\n" }

I wonder if each(%) provides multiply keyed entries
correctly; and how btree sorts duplicate entries, neither
of which are addressed in `perldoc DB_File`




____________________________________________
  David Nicol 816.235.1187 UMKC Network Operations david@news.umkc.edu
                 "multiple valid approaches exist"


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

Date: Tue, 29 Jun 1999 21:50:53 +0200
From: "Trond Michelsen" <mike@crusaders.no>
Subject: Re: MIME TYPE
Message-Id: <zu9e3.529$U%.4173@news1.online.no>


Martin Quensel <martin@adoma.se> wrote in message
news:3778B33E.FDF73AAE@adoma.se...
> > Anyone has any idea what this header " Content-Type: text/html\n\n<pre>"
has
> > in difference with  "Content-Type: text/html\n\n" ??
> the header is "Content-Type: text/html" followed by 2 newlines

Well, acually, "Content-type: text/html\n" is just one of the lines in the
HTTP-header. The HTTP-header and body (HTML document, image, or whatever)
are separated by an empty line.  However, unless you're programming
nph-scripts you usually won't have to care about the other header-lines.

> and what is your perl question??

Right. This is of course a CGI matter.

--
Trond Michelsen




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

Date: Tue, 29 Jun 1999 19:26:47 GMT
From: av8tor@flash.net
Subject: My First Perl error...I'm just learning.
Message-Id: <7lb6l7$p66$1@nnrp1.deja.com>

I'm just starting to learn perl and CGI.
I'm getting the following error when trying to call my program from
Netscape:
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Script execution error

Unable to execute script due to a configuration problem.
Please notify the webmaster of this error.

exec() returned: 2: No such file or directory
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

this is my cgi code I uploaded

#!/bin/perl
print ("It Works!\n");


Simple..  I've also contacted my webhost company and they told me the
location of perl is  /bin/perl and they told me I was setup to use CGI.
Other than that they are NO help (www.icom.com)  I've changed the file
permissions so all three groups have excute privilages.

Here's how I'm trying to excute the cgi:
www.licensed4fun.com/cgi-bin/test.cgi

Thanks
George
www.licensed4fun.com


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


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

Date: 29 Jun 1999 19:00:36 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: newbie refs | uninitialised data prob
Message-Id: <7lb54k$bue$1@lublin.zrz.tu-berlin.de>

Rory Campbell Lange <'x'campbell-lange@easynet.co.uk> wrote in comp.lang.perl.misc:
>I am a newbie, playing about with references and referencing
>
>I've written the following code to encode a bit of data
>(the bit below __END__) by taking the position of each letter
>in the text to be incoded in the alphabet, and adding this to
>the position of a letter in the codeword. Letters from 1 to n
>are taken from the codeword in a cycle until the encoding text
>is used up.
>
>1)  I'd like some comments on my attempts please.
>    I realise that it would be more useful to deal with caps,etc -
>    I've chopped the code down for posting
>    References $ar and $na are unnecessary - I was just
>    trying out the idea of referencing.
>   
>2) I get an unexplained uninitialised value readout:
>   
>   This one is ok:
>      What code word do you want to use?
>      No spaces, digits or caps allowed
>      rory #<- codeword
>   
>      dvdumw dl sptl
>      sfplqgeeh qgwu ldf
>
>   This one isn't
>      What code word do you want to use?
>      No spaces, digits or caps allowed
>      sam #<- codeword
>   
>      xqpvaf hg uqru
>----># Use of uninitialized value, <DATA> chunk 2.
>      File 'newgroup question'; Line 36
>      mabmepij refo gpg
>      
>I'm at a loss as to why the print @out doesn't work
>I get to a point in the cycle where the codenumber +
>the encoding number produces an uninitialised result
>any help would be useful!
>
>Regards
>Rory
>
>
>
>   !#perl-w                                       #: 1
>   @alphas = ("a".."z");                          #: 2
>   $num = 0;                                      #: 3
>   foreach $a (@alphas) {                         #: 4
>     $alphanum{$a} = ++$num;                      #: 5 make alpha
>     $numalpha{$num} = $a;                        #: 6 and number
>   }                                              #: 7 hashes for
>                                                  #: 8 encoding
>   $ar = {%alphanum};                             #: 9
>   $na = {%numalpha};                             #:10

You are unnecessarily copying %alphanum and %numalpha.  If
you want a reference (though I don't quite see why) just
use \%alphanum and \%numalpha.

>                                                  #:11
>   while ($input !~ /^[a-z]+$/) {                 #:12 get 
>   print "\n\nWhat code word do you want to use?  #:13 codeword
>   No spaces, digits or caps allowed\n";          #:14
>   $input = <STDIN>;                              #:15
>   chomp $input;                                  #:16
>   }                                              #:17
>   $code = [split //, $input];                    #:18
>   $code_last = scalar @$code;                    #:19 get number
>   $codenum = 0;                                  #:20 of letters
>                                                  #:21 in codeword
>   while (<DATA>) {$all .= $_;}                   #:22
>   $text_to_encode = [split //, $all];            #:23 get text
>   foreach $enc (@$text_to_encode) {              #:24 to encode
>       $enc =~ tr/[A-Z]/[a-z]/;                   #:25
>                                                  #:26
>       if ($enc =~ /[a-z]/i) {                    #:27
>       $codenum = $codenum % $code_last;          #:28 all the 
>        $enc = $na->{($ar->{$enc}                 #:29 encoding done
>       + $ar->{$code->[$codenum]}) % 26};         #:30 here!
>       ++$codenum;                                #:31
>                                                  #:32
>     }                                            #:33
>   }                                              #:34
>   @out = reverse (@$text_to_encode);             #:35 try and 
>   print @out;                                    #:36 print out
>                                                  #:37
>   __END__                                        #:38
>   Not very important                             #:39
>   text to encode                                 #:40

Without looking too deeply into the code, I notice you never assign
anything to key 0 in %numalpha.  Yet you calculate a subscript into
(a reference to a copy of) that hash via ... % 26.  This is bound
to come out zero one day, and my guess is that's what perl is
kvetching about.

Anno


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

Date: Tue, 29 Jun 1999 19:18:27 GMT
From: blueman@?.? (blueman)
Subject: Nobody to help? (How to understand DBM types?)
Message-Id: <37791a63.26515189@news.supernews.co.uk>

Hi All,

Second try;

I have a set of dbm files created with perl 5. The problem is,
they are created on a SUN machine and I have no chance to
contact the admin. or to connect the machine itself. The question:
How can I understand which dbm is used (Berkeley, NDBM, etc.)
for those files, using perl (I need the info, because when I try to
open them on my Windows machine, operation failed. Why? Because
I try to open them using SDBM, which seems not to be their type.)

TIA.

blueman
bpg



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

Date: Tue, 29 Jun 1999 19:13:34 +0000
From: "David L. Nicol" <david@kasey.umkc.edu>
To: stevel@coastside.net
Subject: Re: Object persistence -- how to?
Message-Id: <37791ADE.E71E3133@kasey.umkc.edu>

Steve Leibel wrote:
 
> if I define a class and then create an instance of that
> class, can I store the instance on disc for later retrieval?

Choose a persistence method, like giving all your objects
some kind of unique tag based on their class and a primary key
and storing your object in a berkeley db after a serializing
step that can handle all the data you are expecting to find
in the objects, ever.

Then make all your persistent objects subclasses of the
persistent class.

I wrote one that serializes to flat files, holds arrays
as well as scalars in its hash-OO key-value pairs, and
does per-record locking (with c<flock> since each object
maps to a unique file)

It wasn't that hard.  You can too.



________________________________________________________________________
  David Nicol 816.235.1187 UMKC Network Operations david@news.umkc.edu
                  "working solutions variously occur"


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

Date: Tue, 29 Jun 1999 12:09:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Outputting Search results in parts (like yahoo)
Message-Id: <Pine.GSO.4.02A.9906291208380.4425-100000@user2.teleport.com>

On Mon, 28 Jun 1999, Shaddy International Ltd. wrote:

> I'm looking for a way to display the results of a search in a web
> browser like yahoo and other search pages do e.g matchs 1-20 then
> matchs 21-40.

> Is this possible in perl

Yes. In fact, Randal did just this sort of thing in one of his Web
Techniques columns.

   http://www.stonehenge.com/merlyn/WebTechniques/

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



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

Date: Tue, 29 Jun 1999 19:33:02 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: Pattern matching $1-$n not being pulled
Message-Id: <Ob9e3.253$6M6.86757@news.shore.net>

e_broyles2@my-deja.com wrote:
: $myvar = "134:00:34:56";

: if ($myvar =~ /(.*?):(.*?):(.*?):(.*?)/) {

[snip]

: 134
: 00
: 34

The last (.*?) is matching "nothing" because you have the ? in there to
indicate non-greediness. Since * matches "zero or more", the least greedy
way to match is to match zero characters.

Now, how to fix this. Depending on what kind of data you're expecting to
have input to this regex, it may make more sense to replace (.*?) with
something a little more specific, perhaps (.+?), if you know there's
always going to be at least one character between colons. Or, you may want
to say "Match anything that's not a colon" by using ([^:]+). Or, you may
only want to deal with numerals, in which case you would say (\d+).

You could also anchor the pattern to the end of your string by putting a $
as the last character of the regex. As you can see, there are
significantly more than one way to do it, depending on your needs and your
data.

Hope this helps!

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Tue, 29 Jun 1999 19:06:37 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: Pattern matching $1-$n not being pulled
Message-Id: <377918ef.2786787@enews.newsguy.com>

On Tue, 29 Jun 1999 18:41:27 GMT, e_broyles2@my-deja.com wrote:

>Can someone tell me why when I do this:
>
>$myvar = "134:00:34:56";
>
>if ($myvar =~ /(.*?):(.*?):(.*?):(.*?)/) {
>     print "$1\n";
>     print "$2\n";
>     print "$3\n";
>     print "$4\n";
>}
>
>I get the following output:
>
>134
>00
>34
>
>
>Instead of
>
>134
>00
>34
>56
>

Because all the quantifiers are non-greedy, so (.*?) tries to match
the least number (including zero) of any character, which is exactly
what it does. It matches zero occurrences of any characters, which, as
far as regexes are concerned, is a match for (.*?)


Marcel



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

Date: 29 Jun 1999 15:44:30 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: Pattern matching $1-$n not being pulled
Message-Id: <a17lomg5b5.fsf@cyclone.jprc.com>

e_broyles2@my-deja.com writes:

> Can someone tell me why when I do this:
> $myvar = "134:00:34:56";
> if ($myvar =~ /(.*?):(.*?):(.*?):(.*?)/) {
>      print "$1\n";
>      print "$2\n";
>      print "$3\n";
>      print "$4\n";
> }
> I get the following output:
> 134
> 00
> 34
The fourth (.*?) matches zero characters after the last colon in myvar.
Perhaps you want to do something like
split /:/, $myvar
instead?

---Jason 


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

Date: Tue, 29 Jun 1999 19:26:01 +0100
From: "Laith Suheimat" <l.suheimat@mdx.ac.uk>
Subject: printing to many filehandles simultaneously
Message-Id: <7lb56o$d1l$1@aquila.mdx.ac.uk>

Hello,

Is there any way of printing to more than one filehandle?

I am using Activestate Perl 5.005_03 on NT 4 wkstn sp4, and would really
like to print to screen (cmd prompt in NT) and to a logfile simultaneously.

At the moment I either redirect STDOUT to the logfile (thus losing any cmd
line output), or I have two print commands, one to logfile, and one to
screen.

Maybe I need to do a fork?

Thanks in advance,

Laith Suheimat
l.suheimat@mdx.ac.uk





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

Date: 29 Jun 1999 13:51:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: printing to many filehandles simultaneously
Message-Id: <377923c0@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, "Laith Suheimat" <l.suheimat@mdx.ac.uk> writes:
:Is there any way of printing to more than one filehandle?

Of course.

    print FH1 "stuff\n";
    print FH2 "stuff\n";

or even 

    for $fh (*FH1, *FH2) {
	print $fh "stuff\n";
    } 

:I am using Activestate Perl 5.005_03 on NT 4 wkstn sp4, 

*shudder*

:and would really
:like to print to screen (cmd prompt in NT) and to a logfile simultaneously.

"Simultaneous" is difficult in a uniprocessor computer, or even in 
an Einsteinian universe.

:At the moment I either redirect STDOUT to the logfile (thus losing any cmd
:line output), or I have two print commands, one to logfile, and one to
:screen.

The perlfaq5 manpage includes the question "How do I print to more than
one file at once?"  It's on your system, so I imagine that you'll've
already read it before posting your question.  What part of that it
was unclear?

:Maybe I need to do a fork?

No, that's not what fork is for.

If you retrieve the source code from the Ram Book, you'll find that
this is covered at least three different ways.

--tom
-- 
"You're one of those condescending Unix computer users!"
"Here's a nickel, kid.  Get yourself a better computer" - Dilbert.


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

Date: Tue, 29 Jun 1999 12:53:14 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Problem with CGI in IE but not Netscape
Message-Id: <Pine.GSO.4.02A.9906291251250.4425-100000@user2.teleport.com>

On Mon, 28 Jun 1999, Matthew Norris wrote:

> The correct HTML will be outputted in Netscape, but nothing was
> outputted in IE.

If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.

Do you already know how to use a search engine like Yahoo to find the
protocol spec and the newsgroups about it?

Hope this helps!

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



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

Date: Tue, 29 Jun 1999 20:25:17 +0100
From: "Martin" <martin@guest-books.com>
Subject: regexp text wrapping question
Message-Id: <7lb6fn$r5i$1@gxsn.com>

Hi!

I've been trying to split $foo into elements of @foo with each element
being upto 53 characters long but I want $foo to be split at word
boundaries only (unless there is a word with more than 53 characters).
I've tried

@foo = ();
while($foo) {
  $foo =~ s/^(.{0,53})\b? *//s;
  push(@foo,$1);
}

although this doesn't seem to work (I am also collating and discarding
any whitespace at the end of the 53 characters hence the ' *' after the
\b?

Martin




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

Date: 29 Jun 1999 19:21:41 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Robot email/poster for this group
Message-Id: <7lb6c5$a0$1@news.NERO.NET>

If you do not read comp.lang.perl.moderated, you might not have learned
that the gurus there are contemplating the creation of a robot for this
group. I haven't seen them discuss it here, though.
you.

Not like the robot that sends the FAQ to each new poster, the proposed
robot would read your articles and try to figure out what question you
were asking. Then it would mail you the "correct" FAQ, and possibly
post a message to the newsgroup saying it had mailed you the FAQ. 

So, if you come to the group after reading the FAQ and have a question,
you may very well get a nice email telling you to read the FAQ, and a
posting here that says that the answer is in the FAQ you were mailed. If
you don't ask it in terms that the robot has programmed into it, you may
get a FAQ that is irrelevant to the question. If you are simply
expressing an opinion, you may get mailed a FAQ with the answer to your
opinion.

There have even been proposed a way to post questions to the robot,
which has been given the cute name "miscy". "Miscy -- what is the URL
for X?"

I think this is a fine idea -- for a special group devoted to robot
operation. It is great for a mail agent. For a discussion group, this
is a bad idea. Discussion groups do not need a robot jumping in with
email and postings. Test newsgroups where robots respond to each
article are one thing. Comp.lang.perl.misc is not a test newsgroup.
This newsgroup is noisy enough with the distribution of FAQs and man
pages on a regular basis, it does not need more noise from a robot.

I lost count of the number of people who complained that this newsgroup
was becoming a "help desk", and who voted for a moderated group so they
could get away from the problem. Now they want to turn this group into a
help desk ("Miscy -- help me...") after they have created a different
group for themselves. They wanted to leave, and now they want to program
the solution for us after they are gone.



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

Date: Tue, 29 Jun 1999 19:15:07 GMT
From: jessica.qing.wang@bankerstrust.com
Subject: sybperl help
Message-Id: <7lb5vf$orf$1@nnrp1.deja.com>

hi all,
I am new to Sybperl. And this is my first program.

#!/nw/dist/prod/perl -w

use Sybase::DBlib;
use FileHandle;
use English;
use strict;

use vars qw(@dat $ae_id $ae_code $ae_name);

open(DB, ">db.txt") || die "cannot create file";
print DB "ae_id, ae_code, ae_name";

$dbh = new Sybase::DBlib("jeswang", "jeswang", "GRNWCH_SRV_2", 0);
$dbh->dbuse("its_hilary");
$dbh->dbcmd("select * from hts_ae_codes");
$dbh->dbsqlexec;
print "connected...";

while($dbh->dbresults != NO_MORE_RESULTS)
{
  while (@dat = $dbh->dbnextrow)
  {
    ($ae_id, $ae_code, $ae_name) = @dat;
    print DB "$ae_id, $ae_code, $ae_name\n";
  }
}

close DB;
$dbh_dbclose;

But I got compiling error as following:
Global symbol "$dbh" requires explicit package name at test.pl line13.
Global symbol $dbh_dbclose" requires explicit package name at test.pl
line 29. (test.pl is the file name).

Any help would be greatly appreciated.
Jessica


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


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

Date: 29 Jun 1999 13:19:10 -0600
From: Daniel Grisinger <dgrisinger@exactis.com>
Subject: Re: why doesn't this for loop work
Message-Id: <m3d7yerf0x.fsf@dhcp70.corp.merc.com>

mike cardeiro <mikecard@my-deja.com> writes:

> 	for ($y = 0, $y <= $num_players, ++$y) {
                   ^                   ^
>       for ($a = 0, $a <= 2, ++$a) {
                   ^        ^
Those commas should be semicolons.  As it is, in both instances
you are looping over a list of 3 `1's.

dgris
-- 
Daniel Grisinger                  dgrisinger@exactis.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Tue, 29 Jun 1999 19:31:19 GMT
From: garthwebb@my-deja.com
Subject: Re: why doesn't this for loop work
Message-Id: <7lb6u8$p9n$1@nnrp1.deja.com>

In article <7laui3$lep$1@nnrp1.deja.com>,
  mike cardeiro <mikecard@my-deja.com> wrote:
<snip>
> #!/usr/bin/perl -w

The '-w' flag is good, but you should probably 'use strict' as well.

> 	require "pitchsub.cgi";

It seems odd that you are requiring a cgi script.  If this is a module
or library you should probably avoid confusion and rename this to
'pitchsub.pm', and if it really is a cgi script you should probably
rethink your approach.

> 		$num_players = 2; # 3 players
> 		$card_place = 0;
>
> 	for ($y = 0, $y <= $num_players, ++$y) {

Your syntax for the 'for' loop is incorrect;  replace the commas with
semi-colons and read the 'perlsyn' manpage.  Right now this 'for' loop
says "Execute this loop three times, once for each item in the list ($y
= 0, $y <= $num_players, ++$y)."  Notice that if you change $num_players
to 5, this loop still executes only 3 times.  Also you take the time to
use this form of the 'for' loop and then never use the variable you
increment.  If you really want the $y variable for something else, save
yourself some typing and use:

for $y (0..$num_players) {

or if you don't need $y:

for (0..$num_players) {

> 		for (0..2) {
> 			push @p_hand, $deck[$card_place];
> 			++$card_place;
> 		}
> 			for ($a = 0, $a <= 2, ++$a) {

Same comment as above for the other 'for' loop.  This can be rewritten
as:

for $a (0..2) {

> 				print $card_place + $a, "\n";
> 			}
> 	}

Good luck,
Garth


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


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

Date: Tue, 29 Jun 1999 12:47:13 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Zip Support For Perl
Message-Id: <Pine.GSO.4.02A.9906291246580.4425-100000@user2.teleport.com>

On Mon, 28 Jun 1999, Stephen Pandich wrote:

> Is anyone aware of support for PKZip type ".zip" files?

If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-)  Hope this helps!

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

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



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

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

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