[9403] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2998 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 26 21:07:25 1998

Date: Fri, 26 Jun 98 18:00:43 -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           Fri, 26 Jun 1998     Volume: 8 Number: 2998

Today's topics:
        Data sent to CGI script via POST into PERL Form sfnichols@my-dejanews.com
    Re: first language - last language (Michael Rubenstein)
    Re: Flames.... (I R A Aggie)
        Formatting integers with commas (1,000,000 etc.) <jcharlesworth@bellacoola.com>
    Re: Formatting integers with commas (1,000,000 etc.) <jcharlesworth@bellacoola.com>
    Re: Formatting integers with commas (1,000,000 etc.) <tkil@scrye.com>
    Re: Global variables? <rra@stanford.edu>
    Re: help! : Arrays in Perl (Craig Berry)
        how much filespace ? (Freddy)
    Re: how to know the limit of a perl array? (Craig Berry)
    Re: Is anyone working on a VxWorks port of Perl? <rra@stanford.edu>
    Re: Perl for Win-32 <fdonovan@media.mit.edu>
    Re: QUE: DBD-Oracle-0.50 database module <ljz@asfast.com>
    Re: regex efficiency (Craig Berry)
    Re: Replacing "stuff" via Regex... HELP! (Craig Berry)
    Re: Replacing "stuff" via Regex... HELP! (Craig Berry)
    Re: Replacing "stuff" via Regex... HELP! (Craig Berry)
    Re: Replacing "stuff" via Regex... HELP! (Craig Berry)
        Send data via POST to CGI Script with PERL Form sfnichols@my-dejanews.com
    Re: SOCKS and LIBWWW <rra@stanford.edu>
    Re: Strange ommission from perl function list <rra@stanford.edu>
    Re: Wait Command in Perl <rra@stanford.edu>
    Re: want a better way to split string (Chris Williams)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 26 Jun 1998 23:22:58 GMT
From: sfnichols@my-dejanews.com
Subject: Data sent to CGI script via POST into PERL Form
Message-Id: <6n1agi$eev$1@nnrp1.dejanews.com>

I wrote a program that uses multiple CGI-Perl scripts to compile data that is
entered by users.  Users enter their data in a text box:

<td>
<textarea row=6 cols=75 wrap="virtual" name="Bod1" ></textarea>
</td>

This is passed to the next CGI-Perl script using POST and printed using:

   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $input{Bod1}
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $input{Bod1}
~  ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $input{An1}
 .


1)  If I enter:

This is a long line that fills almost the entire length of the text box!
This is a short line!
This is a short line!

It only prints the first two lines.
*****

2)  If I enter: long, short, long.  It prints all three.

3)  If I enter: short, long, short.  It prints all three.

4)  If I enter: short, short, long.  It prints all three.

5)  If I enter: short, short, short.  It prints only the first line.


To debug I had the variable print to the Browser window: i.e.-

$input{Bod1}=This is a short line! This is a short line! This is a short line!

The data is being sent to the CGI script.  I'm baffled!  HELP!!!!!!!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Sat, 27 Jun 1998 00:50:29 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: first language - last language
Message-Id: <35963eb5.179370360@nntp.ix.netcom.com>

On Fri, 26 Jun 1998 13:41:57 GMT, John Porter <jdporter@min.net>
wrote:

>Daniel Grisinger wrote:
>> 
>> I had never heard of Intercal but found an implementation.  I've been
>> playing with it for a couple of hours and all I can say is, `Wow, and
>> people think perl looks line noise' :-).  Not to mention the amusing,
>> but somewhat obscure error messages.
>
>That reminds me of another language which is probably worse...
>no, I take that back.  But pretty bad, and more resembling
>line noise: Teco.

But teco was actually intended to be used.  In fact, I did use it a
lot until some easier to use editors with reasonable power became
available.  I hated teco, but I hated it a lot less than any of the
other editors I saw during most of the 1960s.

Even by today's standards, teco was a very powerful editor.  In a head
to head contest, it could destroy a file 3 times as fast as vi and 10
times as fast as emacs :-)
--
Michael M Rubenstein


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

Date: Fri, 26 Jun 1998 19:16:57 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Flames....
Message-Id: <fl_aggie-2606981916580001@aggie.coaps.fsu.edu>

In article <1db8npb.7s0bqzwnp8gvN@roxboro0-044.dyn.interpath.net>,
phenix@interpath.com (John Moreno) wrote:

+ > >If you want to mix-n-match, why not just have _one_ newsgroup.
+ > >James - for all of UseNet, that is...
 
+ > You need two: one for topics where a perl program is the solution
+ > and a second for everything else.  And only a few years ago
+ > you would have found perl advocates in the 2nd group pointing
+ > out the error of their ways.
 
+ If I'm wrong I apologize, but I believe he meant - ONE newsgroup for
+ everything from alt.sex.bestiality discussions to
+ zer.z-netz.wissenschaft.technik, why have more than one after all
+ they'll have some points in common...

Give John a golden cigar! That's *exactly* what I meant.

James


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

Date: Fri, 26 Jun 1998 23:10:36 GMT
From: John Charlesworth <jcharlesworth@bellacoola.com>
Subject: Formatting integers with commas (1,000,000 etc.)
Message-Id: <35942A6B.37005E07@bellacoola.com>


--------------504CC6A383FEC8A6811635D7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

sprintf's %d doesn't appear to add comma separators (shows 1 million as 1000000 rather than 1,000,000).  For large numbers, this creates readability problems.

Anyone know a simple idiom for inserting the commas?  One brute-force approach is building a loop which keeps doing a divide and mod 1000 but that seems needlessly ugly ;-)

Thanks,
 .../j

[Image]

--------------504CC6A383FEC8A6811635D7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
sprintf's %d doesn't appear to add comma separators (shows 1 million as
1000000 rather than 1,000,000).&nbsp; For large numbers, this creates readability
problems.

<P>Anyone know a simple idiom for inserting the commas?&nbsp; One brute-force
approach is building a loop which keeps doing a divide and mod 1000 but
that seems needlessly ugly ;-)

<P>Thanks,
<BR>.../j

<P><IMG SRC="http://www.bellacoola.com/cgi-bin/cgiwrap/johnc/TheScribe3.pl/00001?c.l.p.m.commas" NOSAVE HEIGHT=1 WIDTH=1></HTML>

--------------504CC6A383FEC8A6811635D7--



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

Date: Fri, 26 Jun 1998 23:18:28 GMT
From: John Charlesworth <jcharlesworth@bellacoola.com>
Subject: Re: Formatting integers with commas (1,000,000 etc.)
Message-Id: <35942C43.1800CE8B@bellacoola.com>


--------------D6DFBFE2507529A04073F154
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Sorry, just found it in the FAQ...:

How can I output my numbers with commas added?

    sub commify {
        local $_  = shift;
        1 while s/^(-?\d+)(\d{3})/$1,$2/;
        return $_;
    }

    $n = 23659019423.2331;
    print "GOT: ", commify($n), "\n";

    GOT: 23,659,019,423.2331

You can't just:

    s/^(-?\d+)(\d{3})/$1,$2/g;

because you have to put the comma in and then recalculate your position.


John Charlesworth wrote:

>  sprintf's %d doesn't appear to add comma separators (shows 1 million as 1000000 rather than 1,000,000).  For large numbers, this creates readability problems.
>
> Anyone know a simple idiom for inserting the commas?  One brute-force approach is building a loop which keeps doing a divide and mod 1000 but that seems needlessly ugly ;-)
>
> Thanks,
> .../j
>
> [Image]



--------------D6DFBFE2507529A04073F154
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
Sorry, just found it in the FAQ...:

<P>How can I output my numbers with commas added?

<P>&nbsp;&nbsp;&nbsp; sub commify {
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; local $_&nbsp; = shift;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 while s/^(-?\d+)(\d{3})/$1,$2/;
<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $_;
<BR>&nbsp;&nbsp;&nbsp; }

<P>&nbsp;&nbsp;&nbsp; $n = 23659019423.2331;
<BR>&nbsp;&nbsp;&nbsp; print "GOT: ", commify($n), "\n";

<P>&nbsp;&nbsp;&nbsp; GOT: 23,659,019,423.2331

<P>You can't just:

<P>&nbsp;&nbsp;&nbsp; s/^(-?\d+)(\d{3})/$1,$2/g;

<P>because you have to put the comma in and then recalculate your position.
<BR>&nbsp;

<P>John Charlesworth wrote:
<BLOCKQUOTE TYPE=CITE>&nbsp;sprintf's %d doesn't appear to add comma separators
(shows 1 million as 1000000 rather than 1,000,000).&nbsp; For large numbers,
this creates readability problems.

<P>Anyone know a simple idiom for inserting the commas?&nbsp; One brute-force
approach is building a loop which keeps doing a divide and mod 1000 but
that seems needlessly ugly ;-)

<P>Thanks,
<BR>.../j

<P><IMG SRC="http://www.bellacoola.com/cgi-bin/cgiwrap/johnc/TheScribe3.pl/00001?c.l.p.m.commas" NOSAVE HEIGHT=1 WIDTH=1></BLOCKQUOTE>
&nbsp;</HTML>

--------------D6DFBFE2507529A04073F154--



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

Date: 26 Jun 1998 17:17:48 -0600
From: Tkil <tkil@scrye.com>
Subject: Re: Formatting integers with commas (1,000,000 etc.)
Message-Id: <gyaujg3c3.fsf@scrye.com>

[posted and cc'd]

>>>>> "John" == John Charlesworth <jcharlesworth@bellacoola.com> writes:

John> Anyone know a simple idiom for inserting the commas?  One
John> brute-force approach is building a loop which keeps doing a
John> divide and mod 1000 but that seems needlessly ugly ;-)

man perlfaq4.

or:  http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_can_I_output_my_numbers_with

HTH,
t.
-- 
Tkil * <URL: http://www.scrye.com/~tkil> * hopelessly hopeless romantic.
  "So amplify this little one 	|   She hears as much as she can see
   She's a volume freak       	|   And what she sees, she can't believe."
        -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"


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

Date: 26 Jun 1998 17:38:58 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Global variables?
Message-Id: <m33ecrbrvh.fsf@windlord.Stanford.EDU>

Robert Rehammar <Robert.Rehammar@emw.ericsson.se> writes:

> Do the variable keep it's value if you exit the funktion in which you
> gave the variable it's value?

It depends on what type of a variable it is.  my() variables and variables
that have been affected by local() don't, but other variables do.  For a
more complete discussion of the issues involved in this, see the perlsub
man page.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 26 Jun 1998 23:13:32 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: help! : Arrays in Perl
Message-Id: <6n19us$4dl$1@marina.cinenet.net>

Philipp (philipp999@corpex.com) wrote:
: On Thu, 25 Jun 1998 08:33:11 -0400, Justin Voshell <vosheljh@jmu.edu>
: wrote:
: >
: >	I am pretty new with Perl an can't seem to find a function that will
: >tell me the length of an array. Is there such a thing [there must be]?
: 
: And why dont you all just use $#my_array????

Perhaps because that doesn't provide the length (element count, really) of
@my_array? Oddly enough, the expression that will provide the element
count of @my_array is @my_array.  Nicely Zen, that. 

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 26 Jun 1998 19:30:15 GMT
From: freddy@postme.com (Freddy)
Subject: how much filespace ?
Message-Id: <3593f575.46834657@news.isk.de>


hello specials

i have a very newbie question. i want to know all filespace used down
a named directory. how is that done the easy way? i tested with "ls"
but didn't get a simple answer.

  root
    var
      test
        job
          mail
          web
          other

my example: i want to know all used filespace from the directory "job"
with the directories "mail", "web" and "other" all together.

thanks for reply.

freddy


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

Date: 26 Jun 1998 23:24:14 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how to know the limit of a perl array?
Message-Id: <6n1aiu$4dl$2@marina.cinenet.net>

Yongyan Wang (ywang@emma.plaza.ds.adp.com) wrote:
: In perl, the array can be assigned without pre-assigning its subscript
: limit, like $var[100]="value";
:
: How can I know the limit of the subscript of the variable?

For an array @foo, $#foo is its highest index.  You should probably read
the Llama book or some other Perl beginners' book if you are still working
stuff like this out.  You won't regret it, I promise you.

: Practically, can I do the following
: $var[1000000000000000000000000]="value"; ?

Nope, you'd almost certainly exhaust virtual memory trying to do that.  If
you need to use huge but sparse arrays, a hash probably makes more sense.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 26 Jun 1998 17:36:58 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Is anyone working on a VxWorks port of Perl?
Message-Id: <m367hnbryt.fsf@windlord.Stanford.EDU>

Brand and Karina Hilton <bkhilton@netcom.com> writes:

> It has occurred to me that, if 5.005 is thread-safe, porting to VxWorks
> would be much simpler than previously.  Is anyone working on such a
> thing?

It would surprise me if people were working on that already, as the work
on making Perl thread-safe is still in beta.  In other words, I'm not sure
the thread-aware track of Perl is quite stable enough yet for major
porting efforts.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 26 Jun 1998 20:02:05 -0400
From: Fred Donovan <fdonovan@media.mit.edu>
Subject: Re: Perl for Win-32
Message-Id: <3594367D.167E@media.mit.edu>

I've installed the Oreilly UserAdmin module for
Perl on NT ( http:\\www.vne.com\ora\useradmn). Seems to
have installed ok, and my test program compiles, but
when calling the function Win32::UserAdmin::UserGetAttributes
($server, $username, $level, \%userinfo) I get the error:

	The system could not find the environment option
that was entered.

	when I put in a bogus name for the server,
the function waits a while before returning. With 
a real name, it returns almost immediately.

	I can't really trace the function like one can
under unix ( truss, eg), so I don't know what's going
on. Any hints would be very appreciated.


	Thanks!

-- 
------------------------------------------------------
Fred Donovan
Systems/Network Engineer
M.I.T Media Lab
20 Ames Street
Cambridge, MA  02139
fdonovan@media.mit.edu


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

Date: 26 Jun 1998 20:52:26 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: QUE: DBD-Oracle-0.50 database module
Message-Id: <lt90mjr7hx.fsf@asfast.com>

Tsoukalos Mihalis <mike@tech.eurodyn.com.gr> writes:

> Hello to everyone.
> 
> I have some questions to make about the DBD-Oracle-0.50 perl database
> module.
> 
> 1. I want to know if it is possible to access not only a local Oracle
> database but also a remote Oracle database using the &ora_login(...) [or
> using another way] subroutine.

If you have the Oracle client libraries installed on your local host,
and if the local host can access the remote database through these
locally installed client libraries (for example, via `sqlplus'), then
your DBD-Oracle application should be able to perform the same kind of
access successfully.  I have done this and it works.

If you only have the Oracle client libaries installed on the remote
host and not the local host, then you might want to experiment with
the DBD-pNet module.  This module allows you to access a remotely
installed database via a Perl-based proxy that is running on the
remote host and which is accessed via a corresponding module on the
local host.  The proxy would need to run on the same host that the
Oracle database is installed on, and that remote host would need to
have the Oracle client libraries installed ... but not your local
host.

This DBD-pNet module is in an early stage of development, and I had
trouble about 3-6 months ago getting it to work properly with Oracle.
But YMMV, so perhaps you might want to give it a try.

> 2. There will be a lot of interaction with the Oracle database. Do you
> think that it is better to use Perl or should I use the JDBC API
> instead?

I have found the transmission time between the client and the database
server is comparable whether the client uses Perl or Java, but in
general, I have found that Java clients themselves tend to be less
efficient than their Perl counterparts if these clients make use of
lots of vector, hash, string, etc. operations.

I have been working on a real-time bond trading system written in Java
(version 1.1.x), and we have had to move a lot of the calculations
that sit near the data base interface out of the Java client and into
the database server as stored procedures.  This gave us a speed
increase of 5-7 times right off the bat, even before further
optimization.

Also, about 3-6 months ago, I wrote a Java/Swing application that
performed the same functions on my machine (200 MHz Pentium Pro
running RedHat Linux 5.0) as an already written Tk-Perl application.
The Tk-Perl program ran 50%-100% faster.

Perl is not the most efficient language to use for many applications
(strictly in terms of execution speed), but Java tends to be even
worse.

But perhaps Java has gotten more efficient in the past few
months ... ???

> 3. If I make the module using Oracle 7.3.2 is it possible to use the
> module with Oracle 8.0.3 without any changes [recompilation] ? There are
> some errors when I am trying to do it but I don't know if it is my
> fault.

Well, this one I can't answer, since I haven't used 8.0.3 yet.

Good luck!

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 26 Jun 1998 23:43:40 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: regex efficiency
Message-Id: <6n1bnc$4dl$7@marina.cinenet.net>

alawishus@my-dejanews.com wrote:
: the best way to match files that end in ".pl" or ".pl.whatever"

So we want a '.pl', followed by either end of string or a period.

: so say you have in
: 
: color.pl
: color.pl.bak
: color.plus
: 
: don't want to match the color.plus
: don't want to use alternatives in the regex like, unless
: it really is quicker
: /\.pl$|\.pl\.$/
: 
: we could say
: /\.pl(\..*?)*?$/

Note that those are different.  The first matches '.pl', an option '.',
then end of string.  The second is pretty messed up...the outer
non-greediness is meaningless, for example...but seems to match '.pl'
followed by either end of string, or a dot and then practically anything
after that.  And it captures the dot-followed-by-anything, too.

My take on this would look like

  /\.pl(?:\.|$)/

that is, '.pl', followed by either '.' or the end of the string.  This is
a bit more effiecient than your similar version above, as it moves the
common part ('.pl') outside the alternation.  It also avoids incorrectly
demanding end of string immediately after a following '.', if present.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 26 Jun 1998 23:28:56 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replacing "stuff" via Regex... HELP!
Message-Id: <6n1aro$4dl$3@marina.cinenet.net>

Mike Cisar (mcisar@iul.net) wrote:
: Appologies if this has been posted before/recently... but I've been
: hammering my head up against the wall for hours trying to write a Regex
: that will take the input string (a comma delimited line from a
: spreadsheet) and remove any fields that are quoted.  There may be zero
: or more fields which are quoted and must be nuked.

Why damage your head and/or your wall when this is both a FAQ and handled
by a CPAN module (Text::CSV, I believe)?  (Actually, the removal part
isn't covered by either, but parsing out the comma-separated fields is the
hard part.)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 26 Jun 1998 23:35:19 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replacing "stuff" via Regex... HELP!
Message-Id: <6n1b7n$4dl$6@marina.cinenet.net>

Daniel Grisinger (dgris@rand.dimensional.com) wrote:
: Hmmmmmm... but it doesn't work.  If your string really has newlines
: in it this will work (if it doesn't have newlines you can leave off
: the /s)-
:  s/".*?"//gs;

Pardon my previous post, paired commas around excised fields *is* what the
original poster wanted.  Sorry.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 26 Jun 1998 23:32:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replacing "stuff" via Regex... HELP!
Message-Id: <6n1b1n$4dl$4@marina.cinenet.net>

F.Quednau (quednauf@nortel.co.uk) wrote:
: > ie. if the input line was
: > data,data,data,number,text,"string",data, stuff,"nuther",stuff,text,"two
: > words",text
: > the output would be
: > data,data,data,number,text,,data, stuff,,stuff,text,,text
: 
: What about this?
: 
: $_ = 'data,data,data,number,text,"string",data, stuff,"nuther",stuff,text,"two
: words",text';
: s/".*",//;
: print $_."\n";

That clobbers everything from "string... through ...two words".  Not quite
to spec.

Making the .* into .*? gets a lot closer, but would still fail on escaped
internal quotes (if that matters), and on a quoted field in the last
position in the list (since there's no following comma).

Parsing CSV text is a bit trickier than it looks at first.  That's why
Freidl plays with it for many pages in _Mastering Regular Expressions_,
and why Text::CSV got written.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: 26 Jun 1998 23:34:20 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Replacing "stuff" via Regex... HELP!
Message-Id: <6n1b5s$4dl$5@marina.cinenet.net>

Daniel Grisinger (dgris@rand.dimensional.com) wrote:
: Hmmmmmm... but it doesn't work.  If your string really has newlines
: in it this will work (if it doesn't have newlines you can leave off
: the /s)-
:  s/".*?"//gs;

That leaves in a pair of commas surrounding the excised field, which isn't
how I interpreted the original poster's spec.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      Member of The HTML Writers Guild: http://www.hwg.org/   
       "Every man and every woman is a star."


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

Date: Fri, 26 Jun 1998 23:07:13 GMT
From: sfnichols@my-dejanews.com
Subject: Send data via POST to CGI Script with PERL Form
Message-Id: <6n19j1$dck$1@nnrp1.dejanews.com>

I wrote a program that uses multiple CGI-Perl scripts to compile data that is
entered by users.  Users enter their data in a text box:

<td>
<textarea row=6 cols=75 wrap="virtual" name="Bod1" ></textarea>
</td>

This is passed to the next CGI-Perl script using POST and printed using:

   ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $input{Bod1}
~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $input{Bod1}
~  ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   $input{An1}
 .


1)  If I enter:

This is a long line that fills almost the entire length of the text box!
This is a short line!
This is a short line!

It only prints the first two lines.
*****

2)  If I enter: long, short, long.  It prints all three.

3)  If I enter: short, long, short.  It prints all three.

4)  If I enter: short, short, long.  It prints all three.

5)  If I enter: short, short, short.  It prints only the first line.


To debug I had the variable $input{Bod1} printed to the Browser page; i.e. -

$input{Bod1}=This is a short line! This is a short line! This is a short line!

So the information is being passed to the script via POST.

I'm baffled!  HELP!!!!!!!

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 26 Jun 1998 17:35:03 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: SOCKS and LIBWWW
Message-Id: <m3btrfbs20.fsf@windlord.Stanford.EDU>

Robert C Rekas <robertcr@us.ibm.com> writes:

> I'm trying to pool html pages over proxy, noproxy and socks.
> Proxy/noproxy scenarios are working but I do not know how to do socks.
> Any comments/help?

My understanding from previous discussions of SOCKS is that to do it
properly, one would need a Perl with core support for SOCKS.  In other
words, be warned that this may be decidedly non-trivial.

Hopefully someone who knows an easier way will correct me if I'm wrong.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 26 Jun 1998 17:33:35 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Strange ommission from perl function list
Message-Id: <m3emwbbs4g.fsf@windlord.Stanford.EDU>

Bart Lateur <bart.mediamind@tornado.be> writes:
> Russ Allbery wrote:

>> There was a proposal to include min and max in a future version of Perl
>> as third-class keywords

> Probably a silly question: what's a third class keyword? Does this imply
> that there are first and second class keywords too? Fourth, ...?

I'm not sure what the exact distinction between first and second class
keywords are (maybe you can't overload first-class keywords?) but a
third-class keyword is one that doesn't complain and doesn't exist for the
purposes of your program if you already have a sub defined with that name.
In other words, min and max would be introduced in a fashion that didn't
break existing code that already had subs with those names.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 26 Jun 1998 17:36:06 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Wait Command in Perl
Message-Id: <m390mjbs09.fsf@windlord.Stanford.EDU>

Michael Harrison <hostmaster@hosttech.com> writes:

> I need to get a script to wait about 10-12 seconds while a file is
> produced.  The script writes a request file for ICVerify and the needs
> to stall for 10-12 secs while the answer file is produced. My questions
> is, is there any easy way to do this.

        sleep 12;

> Second after I read in the .answer file I need to read only the first
> char of the file to see if it is an "A" or "N" and the give the result
> back to the client. What is and easy way to strip all char from a
> Filehandler but the first. chop() gets the last char, is there away to
> reverse that.

        $char = substr ($string, 0, 1);

Hope this helps!

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 26 Jun 1998 23:37:16 GMT
From: chrisw@netinfo.com.au (Chris Williams)
Subject: Re: want a better way to split string
Message-Id: <35953020.1025229@newshost.netinfo.com.au>

On Fri, 26 Jun 1998 14:12:43 -0500, "Al Degutis"
<adegutis@isi-info.com> wrote:

>I'm trying to break down a string to fit 60 characters per line.  Rather
>than use a specific length of 60 characters, I'd like to break the string on
>the nearest space starting from the 50th position.
>
You may wish to try the Text::Wrap module.   It is close (not exactly)
what you asked for.  It's part of the standard distribution.

perldoc Text::Wrap

HTH

Chris Williams
Canberra, Australia


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2998
**************************************

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