[12662] in Perl-Users-Digest

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

Resend: Perl-Users Digest, Issue: 71 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 22:17:24 1999

Date: Wed, 7 Jul 1999 19:03:00 -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, 7 Jul 1999     Volume: 9 Number: 71

Today's topics:
        advice on data structures, and more <litscher@cis.ohio-state.edu>
    Re: cgi question, can you help me? <miroslav@gamestats.com>
    Re: cgi textarea filtering <jtolley@bellatlantic.net>
    Re: Connection problem using Perl DBI and IIS4 (Abigail)
    Re: Deleting everything after a pattern? (Neko)
    Re: error 500 problem (Abigail)
    Re: Expired CGI-script (Needs help quick) (Abigail)
    Re: Expired CGI-script (Needs help quick) (Abigail)
    Re: Help -- Weird Increments (MacPerl) (Anno Siegel)
    Re: HTTP Proxy programming <bakins@mediaone.net>
    Re: HTTP Proxy programming (Abigail)
    Re: is anybody here? (Abigail)
    Re: Is PERL the way to create a pop-up window ? <jtolley@bellatlantic.net>
    Re: Joining a string? (Abigail)
    Re: My Own Perl Library Setup <cassell@mail.cor.epa.gov>
    Re: Need subroutine to create combinations (elephant)
    Re: Newbie Question <kistler@fnmail.com>
    Re: opening a pipe (elephant)
    Re: Problems with derefrencing (Larry Rosler)
    Re: regular expressions in vi <dbc@tc.fluke.com>
    Re: regular expressions in vi (elephant)
    Re: Summing Array to Hash elements <hiller@email.com>
    Re: Summing Array to Hash elements (Abigail)
    Re: Tk::BrowseEntry - Return index instead of value? <lusol@Pandora.CC.Lehigh.EDU>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Wed, 07 Jul 1999 20:50:11 -0400
From: Ross <litscher@cis.ohio-state.edu>
Subject: advice on data structures, and more
Message-Id: <3783F5C3.4F546D9@cis.ohio-state.edu>

Hi everyone. I know someone is going to point me to the FAQ after
reading what i ask, but I have looked there and I cannot find what i
need. I also have "Programming Perl" and has kinda helped, not really
noticable to you judging by the length of this message, but... trust me.
Please be gentle. Now here is what i'm trying to do. I need to sort
entries of a "database"  according to zip code first and then within zip
code, the institution name. So i'm splitting up each line doing
something like this


while(<CLEAN_LIST>)
{
    ($first_name, $last_name, $institution, $department, $address_2,
$address, $city, $state, $zip, $error_code) = split /,/, $_, 10;
    push @{ $all_lines[$line_counter] },  "all of the above variables";
    $line_counter++;
}

by the way, entries of the database look like:
"Ross","Litscher","Ohio State","","","111 My Rd.",
"Columbus","OH","43210",""
"Joe","Shmoe","Malanabapoop","Biomed","","321 His St.",
"Columbus","OH","43210",""

so when i do the split, it leaves in the quotes. One question is, since
they all have quotes, if I sort these will the quotes play any part in
deciding the order? I would think not, but I am not sure, since I am new
to the perl world.

i have tried sorting like this:

@sorted = sort {
                     zip($a) <=> zip($b) ||
                     institution($a) <=> institution($b) ||
                   }     @all_lines;

i can't remember if this worked at all or not. i remember getting two
various results by changing things around. one, which i think this is
what the code was, was that is got hung up on zip, thinking is was a
subroutine? the other problem i ran into while trying to write a correct
implementation was it threw everything into the zeroith place of the
array, so instead of accessing by doing $sorted[3][8], to get the same
item i would do $sorted[0][28]. which isn't what I expected nor wanted.

So I am not too sure that I'm going about this the right way at all.
Could someone offer me a little insight? should i be reading the data
into a different kind of structure? I know there were a couple more
questions I had, I can't think of them right now. I hope this message
allows you to comprehend what I am trying to do.

thanks,
ross



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

Date: Thu, 08 Jul 1999 01:54:16 +0200
From: Miroslav <miroslav@gamestats.com>
Subject: Re: cgi question, can you help me?
Message-Id: <3783E8A8.6AA418F8@gamestats.com>

you could

print "Please wait for results...";

[ do your stats thing here ] #it'll wait I think until server finishes

print "Here's your stats...";

Just a thought, I never used anything like this

> geofox wrote:
> 
> Hi,
> I have written a cgi script to get
> some information about the statistics of
> the web site....
> However, it takes some time to output
> the result.
> My Question is:
> can I write something such "pls wait" or "the result is coming" etc.
> to indicate the request is processing before the result comes out
> in the page?
> 
> Thanks,
> geofox
> 

-- 
Miroslav, miroslav@gamestats.com
No Mutants Allowed - Fallout Website
http://fallout.gamestats.com/


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

Date: Thu, 08 Jul 1999 00:51:18 GMT
From: "James Tolley" <jtolley@bellatlantic.net>
Subject: Re: cgi textarea filtering
Message-Id: <aCSg3.34$_t5.8931@typhoon2.gnilink.net>


Robin Senior <therobin@nortelnetworks.com> wrote in message
news:3783A7FF.5093345E@nortelnetworks.com...
> Hey,
> using Perl, what sort of filtering should I put on info submitted from a
> textarea?
> Right now I'm using:
> $fields{'input'} =~ s/\r\n|\n/\r/gs>

> I'm outputting to a flat-file text database, with new records delimited
> by newlines. By substituting with \r, I can still maintain multiple line
> formatting without delimiting records

> How can I prevent this from happening?
> Is there a standard filter for textareas

Textareas, in all of my tests on different browsers on Mac, Win32, Unix, all
submit \r\n as a newline. I store this info in text db's sometimes, too, and
find that variations of one of the following works fine:

$in{'area'} =~ s/\r\n/<br>/g;
or
$in{'area'} =~ s/\s*\r\n/ /g; # that's a space.






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

Date: 7 Jul 1999 19:03:17 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Connection problem using Perl DBI and IIS4
Message-Id: <slrn7o7qlb.ued.abigail@alexandra.delanet.com>

Pascal Essiembre (pessiembre@netscape.net) wrote on MMCXXXVI September
MCMXCIII in <URL:news:n2Pg3.23579$Xr4.199771@c01read02-admin.service.talkway.com>:
%% Hi,
%% 
%% I have connection problems when multiple users try to connect at the
%% same time to a Sybase database using Perl DBI through IIS4.

Did you check the Sybase errorlog? Did you check your servers errorlog?
Do you have something more substantial than "my query just stops"?


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: 8 Jul 1999 00:37:01 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Deleting everything after a pattern?
Message-Id: <7m0rrd$9bh$0@216.39.141.200>

On 07 Jul 1999 20:17:06 GMT, mesarchm@aol.com (Mesarchm) wrote:

>I don't see the typo.  I tested it and it works much faster than my old method.

>s/$pattern.*?$//;
             ^
             typo

Specifying a non-greedy quantifier will gain you nothing.  A greedy
quantifier cannot eat up past the end of a string, no matter how greedy it
is.

    s/foo.*$//;  # Say what you mean.

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: 7 Jul 1999 19:13:38 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: error 500 problem
Message-Id: <slrn7o7r8o.ued.abigail@alexandra.delanet.com>

matt01980@DELETETHISTOMAILaol.com (matt01980@DELETETHISTOMAILaol.com)
wrote on MMCXXXVI September MCMXCIII in <URL:news:37836437.4CFF9A3A@DELETETHISTOMAILaol.com>:
,, The following code when placed in my script causes a error 500.

Well, that's a very general description, and not really helpful.

,, The error log says:
,, 
,, Missing right bracket at myscript.lib line 961, at end of line
,, syntax error at myscript.lib line 961, at EOF

Good. Did you check 'man perldiag' to see what it means?

,, If I comment it out I still get the 500 error with the same report in
,, the error log.

Logical.

,,                It is only when I delte the above coding that the script
,, runs.

Really? That's pretty amazing. You delete some comments, and suddenly the
script compiles. That must be a bug in Perl. Could you trim it down to
say 10 lines, showing the problem, and use 'perlbug' to submit it?

,,       However without the above code the part of the script that runs
,, the banner ad wont work.

Now, that's what I call a feature. Perhaps Perl examined your code and
decide to puke on it.`

,,                          I normally call the banner ad from its own
,, script via SSI and it works fine, I have copied the code and put it in
,, my new script to call the banner ad.

Bad. You shouldn't just copy-and-paste-code.

,,                                      However the part of the script
,, above is causing an 500 error and I dont know why. Any one know what
,, part of the script could be causing the error?

It's unlike the part in your posting, as it didn't work when outcommented.

,,                                                Also is there a way to
,, call a perl script from with in a perl script?

Yes. RTFM.

,,                                               I thought about having my
,, script call the same perl script that my ssi pages do, but dont know if
,, that is possible. Please reply to my email address and remove the
,, "DELETETHISTOMAIL" part of the email address to email me. Thanks, Matt.

Yeah. Really. If you want to have a personal reply, be at least not
so rude to mangle your email address. Or do you expect someone bringing
you a free, custom made, pizza to climb over a fence as well?



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== 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: 7 Jul 1999 19:18:35 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Expired CGI-script (Needs help quick)
Message-Id: <slrn7o7ri2.ued.abigail@alexandra.delanet.com>

Anders Thorsby (artsoft@danbbs.dk) wrote on MMCXXXVI September MCMXCIII
in <URL:news:NNKg3.263$HY5.508@news.get2net.dk>:
 .. 
 .. I have a CGI-script which much expire, so the script has to be executed
 .. again if the user follows a link and using the browsers back-button. The
 .. output of the script may not be cached!

Please read the appropriate RFC. There are HTTP headers that will
*SUGGEST* to the browser and intermediate agents not to cache documents,
but those can be ignored. And the same RFC explicitely states that going
back has to be treated differently when it comes to caching. Getting a
'stale' document this way is a *feature*, not a bug.

 .. Any hint, help or quick solution is usable!!!

Once a document is in my hands, *I* decide how to deal with it. If you
don't want it cached, don't send it out.


Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== 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: 7 Jul 1999 19:20:10 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Expired CGI-script (Needs help quick)
Message-Id: <slrn7o7rl3.ued.abigail@alexandra.delanet.com>

Fulko van Westrenen (fulko@trane.wtm.tudelft.nl) wrote on MMCXXXVI
September MCMXCIII in <URL:news:slrn7o773j.fh.fulko@trane.wtm.tudelft.nl>:
\\ On Wed, 7 Jul 1999 17:58:28 +0200, Anders Thorsby <artsoft@danbbs.dk> wrote:
\\ >
\\ >I have a CGI-script which much expire, so the script has to be executed
\\ >again if the user follows a link and using the browsers back-button. The
\\ >output of the script may not be cached!
\\ 
\\ This is not a Perl issue, but html. I'm not a html-guru,
\\ but is must be something like:
\\ <META HTTP-EQUIV="pragma" CONTENT="no-cache">


Not HTML, and won't certainly not work with in a non-HTML document.
And don't expect proxies to actually parse HTTP data; they have better
things to do. And a pragma: no-cache may be ignored anyway.



Abigail
-- 
perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT


  -----------== 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: 8 Jul 1999 00:19:25 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help -- Weird Increments (MacPerl)
Message-Id: <7m0qqd$4s4$1@lublin.zrz.tu-berlin.de>

johnny99  <john@your.abc.net.au> wrote in comp.lang.perl.misc:
>I'm using someone else's script, which uses an external data
>file to record an incremented number.
>
>The incremented number is incrementing very strangely.
>
>Here's a script I put together to reproduce the effect:
>
>		open (NUMBER,"+<data.txt");
>		$num = <NUMBER>;
>		print "I got $num from the data.txt file ";
>		$num++;
>		print "and I incremented it to $num.\n";
>		print NUMBER $num;
>		close (NUMBER);
>
>which produces these effects, (starting with a zero as the
>contents of data.txt):
>
>I got 0 from the data.txt file and I incremented it to 1.
>I got 01 from the data.txt file and I incremented it to 02.
>I got 0102 from the data.txt file and I incremented it to
>0103.
>I got 01020103 from the data.txt file and I incremented it
>to 01020104.
>I got 0102010301020104 from the data.txt file and I
>incremented it to 0102010301020105.
>
>Can anyone help me?
>
>This script works just fine on UNIX, by the way, and you end
>up with a file consisting of just

You broke off there.  Was that because you found the program
behaves under unix just as it does on the mac?

When you write to the file after reading to eof, you append to it.
Also, the increment works in string mode, since you never use
the string you read from the file in a numeric context.  Both
facts together explain the behavior perfectly well.

Anno


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

Date: Wed, 07 Jul 1999 20:11:02 -0400
From: "M. Brian Akins" <bakins@mediaone.net>
Subject: Re: HTTP Proxy programming
Message-Id: <3783EC96.85027C9E@mediaone.net>

Thanks so much for your rudeness.

My question was indeed perl related.  After digging a little deeper, I used
the HTTP::Daemon module, and that enabled me to view the complete request from
the browser.  The only problem I have now is that when pulling images over
this proxied connection, performance is hideous.

Anyone else had anyexperience with similar projects?

Once again, to Martien Verbruggen, my day would not have been complete with
out your rudeness.

Thanks,

M. Brian Akins.


Martien Verbruggen wrote:

> In article <378340C7.E8C8A58A@mediaone.net>,
>         "M. Brian Akins" <bakins@mediaone.net> writes:
>
> > I have a problem though.  When connecting to apche servers which use
> > name based virtual hosting, since I am only connecting via IP, I get the
> > default "host" on that server.  What I need is a way to determin from
>
> Of course you do.
>
> > the HTTP request from a browser what server they are attempting to
> > connect to by name and then forward this to the apache server.  Right
> > now all I can  see is the generice HTTP request: "GET /  HTTP 1.0".
>
> And your perl question is?
>
> HTTP headers are discussed in the comp.infosystems.www.* hierarchy.
> Not in the perl newsgroups. Of course, you are now writing something
> much more complex than just an IP level packet router. You might want
> to read the relevant RFCs.
>
> > Any help out here??
>
> Not here.
>
> > Please e-mail me directly.
>
> No. Post here, read here, even if it is irrelevant to this group. This
> response on this group may encourage other people with similar
> questions to think about which group they need to ask these questions
> on.
>
> Martien
> --
> Martien Verbruggen                  |
> Interactive Media Division          | The gene pool could use a little
> Commercial Dynamics Pty. Ltd.       | chlorine.
> NSW, Australia                      |



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

Date: 7 Jul 1999 19:26:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: HTTP Proxy programming
Message-Id: <slrn7o7s0g.ued.abigail@alexandra.delanet.com>

M. Brian Akins (bakins@mediaone.net) wrote on MMCXXXVI September MCMXCIII
in <URL:news:378340C7.E8C8A58A@mediaone.net>:
!! 
!! I have a problem though.  When connecting to apche servers which use
!! name based virtual hosting, since I am only connecting via IP, I get the
                                                              ^^
Really? Just IP? No TCP?

!! default "host" on that server.  What I need is a way to determin from
!! the HTTP request from a browser what server they are attempting to
!! connect to by name and then forward this to the apache server.  Right
!! now all I can  see is the generice HTTP request: "GET /  HTTP 1.0".

The HTTP Host header isn't supported by HTTP/1.0.

Why isn't the proxy copying the appropriate headers from the client?



Abigail
-- 
Until they cull me on my head with something hard, I will argue for web
caches as pure network buffers; no stealing or illegality in buffering bits.
                   [Ingrid Melve in `Hit-metering: to Proposed Standard?'
                    <"4aPDO3.0.QQ.34rao"@cuckoo>]


  -----------== 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: 7 Jul 1999 19:27:50 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: is anybody here?
Message-Id: <slrn7o7s3f.ued.abigail@alexandra.delanet.com>

Steven Line (sline@rdss.com) wrote on MMCXXXVI September MCMXCIII in
<URL:news:3783AD6C.AB981FC9@rdss.com>:
|| 
|| This group is empty.


No, it's not. It was just nice and quiet here. Untill you came along.
*sigh* There goes the neigbourhood.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\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: Thu, 08 Jul 1999 00:45:29 GMT
From: "James Tolley" <jtolley@bellatlantic.net>
Subject: Re: Is PERL the way to create a pop-up window ?
Message-Id: <JwSg3.33$_t5.8666@typhoon2.gnilink.net>




cd156 <cd156@att.net> wrote in message
news:7m0mse$27o$1@bgtnsc03.worldnet.att.net...
> I'm wondering if there is a way to have a perl script open a small window
 .
> I've tried a couple of methods, but not getting positive results.

If your customer base is using IE 3 and 4 exclusively on Win32, I suppose it
could be done, but you'd have to jump through some hoops. There's got to be
a better way.

> A few webhosting servers produce pop-ups, how the heck are they doing it ?

By this, I think you mean username and password dialogs. If so, this is most
likely a server authentication issue. HTTP Basic Authentication is what's
being used. The browser pops up the window, not a script.




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

Date: 7 Jul 1999 19:29:10 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Joining a string?
Message-Id: <slrn7o7s5v.ued.abigail@alexandra.delanet.com>

pedro (pedro@nospam.co.uk) wrote on MMCXXXVI September MCMXCIII in
<URL:news:37832041.5785584@news.freeuk.net>:
&& Just a simple question that i couldn't find in the
&& 'thick books'.

Maybe you should get some Perl books then.

&& If you have one scalar say $a="blue" and
&& another variable as say $b="sky" how do
&& you add them in perl so that $c=$a+$b in other
&& words  c$="bluesky" ?


That's in the manual. Go read it.



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, 07 Jul 1999 17:33:55 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: My Own Perl Library Setup
Message-Id: <3783F1F3.ACB9C8EE@mail.cor.epa.gov>

[Note - your 'Organization' is 'free textbook'?  Are textbooks
being cruelly held in captivity somewhere?]

Alex wrote:
> 
> Hi Everyone,
> 
> How can I have my own perl Library setup in my cgi-bin directory?
> I want to use the LWP.
> where I can find this kind of information? But if you willing to
> teach me in newsgroup, I appreciate so much!

You'll be surprised to learn that the information you seek is
in the Perl FAQ.  That's right, the Frequently Asked Questions
that you no doubt already looked through (as is recommended
in any guide to Usenet Netiquette).  Since you missed this,
I'll tell you to go back to perlfaq8 and look for these
questions:

"How do I keep my own module/library directory?"
"How do I add the directory my program lives in to the 
module/library search path?"
"How do I add a directory to my include path at runtime?"

If you don't have these on your machine, then I strongly
recommend that you download a copy of Perl at once.  Not
only will you have all the FAQ and documentation that comes
with Perl, but you'll have Perl itself to use as a testbed
for your CGI scripts.  It will be so much easier to test
and debug your scripts on your own machine than to try to
do it remotely, when you may not be able to see the server
logs easily.

You'll also want the CGI.pm module.

HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Thu, 8 Jul 1999 10:13:30 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: Need subroutine to create combinations
Message-Id: <MPG.11ee983964401ad9989b19@news-server>

Billy Patton writes ..
>Ex: if list has 3 elements. combinations need to be created that
>have from one to 3 elements, all unique.
>list = a,b,c
>combinations :

QED

#--begin
my @array = ();	# global to hold resulting array

combinations( '', 0, (1,2,3,4));

for ( @array) { print "$_\n"; }

sub combinations
{
  my( $current, $i, @in) = @_;

  for ( my $j = $i; $j < @in; $j++)
  {
    push( @array, $current . $in[$j]);
  }

  local $" = '';	# otherwise we'll have spaces in our combinations

  # recurse
  combinations( "@in[0..$i++]", $i, @in) unless $i > $#in;
}
#--end

>combinations :
>a b c
>b c a
>c a b
>a c b
>c b a
>b a c

now that's a more difficult problem .. which I can't be bothered with

-- 
 jason - remove all hyphens for email reply -


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

Date: Thu, 08 Jul 1999 00:48:27 +0200
From: Per Kistler <kistler@fnmail.com>
To: Adrian Mink <akmink@worldnet.att.net>
Subject: Re: Newbie Question
Message-Id: <3783D93B.B7FCEAC@fnmail.com>

Hi Adrian

It's nearly impossible to check an email address to be perfectly
correct. In the perl cookbook, there is a discussion about this
on p. 206. But if you just want to have something which matches
yyy@yyyyy where there could be as many y's and y would be a lot
of things, it could be something like:
$y = '[\w\-+&\.#%]';
if( $email =~ m!$y+\@$y+! ){ ok }
But since there is no check for meaning, it's rather meaningless.
One could as well just say:
$notY = '[^\@\s]';
if( $email =~ m!$notY+\@$notY+! ) { ok }

(This posting looks ugly:-(

Regards, Per.

Adrian Mink wrote:
> 
>     Hello,
> 
>         I'm running Active Perl Build 517 and have a simple question. I'm
> writing a script to weed bad email addresses out of a list and am looking
> for a way to do a simple comparison against what the basic email address
> should look like. (We have a lot of people who enter their address in
> compleatly wrong, I'd like to weed them out.)
>         I was thinking of just comparing the address in question against a
> pattern using wildcards ($email == something@something.something) but cannot
> seem to figure out how to do this. Can someone help? Thanks. I am very new
> to Perl and will appreciate any help. Thanks.
> 
> --
>        Adrian Mink
> akmink@worldnet.att.net

-- 
Per Kistler kistler@fnmail.com / kistler@gmx.net
------------------------------------------------------------


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

Date: Thu, 8 Jul 1999 08:50:07 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: opening a pipe
Message-Id: <MPG.11ee84a99c0eea38989b17@news-server>

Brian Orpin writes ..
>	open (PIPE, "rlog -r $file |") or die "could not open PIPE rlog\n";
>
>The open works fine but I am trying to catch the case when the rlog fails
>(can't find the file).

1) test for the existance of the file first ?

if ( -e $file) { open... or die... }
else { print( 'no file'); }

you can see the -e function and other such gems in the perlfunc page

2) use the shell to pipe the STDERR output to STDOUT ?

open( PIPE, "rlog -r $file 2>&1 |") or die...

you will then get the output of STDERR ('2') on STDOUT ('1') .. NB: this 
relies on a UNIX shell (pretty sure they all do this) so you will have to 
use method 1) if you're on NT

-- 
 jason - remove all hyphens for email reply -


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

Date: Wed, 7 Jul 1999 17:05:43 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problems with derefrencing
Message-Id: <MPG.11ed8b306eb441989c71@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <3783DE28.EE410565@zeus.ia.net> on Wed, 07 Jul 1999 18:09:28 
-0500, Michael Carman <mjcarman@zeus.ia.net> says...
 ...
> ... Try
>     print @{df_output{$mount_point}};
> which will print the array elements seperated by spaces.

No, by default (i.e., unless you set $, to " ") it won't.  I think you 
mean:

      print "@{df_output{$mount_point}}";

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


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

Date: Wed, 7 Jul 1999 16:55:27 -0700
From: Dan Carson <dbc@tc.fluke.com>
Subject: Re: regular expressions in vi
Message-Id: <Pine.LNX.3.95.990707164832.19933A-100000@dbc-pc>

On 7 Jul 1999, Barry G Reville wrote:

> I use vi and I know PERL - is there any way to use perl's regular
> expressions within the vi editor?

Not real convienient, but...

:%!perl -pe 's/perl regexp/whatever/'

-Dan



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

Date: Thu, 8 Jul 1999 09:00:38 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: regular expressions in vi
Message-Id: <MPG.11ee8720f6d9a827989b18@news-server>

Barry G Reville writes ..
>I use vi and I know PERL - is there any way to use perl's regular expressions within the vi editor?

HELLO ?!?!?! .. I use my toilet - but I know Perl .. should I therefore 
ask the perl newsgroup how to get comfortable on my Royal Dulton seat 
while trying to read a perl book ?

followups set

-- 
 jason - remove all hyphens for email reply -


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

Date: Thu, 08 Jul 1999 00:28:12 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Re: Summing Array to Hash elements
Message-Id: <3783F09D.C5F30D9E@email.com>

This worked for me, although it may not be very efficient:

my(%hash);
my(@array) = qw/hello world hi hello this is a sample world/;

foreach(@array) {
	$hash{$_}++ or $hash{$_} = 1;
}

--
Then for testing purposes use this:
--

foreach(keys %hash) {
	print "$_: $hash{$_}\n";
}

wired2000@my-deja.com wrote:
> 
> Hi,
> 
> I have an array that stores a list of unknown keywords (see below) and
> I would like to convert this array to a hash table which stores the
> total number of occurances in the array.
>


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

Date: 7 Jul 1999 19:39:15 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Summing Array to Hash elements
Message-Id: <slrn7o7sor.ued.abigail@alexandra.delanet.com>

wired2000@my-deja.com (wired2000@my-deja.com) wrote on MMCXXXVI September
MCMXCIII in <URL:news:7m0cjo$n9r$1@nnrp1.deja.com>:
"" 
"" I'm not quite sure how to do the unique scan, especially because I
"" don't know what the keywords are at runtime. Normally I would do a
"" foreach, but the problem is I don't know how to insert data into the
"" hash when I don't know what the keys are upfront. Anyone have any
"" suggestions or sample code would be greatly appreciated.

Well, what if you do a foreach over the array, and use the iteration
variable as a key? You *do* know what variables are, don't you?



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: 7 Jul 1999 23:59:21 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: Tk::BrowseEntry - Return index instead of value?
Message-Id: <7m0pkp$ge6@fidoii.cc.Lehigh.EDU>

Michael Carman <mjcarman@zeus.ia.net> wrote:
> Okay, I've tried posting this to a couple of other Perl ng's thinking

Just 1 - comp.lang.perl.tk

> that it would be more appropriate there but have received no response so
> I'm going where there's more traffic and (hopefully) knowledge.

Yikes.

> Apologies to anyone who's already seen this elsewhere.

Hmm - I replied at length a few days ago.... Gorgo seems to have munched it.
I hate having to type a reply > once, so I'll be brief.

> I am just starting to work with Tk. For my first little toy application
> I'm using BrowseEntry to make a selection box. This widget normally sets
> the associated variable to the value of whichever option is chosen. Can
> it return the index instead? Or better yet, an arbitrary value? I've

No. No. But anything is possible, perhaps subclassing the widget.  

> found nothing in the docs to suggest that
> I can do so, but I wouldn't think that it's uncommon to desire this
> behavior. What I'm really trying to do is to use a hash to populate the
> box, displaying the values to choose from but returning the keys. The
> hash is 1:1 so I could make a copy using reverse() and then look up the

I don't think reverse() is what you want.

> key there, but that feels too much like a kludge. Has anyone wrestled
> with this before?

No.  Possibilites:

1) Tie::Watch - probably not what you want.

2) A -browsecmd callback seems reasonable - it's called with 2 params, the
widget reference and the selected (browsed) entry; use that to map to whatever
you'd like.  No duplicate values, right?

3) I forget, but I know there was a #3.  Rats.  Oh, use an array?  Menu items
are indexed by an ordinal..... ?










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

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


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