[12727] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 137 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 14 03:07:21 1999

Date: Wed, 14 Jul 1999 00: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)

Perl-Users Digest           Wed, 14 Jul 1999     Volume: 9 Number: 137

Today's topics:
        $ENV(VAR) problem! thiensyh@my-deja.com
    Re: $ENV(VAR) problem! (Abigail)
    Re: ** Working With Strings (Yoda)
    Re: < 1 Second Timing (Abigail)
        [Q] Can sendmail be used for attachments? <Cyanide320@NOSPAM.hotmail.com>
    Re: Calculations (Larry Rosler)
    Re: Calculations (Abigail)
    Re: Calculations (Abigail)
        changing passwds <farber@admin.f-tech.net>
    Re: checking Perl offline (Abigail)
    Re: decimal to binary <tchrist@mox.perl.com>
    Re: deleting files <swiftkid@bigfoot.com>
    Re: FTP Question <rick.delaney@home.com>
    Re: FTP Question (Michael Rubenstein)
    Re: FTP Question <rick.delaney@home.com>
    Re: how do i convert a integer to string. (Abigail)
    Re: How do I include a hash is a regular expression? (Abigail)
        I want to do something interesting with ranges (Steve Simmons)
    Re: I want to do something interesting with ranges (Anno Siegel)
        Ima::DBI - Possible major interface change! <stupid@pobox.com>
        MySQL with perl <johnyick@hongkong.com>
        pattern matching with variables <ida@fcmc.com>
    Re: pattern matching with variables (elephant)
    Re: perl -e 'print "${\ord(s)}\n";' (Abigail)
        Perl CGI:  streaming HTML output from a called program. <geoz@oz.net>
        Problem with generate the return html for browser clien thiensyh@my-deja.com
        Problem with generate the return html for browser clien thiensyh@my-deja.com
        Problem with generate the return html for browser clien thiensyh@my-deja.com
    Re: Professional programmers seeking opportunities on-l (Ronald J Kimball)
    Re: Searching files (Anno Siegel)
    Re: single instance log file (Ronald J Kimball)
        Taking a Microsoft Word upload and converting it to tex rancorr@hotmail.com
    Re: Uninitialized Value in Hash?? <rick.delaney@home.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Jul 1999 06:07:37 GMT
From: thiensyh@my-deja.com
Subject: $ENV(VAR) problem!
Message-Id: <7mh9f4$95b$1@nnrp1.deja.com>

I'm facing a problem on my perl program , when i
compile the program it gave me the following error
message:
Use of uninitialized value at sales.pl line 29.
Use of uninitialized value at sales.pl line 32.
Debug/Unknown method?

Here is my code which the problem happened. Please
help!
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
    $buffer = $ENV{'QUERY_STRING'};
}
elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
}
else {
    print ("Debug\/Unknown method?\n\n");
    $ENV{'QUERY_STRING'} =
'cardno=4012888888881881&mm=12&yy=99&amt=123.12&in
vnum=199910310000001&merchantID=000001111111111';
    $buffer = $ENV{'QUERY_STRING'};



with many thanks,
Gabriel.


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


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

Date: 14 Jul 1999 02:03:16 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: $ENV(VAR) problem!
Message-Id: <slrn7oodgn.h7.abigail@alexandra.delanet.com>

thiensyh@my-deja.com (thiensyh@my-deja.com) wrote on MMCXLIII September
MCMXCIII in <URL:news:7mh9f4$95b$1@nnrp1.deja.com>:
## I'm facing a problem on my perl program , when i
## compile the program it gave me the following error
## message:
## Use of uninitialized value at sales.pl line 29.
## Use of uninitialized value at sales.pl line 32.

At *compile* time? Via 'use' perhaps?

## Debug/Unknown method?
## 
## Here is my code which the problem happened. Please
## help!

[ Line numbers added by Abigail ]

##  1  if ($ENV{'REQUEST_METHOD'} eq 'GET') {
##  2      $buffer = $ENV{'QUERY_STRING'};
##  3  }
##  4  elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
##  5      read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
##  6  }
##  7  else {
##  8      print ("Debug\/Unknown method?\n\n");
##  9      $ENV{'QUERY_STRING'} =
## 10  'cardno=4012888888881881&mm=12&yy=99&amt=123.12&in
## 11  vnum=199910310000001&merchantID=000001111111111';
## 12      $buffer = $ENV{'QUERY_STRING'};
## 


That's very strange. Your 12 line program gets uninitialized variables
on lines 29 and 32!

What can we say. It's probably solar flares. It should pass in a year
of 3.



Abigail
-- 
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Tue, 13 Jul 1999 22:46:49 -0500
From: rlb@intrinsix.ca (Yoda)
Subject: Re: ** Working With Strings
Message-Id: <B3B1725996681841F4@204.112.166.88>

In article <MPG.11f510c4a29b3bbc989cb8@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:

>Things like this are tipping me further to the Abigail side of The 
>Force.

Sense much ego in you, I do. 

Ego leads to intolerance, intolerance leads to hostility, hostility leads
to the Abigail side of the Force.

The Abigail side of the Force leads to unfortunate wardrobe decisions.

Yoda




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

Date: 14 Jul 1999 01:42:33 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: < 1 Second Timing
Message-Id: <slrn7ooc9t.h7.abigail@alexandra.delanet.com>

wired2000@my-deja.com (wired2000@my-deja.com) wrote on MMCXLII September
MCMXCIII in <URL:news:7mgcll$vrh$1@nnrp1.deja.com>:
&& 
&& The main problem I see is that many of the operations are under 1
&& second which has caused problems before since I can't use time in epoch
&& seconds before and after since this will round to the nearest second.
&& If possible, down to milliseconds would be nice but at least to 1
&& decimal place of a second is required. Any ideas on how to track this?


FAQ.


Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 14 Jul 1999 00:37:00 -0400
From: "Jessie Hernandez" <Cyanide320@NOSPAM.hotmail.com>
Subject: [Q] Can sendmail be used for attachments?
Message-Id: <nwUi3.7969$qw.43487@news2.mia>

  I know how to send an e-mail without an attachment with sendmail(easy!),
but how can I send an attachment? Specifically, a page of mine has an input
of type "file". So I'm actually going to ask two questions:

How can i get the file handle of the file that the user entered in an HTML
form?

How can I send an e-mail with this file attachment?

  Any help will be greatly appreciated!

--
Jessie
"With great power comes great responsibility"




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

Date: Tue, 13 Jul 1999 22:09:42 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Calculations
Message-Id: <MPG.11f5bb732b72533e989cc5@nntp.hpl.hp.com>

In article <S%Si3.115$xg5.8364@nsw.nnrp.telstra.net> on Wed, 14 Jul 1999 
02:56:50 GMT, Martien Verbruggen <mgjv@comdyn.com.au> says...
 ...
> $_ = <<EO_SUM;
> 123456
> ++++++
> 234567
> ======
> ??????
> EO_SUM
> s*\s+**gs&&s=\++=+=s&&s-\=+--s&&s!\?+!!s;
                          ^
One character too many there.  For shame!

> print eval, "\n";
> 
> There may be easier ways of doing it, but I have never found one.

Stripping whitespace seems unnecessary somehow.  This produces a better 
golf score by far (and should be much faster, too):

  y=+==s&&y-=?--d;

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 14 Jul 1999 01:29:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Calculations
Message-Id: <slrn7oobhe.h7.abigail@alexandra.delanet.com>

Susan C. Sayce (susan@anthony1.force9.co.uk) wrote on MMCXLII September
MCMXCIII in <URL:news:HoMi3.2652$34.2848@wards>:
^^ Hi,
^^     How do you get perl to add 2 numbers together??

That's rather complicated, as Perl lacks any numerical operators.
Perl is totally geared towards string operations, and noone ever
thought adding numbers would be useful.

I've ran into this problem myself, and I've written a module to
help me out. Feel free to use this whenever you want:


package Math::Add;

use vars qw /@ISA @EXPORT @EXPORT_OK/;

use Exporter;

@ISA       = qw /Exporter/;
@EXPORT    = qw //;
@EXPORT_OK = qw /add/;

my $table = [
   [[0,0], [1,0], [2,0], [3,0], [4,0], [5,0], [6,0], [7,0], [8,0], [9,0]],
   [[1,0], [2,0], [3,0], [4,0], [5,0], [6,0], [7,0], [8,0], [9,0], [0,1]],
   [[2,0], [3,0], [4,0], [5,0], [6,0], [7,0], [8,0], [9,0], [0,1], [1,1]],
   [[3,0], [4,0], [5,0], [6,0], [7,0], [8,0], [9,0], [0,1], [1,1], [2,1]],
   [[4,0], [5,0], [6,0], [7,0], [8,0], [9,0], [0,1], [1,1], [2,1], [3,1]],
   [[5,0], [6,0], [7,0], [8,0], [9,0], [0,1], [1,1], [2,1], [3,1], [4,1]],
   [[6,0], [7,0], [8,0], [9,0], [0,1], [1,1], [2,1], [3,1], [4,1], [5,1]],
   [[7,0], [8,0], [9,0], [0,1], [1,1], [2,1], [3,1], [4,1], [5,1], [6,1]],
   [[8,0], [9,0], [0,1], [1,1], [2,1], [3,1], [4,1], [5,1], [6,1], [7,1]],
   [[9,0], [0,1], [1,1], [2,1], [3,1], [4,1], [5,1], [6,1], [7,1], [8,1]],
];


sub add ($$) {
    my ($number1, $number2) = @_;

    local $_  = "";
    my $carry =  0;

    while (length ($number1) || length ($number2) || $carry) {
        my $thingy1   = chop ($number1) || 0;
        my $thingy2   = chop ($number2) || 0;
        my ($s1, $c1) = @{$table -> [$thingy1] [$thingy2]};
        my ($s2, $c2) = @{$table -> [$s1] [$carry]};
       ($carry)       = @{$table -> [$c1] [$c2]};
        s/$/$s2/;
    }

    scalar reverse $_;
}

__END__


^^ Also is there a function to test to see if a string is numeric such as the
^^ "isnumeric(string)" in VB




That's explained in the FAQ.



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 14 Jul 1999 01:30:21 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Calculations
Message-Id: <slrn7oobj1.h7.abigail@alexandra.delanet.com>

Larry Rosler (lr@hpl.hp.com) wrote on MMCXLII September MCMXCIII in
<URL:news:MPG.11f545969d821ed7989cbe@nntp.hpl.hp.com>:
\\ 
\\ How's my Abigail imitation?


Orange nailpolish? I would never wear that.



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 14 Jul 1999 00:10:47 -0400
From: Paul Farber <farber@admin.f-tech.net>
Subject: changing passwds
Message-Id: <Pine.LNX.4.04.9907140007050.1497-100000@admin.f-tech.net>

hello all

Is there a mod or system call I can make to change the value on the
crypt()ed password in the passwd/shadow file?

There seems to be a jillion was to get it (non-interactively) but the only
way I can think of *changing* a users password is to do a search for the
user then replace the crypt()ed old passwd with a new one.

Just wondering if anyone has a module or snipet they could post.

Thanks all.

Paul D. Farber II
Farber Technology
Ph. 570-628-5303
Fax 570-628-5545
farber@admin.f-tech.net



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

Date: 14 Jul 1999 01:47:01 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: checking Perl offline
Message-Id: <slrn7ooci8.h7.abigail@alexandra.delanet.com>

Dale Henderson (dhenders@cpsgroup.com) wrote on MMCXLII September
MCMXCIII in <URL:news:87k8s4gr0m.fsf@camel.cpsgroup.com>:
|| 
||      heh. One of my pet peeves (sp?) is email me at
||      http://www.foobar.com.  Somehow I don't think apache is very good
||      at recieving email.


That's why www.foobar.com doesn't run Apache. ;-)


Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 13 Jul 1999 23:49:10 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: decimal to binary
Message-Id: <378c24d6@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Carter Hamilton <carter@computer.org> writes:
:Is there an easy way to convert an integer value to its binary
:equivalent?

If you're using one of the supernewest perls:

    printf "%b\n", 23;
10111

    $n = sprintf "%b\n", 23;
    print $n
10111

--tom
-- 
"I think there's a world market for about 5 computers."
	- Thomas J. Watson, Chairman of the Board, IBM (around 1948)


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

Date: Wed, 14 Jul 1999 10:43:29 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: deleting files
Message-Id: <7mibbe$2a06@news.cyber.net.pk>

: I would like to write a perl script that deletes text files in a
directory.
: The filenames are numbers (like 996134274.txt) and only those which are
less
: than a certain number (say 997000000.txt) should be deleted.
:
: My problem is that I can't figure out a way to compare my filename with
the
: number.
:
: How can I store the filename in a temporary variable (so I am able to
: compare it)? Also, how can I check each text file in the directory (so
that
: I can delete all necessary files)?

map { m:(.*)/(.+)\.txt:; unlink if $2 < 997000000 } </blah/yourdir/*.txt>;

#untested




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

Date: Wed, 14 Jul 1999 03:08:41 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: FTP Question
Message-Id: <378BFF08.39DD91AD@home.com>

[posted & mailed]

mike wrote:
> 
> I am certain this may be a frequently asked question if so my
> apoligises.

I am certain it may rain tomorrow.  :-)  If you are certain then why not
search for it?
 
> I would like to connect to an FTP server and get a dozen or so files. I
> only need to get files not put any files. Is there a simple way to do
> this.

Sure there's an LWP::Simple way to do it.  Here's what a simple

    grep FAQ perlfaq*pod

gave me:

perlfaq.pod:=item * Perl on the Net: FTP and WWW Access
perlfaq.pod:=item * How do I fetch/put an FTP file?
perlfaq2.pod:=head2 Perl on the Net: FTP and WWW Access
perlfaq8.pod:Try the Net::FTP, TCP::Client, and Net::Telnet modules
(available from
perlfaq9.pod:=head2 How do I fetch/put an FTP file?
perlfaq9.pod:LWP::Simple (available from CPAN) can fetch but not put. 
Net::FTP (also

If you're not familiar with pod, the ones starting with =head2 are the
actual FAQs.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Wed, 14 Jul 1999 03:31:30 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: FTP Question
Message-Id: <379203ec.142596923@nntp.ix.netcom.com>

On Wed, 14 Jul 1999 03:08:41 GMT, Rick Delaney
<rick.delaney@home.com> wrote:

>Sure there's an LWP::Simple way to do it.  Here's what a simple
>
>    grep FAQ perlfaq*pod
>
>gave me:
>
>perlfaq.pod:=item * Perl on the Net: FTP and WWW Access
>perlfaq.pod:=item * How do I fetch/put an FTP file?
>perlfaq2.pod:=head2 Perl on the Net: FTP and WWW Access
>perlfaq8.pod:Try the Net::FTP, TCP::Client, and Net::Telnet modules
>(available from
>perlfaq9.pod:=head2 How do I fetch/put an FTP file?
>perlfaq9.pod:LWP::Simple (available from CPAN) can fetch but not put. 
>Net::FTP (also

I am extremely impressed by your version of grep?  Where did you
get it? :-)
-- 
Michael M Rubenstein


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

Date: Wed, 14 Jul 1999 03:57:33 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: FTP Question
Message-Id: <378C0A6F.E0134849@home.com>

[posted & mailed]

Michael Rubenstein wrote:
> 
> On Wed, 14 Jul 1999 03:08:41 GMT, Rick Delaney
> <rick.delaney@home.com> wrote:
> 
> >    grep FAQ perlfaq*pod
> >
> >gave me:
> >
> >perlfaq.pod:=item * Perl on the Net: FTP and WWW Access
etc.
 
> I am extremely impressed by your version of grep?  Where did you
> get it? :-)

I made it myself!  But don't be too impressed--it only finds one thing.

$ cat grep
#!/bin/sh
shift
/usr/bin/grep FTP $*

-- 
Rick Delaney
rick.delaney@home.com


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

Date: 14 Jul 1999 01:33:12 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: how do i convert a integer to string.
Message-Id: <slrn7ooboc.h7.abigail@alexandra.delanet.com>

cramey@my-deja.com (cramey@my-deja.com) wrote on MMCXLII September
MCMXCIII in <URL:news:7mg4kg$scg$1@nnrp1.deja.com>:
// i want to convert an integer
// 
// specifically
// 
// 1111111 to a string with
// 
// str[0] == 1
// .
// .
// .
// str[6] == 1
// 
// is there an easy way to do this ?


@str = (1) x 7;   # After all you did specify '1111111'.



Abigail
-- 
tie $" => A; $, = " "; $\ = "\n"; @a = ("") x 2; print map {"@a"} 1 .. 4;
sub A::TIESCALAR {bless \my $A => A} #  Yet Another silly JAPH by Abigail
sub A::FETCH     {@q = qw /Just Another Perl Hacker/ unless @q; shift @q}


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 14 Jul 1999 01:52:35 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How do I include a hash is a regular expression?
Message-Id: <slrn7oocsn.h7.abigail@alexandra.delanet.com>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMCXLII September
MCMXCIII in <URL:news:7mgdvf$dg0$1@lublin.zrz.tu-berlin.de>:
== Abigail <abigail@delanet.com> wrote in comp.lang.perl.misc:
== 
== >Someone emailed me that this works:
== >
== >    m/(\S+)\s(?p{$job{$1}})/
== 
== Would that someone have said which version supports the (?p...)
== sequence?


The current version of Perl. 5.005, now in maintenance release 5.005_03.




Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 14 Jul 1999 03:33:07 GMT
From: scs@ans.net (Steve Simmons)
Subject: I want to do something interesting with ranges
Message-Id: <TxTi3.1$lf5.36@news.aa.ans.net>

Tried something which (IMHO) should have worked, but didn't:

	@section = (<STDIN>)[ 4 .. /^MARKER\n$/ ] ;

In short, I wanted to grab lines 4 thru the line which contains
"^MARKER\n$" into @section.  This sort of thing works in list contexts
for ranges of incrementable items, eg:

	@section = (<STDIN>)[ 4 .. 10 ] ;

and for mixed-type ranges in scalar contexts:

	while (<>) {
		push @section, $_ if ( 4 .. /$MARKER\n$/ ) ;
	}

OK, I can see reasons why it wouldn't work . . . but IMHO it ought to.
When perl sees a non-scalar in a range used to select an array slice,
IMHO it ought to perform the test element by element in the array.

Actually, in a completely perfect world you could do

	@section = (<STDIN>)[ /^START_MARKER\n$/ + 1 .. /^END_MARKER\n$/ - 1 ] ;

and get many instances with:

	while ( @section = (<STDIN>)[ /START_MARKER/ + 1 .. /END_MARKER/ - 1 ] )
	{
		# do something with each section
	}

so the marker lines didn't get into @section, but there's a limit to
even my laziness......


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

Date: 14 Jul 1999 05:15:28 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: I want to do something interesting with ranges
Message-Id: <7mh6dg$ebl$1@lublin.zrz.tu-berlin.de>

Steve Simmons <scs@ans.net> wrote in comp.lang.perl.misc:
>Tried something which (IMHO) should have worked, but didn't:
>
>	@section = (<STDIN>)[ 4 .. /^MARKER\n$/ ] ;
>
>In short, I wanted to grab lines 4 thru the line which contains
>"^MARKER\n$" into @section.  This sort of thing works in list contexts
>for ranges of incrementable items, eg:
>
>	@section = (<STDIN>)[ 4 .. 10 ] ;
>
>and for mixed-type ranges in scalar contexts:
>
>	while (<>) {
>		push @section, $_ if ( 4 .. /$MARKER\n$/ ) ;
>	}
>
>OK, I can see reasons why it wouldn't work . . . but IMHO it ought to.
>When perl sees a non-scalar in a range used to select an array slice,
>IMHO it ought to perform the test element by element in the array.

Thaumatic overload alert... seek shelter.

In scalar context the .. operator is magical in that a numeric literal
(and nothing else) is implicitly compared to $. (the current line number),
so 4 .. /pattern/ is really $. == 4 .. /pattern/.  Normally, each operand
is evaluated as a boolean.  Since $. is a global variable the behavior
is well defined in any situation you may want to use scalar .., though
it only makes sense when you are working with file input.  The pattern
match, on the other hand, works on the general principle that $_ is the
default pattern searching space.

In list context, which is what you have between the [] in an array slice,
it is simply a list constructor, incrementing the value of the first
operand until it reaches (or passes) the second one.  While the use
of this construct in array slices may be frequent, it isn't the only
application by far.  What would the pattern be compared to in something
like "for ( 0 .. /boom/ ) {}"?

But even array slices don't always provide something reasonable to
match against.  @arry[ 1, 3, 5] = ( 5, 3, 1) is valid perl.  But
what would @arry[ 1 .. /oops/] slice out of the array before it is
defined?

In other words, while your construct may look reasonable in some
contexts, it only does because a lot of magic is going on already.
Adding more magic would, in my opinion, make it inordinately hard
to see what an expression really means and if it is applicable at
all.  In other words, thaumatic overload.

[snip farther-reaching suggestions]

Anno


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

Date: Tue, 13 Jul 1999 23:23:05 -0400
From: Michael G Schwern <stupid@pobox.com>
To: dbi-users@fugue.com
Subject: Ima::DBI - Possible major interface change!
Message-Id: <130719992323052132%stupid@pobox.com>

[[ This message was both posted and mailed: see
   the "To," "Cc," and "Newsgroups" headers for details. ]]

This is a call to all (any?) users of the Ima::DBI module.  I am
planning a major change to the interface (see below).  As the module is
still in development, nobody should be using it for serious production
work... I hope.  So, anyone who is, come forth now or forever hold your
peace!


The name of the module has to change, since the guys at CPAN don't want
to crack open the Ima:: namespace (and I don't blame them.)  It will
probably change to Class::DBI (somebody please suggest something
better.)

While this won't break existing programs, they won't benefit from new
versions of the module (of which benefits will be many.)


Comments?


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

Date: Wed, 14 Jul 1999 13:45:57 -0000
From: "Johnson ¬ù¿«­Ó¥J" <johnyick@hongkong.com>
Subject: MySQL with perl
Message-Id: <7mh7vu$b6o$1@imsp009a.netvigator.com>

which homepage teach Mysql with perl except its official site?
thanx for replying




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

Date: Wed, 14 Jul 1999 03:29:02 GMT
From: Ida Wong <ida@fcmc.com>
Subject: pattern matching with variables
Message-Id: <7mh05k$6g9$1@nnrp1.deja.com>

Hi there,

This is most likely an easy question. I would like to to have a variable
in my pattern match string. ie

if /$var/

but $ is the end of char and if I use \$ instead, then it resolve to a
simple "$" and not recognising $var is a variable.

any advice?

thanx,
ida


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


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

Date: Wed, 14 Jul 1999 13:41:09 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: pattern matching with variables
Message-Id: <MPG.11f6b1e031a31008989b38@news-server>

Ida Wong writes ..
>This is most likely an easy question. I would like to to have a variable
>in my pattern match string. ie
>
>if /$var/

what happens when you try this ?

-- 
 jason - remove all hyphens for email reply -


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

Date: 14 Jul 1999 01:39:28 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: perl -e 'print "${\ord(s)}\n";'
Message-Id: <slrn7ooc42.h7.abigail@alexandra.delanet.com>

Jeremy James (perly@ufl.edu) wrote on MMCXLII September MCMXCIII in
<URL:news:378BACC4.350BB4CC@ufl.edu>:
@@ perl -e 'print "${\ord(u)}\n";'
@@ 117
@@ perl -e 'print "${\ord(s)}\n";'
@@ Substitution pattern not terminated at -e line 1.
@@ 
@@ can someone help me understand why the 's' is trying to start a
@@ substitution and how I can stop this from happening?


You are using bare words. Now, s is also a function/operator, and in
the case of a conflict between barewords and functions/operators, the
Perl parser favours functions and operators, otherwise it would be
hard to write anything useful in Perl.  The 's' starts a substition,
using ')' as the delimiting character.

'use strict;' would have disallowed the use of bare words, and you
should always use that. To avoid this problem, you need to quote
the barewords:  perl -e 'print "${\ord(q [s])}\n"'. But why this 
difficult interpolation? Why not: perl -e 'print ord ("s"), "\n"' ?


Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 14 Jul 1999 04:30:37 GMT
From: "Geoff Zehring" <geoz@oz.net>
Subject: Perl CGI:  streaming HTML output from a called program...
Message-Id: <7mh3pd$hf1$0@216.39.133.81>

Hello,

This is my first post to the comp.lang.perl.misc newsgroup.  I hope I'm in
the right place!

My problem is this:

I want to send real time output in HTML format to a specified frame from a
 .sh file execution performed in a perl CGI script.  I've tried everything
short of using socket assignment.  My output always writes to the frame
after the .sh script has completed.  Obviously, STDOUT is assigned to the
parent process (in this case, the browser) but I still can't get the output
to stream.  Is JavaScript the answer?

If anyone has any ideas or examples, I would be extremely grateful.

Many thanks,

Geoff




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

Date: Wed, 14 Jul 1999 06:07:42 GMT
From: thiensyh@my-deja.com
Subject: Problem with generate the return html for browser client
Message-Id: <7mh9f8$95e$1@nnrp1.deja.com>

I'm facing a problem on my perl program , when i
compile the program it gave me the following error
message:
content-type:texthtml

<html><head><title>Merchant Administration
Page</title></head>
<CENTER><font face="helvetica"><B>EDC Merchant
Administration</B></center><P>

<H3>Sales Transaction Failed</H3><br><B>Detail
:</B> Payment Server unavaliable<
br>Please contact
administrator.<br></body></html>]

Here is my code where the problem happened. Please
help!

### generate the return html for browser client
                            _
print("content-type:text\html\n\n");
                            _
print("<html><head><title>Merchant Administration
Page</title></head>\n");    _
print("<CENTER><font face=\"helvetica\"><B>EDC
Merchant Administration</B></ce_
###
                            _

with many thanks,
Gabriel.


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


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

Date: Wed, 14 Jul 1999 06:07:38 GMT
From: thiensyh@my-deja.com
Subject: Problem with generate the return html for browser client
Message-Id: <7mh9f5$95c$1@nnrp1.deja.com>

I'm facing a problem on my perl program , when i
compile the program it gave me the following error
message:
content-type:texthtml

<html><head><title>Merchant Administration
Page</title></head>
<CENTER><font face="helvetica"><B>EDC Merchant
Administration</B></center><P>

<H3>Sales Transaction Failed</H3><br><B>Detail
:</B> Payment Server unavaliable<
br>Please contact
administrator.<br></body></html>]

Here is my code where the problem happened. Please
help!

### generate the return html for browser client
                            _
print("content-type:text\html\n\n");
                            _
print("<html><head><title>Merchant Administration
Page</title></head>\n");    _
print("<CENTER><font face=\"helvetica\"><B>EDC
Merchant Administration</B></ce_
###
                            _

with many thanks,
Gabriel.


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


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

Date: Wed, 14 Jul 1999 06:07:40 GMT
From: thiensyh@my-deja.com
Subject: Problem with generate the return html for browser client
Message-Id: <7mh9f7$95d$1@nnrp1.deja.com>

I'm facing a problem on my perl program , when i
compile the program it gave me the following error
message:
content-type:texthtml

<html><head><title>Merchant Administration
Page</title></head>
<CENTER><font face="helvetica"><B>EDC Merchant
Administration</B></center><P>

<H3>Sales Transaction Failed</H3><br><B>Detail
:</B> Payment Server unavaliable<
br>Please contact
administrator.<br></body></html>]

Here is my code where the problem happened. Please
help!

### generate the return html for browser client
                            _
print("content-type:text\html\n\n");
                            _
print("<html><head><title>Merchant Administration
Page</title></head>\n");    _
print("<CENTER><font face=\"helvetica\"><B>EDC
Merchant Administration</B></ce_
###
                            _

with many thanks,
Gabriel.


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


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

Date: Tue, 13 Jul 1999 23:39:06 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Professional programmers seeking opportunities on-line
Message-Id: <1duwm8l.32sbq21uqqi5tN@p232.tc2.state.ma.tiac.com>

Tomasz Marcinek <tomek@coders.pl> wrote:

> X-Complaints-To: abuse@news.icm.edu.pl

Consider it done.

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 14 Jul 1999 03:10:48 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Searching files
Message-Id: <7mgv3o$e70$1@lublin.zrz.tu-berlin.de>

 <inlandpac@my-deja.com> wrote in comp.lang.perl.misc:
>I have a search pattern where I am trying to extract domains:
>(<DB> being my file I am reading from)
>
>my @domains = /\)\s+(.*)/, <DB>;
>chomp @domains;

[snip irrelevant code]

>I am still getting erroneous results!  For example:
>
>(inlandaerospace-dom) inlandaerospace.com instead of just
>inlandaerospace.com

I doubt it.  The closest thing I can come up with that would deliver
something to @domains is something like

undef $/;
my @domains = ( <DATA> =~ /\)\s+(.*)/g );
chomp @domains;

>How can I extend my search pattern to remove anything that is in
>parenthesis?  I do not care if there are domains in the parenthesis.  I
>don't want them.

Since you are not showing us the data the pattern has to work on,
that's anybody's guess.  Apparently, there's a closing bracket followed
by whitespace somewhere before '(inlandaerospace-dom) inlandaerospace.com'.
After the first ') ' the \)\s+ part of your pattern is satisfied,
the rest goes to (.*) and that's what you get.

You could try /./\)\s+(.*)/.  This will grab as much text as possible
before a ') ' or similar, and then put the rest of the line into (.*).

A better solution would probably be to be more specific about what
can occur in a 'domain'.  Something like ([.-\w]+) would work for the
more standard types of domain names, but it all really depends on
the data you expect.

Anno


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

Date: Tue, 13 Jul 1999 23:39:07 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: single instance log file
Message-Id: <1duwmkz.1v7cyq1ju6ujmN@p232.tc2.state.ma.tiac.com>

Abigail <abigail@delanet.com> wrote:

> A close() unlocks the file. Usually, you don't want to unlock yourself.

Because if you do, then you allow other processes concurrent access to
yourself, and you'll probably end up getting corrupted!

-- 
 _ / '  _      /       - aka -
( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
    /                                http://www.tiac.net/users/chipmunk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Wed, 14 Jul 1999 06:04:55 GMT
From: rancorr@hotmail.com
Subject: Taking a Microsoft Word upload and converting it to text
Message-Id: <7mh9a2$93b$1@nnrp1.deja.com>

Hi,

I want to create a script that will take a Microsoft Word document
uploaded to my web site (web site is on a Linux/Apache machine) and
convert the word document to HTML (hopefully preserving the HTML).

I know Word has a "convert to HTML" feature, but I really don't want to
put the user through all that hassle.

Is there an easy way to do this?

Thanks for your help!


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


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

Date: Wed, 14 Jul 1999 03:38:11 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Uninitialized Value in Hash??
Message-Id: <378C05ED.A5BF1F8F@home.com>

[posted & mailed]

Tom Lynch wrote:
> 
>         I have the following code:

We know you're using -w because of the warning you're getting but you
will probably find 

    use strict;

at the top of your program useful as well.
 
> while (<FILE>) {
>     chop;

chomp is safer (in case your file isn't terminated by a newline) and
more versatile (in case you have $\ set to something that is more than
one character).

>     @line = $_;

Why is this here?

>     @line = split;

[snip]

>         if (exists $grp0rise{$line[1]}) {
>             push (@rise_grp0, "$pinname $pin $line[4] $grp0rise{$line[0]}");
>         }

[snip]

>         and I keep getting:
> 
> Use of uninitialized value at rtime line 163, <FILE> chunk 9086 (#1)
> 
>         which always points to one of the exists lines.
>         I have check and double checked $line[1] and it's
>         a valid value.

perl is pointing to the wrong line (but it's close).  It could be that
$line[4] is undefined.  If you expect 5 elements in your array then it
would be a good idea to put a check on that immediately after assigning
it.

    if (@line < 5) {
        warn "$_\n is missing fields--skipping\n";
        next;# or you could just die()
    }

It could also be that $grp0rise{$line[0]} is undefined.  You don't check
that.  You only check if $grp0rise{$line[1]} exists.  

    exists ne defined
    1 != 0

-- 
Rick Delaney
rick.delaney@home.com


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

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


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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


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