[19904] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2099 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 9 06:10:32 2001

Date: Fri, 9 Nov 2001 03:10:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005304213-v10-i2099@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 9 Nov 2001     Volume: 10 Number: 2099

Today's topics:
    Re: Processing portions of an array <htmailing.nospam@yahoo.com>
        Regular Expression <AdamYYYY@yahoo.com>
    Re: Regular Expression (Anno Siegel)
    Re: Removing whitespace from list / array (mark)
    Re: Serving HTML images <goldbb2@earthlink.net>
    Re: Split output into multiple pages? <goldbb2@earthlink.net>
        Table Sort <martin@ppmedia.at>
    Re: unexpected behaviour behind  a protecte directory <wyzelli@yahoo.com>
    Re: unexpected behaviour behind  a protecte directory <bart.lateur@skynet.be>
    Re: Unix executed thru CGI? <brian@jankoNOnet.SPAMcom.INVALID>
    Re: Unix executed thru CGI? (Garry Williams)
    Re: Unix executed thru CGI? (Tad McClellan)
    Re: Unix executed thru CGI? <comdog@panix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 9 Nov 2001 04:16:30 +0100
From: "htmailing" <htmailing.nospam@yahoo.com>
Subject: Re: Processing portions of an array
Message-Id: <3beb4a02@post.usenet.com>

**** Post for FREE via your newsreader at post.usenet.com ****


Mark Jason Dominus (mjd@plover.com) wrote in message news:...

> Try this:
>
>         while (@array) {
>           my @next_50 = splice @array, 0, 50;
>           whatever(@next_50);
>         }
>

This is what I ended up doing after reading perldoc -f splice and some
trial-and-error.  It works like a charm !!!

Thanks for all the help.  This NG rocks !

Cheers






-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 *** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
                      http://www.usenet.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


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

Date: Fri, 9 Nov 2001 05:29:42 -0500
From: "Adam Young" <AdamYYYY@yahoo.com>
Subject: Regular Expression
Message-Id: <9sgaeh$jqt$1@slb3.atl.mindspring.net>

What \1 and \2 mean? digit 1, digit 2 or char 1, char 2. I am confused.
Can't find this at perldoc.

Thanks.




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

Date: 9 Nov 2001 10:26:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regular Expression
Message-Id: <9sgb0l$krq$2@mamenchi.zrz.TU-Berlin.DE>

According to Adam Young <AdamYYYY@yahoo.com>:
> What \1 and \2 mean? digit 1, digit 2 or char 1, char 2. I am confused.
> Can't find this at perldoc.

As is often the casein Perl, the answer depends on context.  In the
context of a regular expression, \1, \2, ... are back-references to
captured matches.  In other double-quotisch contexts they represent
the characters with ASCII values 1, 2, ... .  perldoc perlre explains
this in detail.

Anno


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

Date: 9 Nov 2001 00:21:34 -0800
From: mark.adaoui@siemens.at (mark)
Subject: Re: Removing whitespace from list / array
Message-Id: <487f3b0f.0111090021.23a23741@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9uljen.k5v.tadmc@tadmc26.august.net>...
> mark <mark.adaoui@siemens.at> wrote:
> 
> >My code:
> >#!usr/local/bin/perl
>   ^^
>   ^^
> 
> Is the truly your code?
> 
> How are you invoking the program?
> 
> Didn't notice that missing character before...

-------------------------------------------------------------------------------
9/11/01
Let me start by thanking everyone for the replies & help.

Basicly i am writing a prog, to read in asn types & write
corresponding c code, the asn types are listed in a txt file, called a
telegram.

legal tokens are the elements of the telegram that i wish to make a
new array from, so basicly i want to know how to scan/filter this txt
file, for approprite tokens, then create an array of these tokens.
Without generating the empty strings (thx Tad).

valid Tokens are numbers, (mainly integers) characters, parenthesis &
curlies, also something we refer to as the colon operator ::=
All of these are valid Tokens. (does this help)

The original query, clearly illustrates how i want the array to look
when it is printed.

If you require more info, please dont hesitate to post, or mail me,
once again thanx to all concerned, for there time.
Mark


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

Date: Thu, 08 Nov 2001 21:19:17 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Serving HTML images
Message-Id: <3BEB3D25.3796C59C@earthlink.net>

[reordered chronologically]
GOGAR wrote:
> Benjamin Goldberg wrote:
[snip]
> > #!/usr/local/bin/perl -wT
> > # imageloader.cgi
> > # invoke as http://foo.bar.com/cgi-bin/imageloader.cgi/foo.gif
> > my ($file) = $ENV{PATH_EXT} =~ m[^([^/]*)\z];
[snip]
> 
> maybe in the urls to the images you could add a random query string..
> i am assuming the html page is generated by cgi..
> 
> like
> 
> <img src="http://www.blah.com/images/image.jpg?random=3534545">

The query string [the ? and all that follows it] is irrelevant -- what
is relevant is that the part *before* it be a filename which you
consider ok for saving.  By using path_ext, the result is that the
filename that the browser sees is '.../foo.gif'.  If you could simply
name your cgi program "image.gif" that would be great... you could put
the parameters after it just like a normal cgi.  But I'm sure that there
will be a few httpds which will not like such a name for an executable
cgi program.

-- 
Klein bottle for rent - inquire within.


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

Date: Thu, 08 Nov 2001 21:52:27 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Split output into multiple pages?
Message-Id: <3BEB44EB.4FE5C919@earthlink.net>

Charles King wrote:
> 
> Have a problem with a script which prints designated fields from
> *all records* in a flat file database.  The problem is how to
> split what gets printed into multiple pages with links at the
> bottom to the other pages.  (btw, I'm not a CGI programmer [in case
> that's not obvious from my question]).

#!/usr/local/bin/perl -wT
use CGI::Carp;
use strict;
# always use -w and strict.
# always use -T for cgi programs.
# usually use CGI::Carp while the cgi program is being developed.

use DB_File;
use CGI qw(:default *table);

my $database = "/home/me/mystuff/thedatabase.txt";
my $limit = param("limit") =~ /(\d+)/;
my ($start) = param("start") =~ /(\d+)/;
$limit = 30 if !$limit || $limit<0;
$start = 0  if !$start || $start<0;
tie my (@database), "DB_File", $database
    or die $!;
print header, start_html, start_table;
print Tr th [qw/field1 field2 field3 field4/];
for( $start .. $start+$limit-1 ) {
    last if $_ > $#database;
    print Tr td [split /\|/, $database[$_], -1],
}
print end_table, br;
if( $start != 0 ) {
    my $url = url(-relative=>1);
    $url .= "?start=" . ($start>$limit ? $start-$limit : 0);
    $url .= "&limit=$limit" if $limit != 30;
    print a {href=>$url}, "Prior Page";
    print br;
}
if( $start+$limit-1 < $#database ) {
    my $url = url(-relative=>1);
    $url .= "?start=" . $start+$limit;
    $url .= "&limit=$limit" if $limit != 30;
    print a {href=>$url}, "Next Page";
    print br;
}
print end_html;
__END__

NB: this code is untested.

-- 
Klein bottle for rent - inquire within.


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

Date: Fri, 09 Nov 2001 11:20:06 +0100
From: Martin <martin@ppmedia.at>
Subject: Table Sort
Message-Id: <3BEBADD6.9040008@ppmedia.at>

Hi to everybody
I must create html Tables and sort them in different criterics (name, 
land, usw)

My workaround is to create a temporary Table in database with the 
results of request and than i create from this different tables in html 
and let sql do the sorting.

My question is if is there a better way to do this
Like the Html::Pager module but i need only one table no buttons for 
forward and back

Thanx martin



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

Date: Fri, 9 Nov 2001 16:07:54 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: unexpected behaviour behind  a protecte directory
Message-Id: <vQKG7.66$4N6.906@vicpull1.telstra.net>

"Kirst Hulspas" <google@psc-it.nl> wrote in message
news:JszG7.814$rW6.489@castor.casema.net...
> I found your previous posting on google and *not* :( on my news site.
Sorry
> about that.
> And Yes, perl can be written badly but I doubt if it is the cause this
time.
> The cgi below behaves *exactly* the same when called from:
>
>     <form method="POST" action="http://www.mysite.nl/bin/tst.cgi">
>     <input type="text" name="Name" value="" size="9" maxlength="9">
>     <input type="submit" name="send" value=" Send ">
>     </form>
>
>     #!/usr/bin/perl
>     print "Content-type: text/plain\n\nHello World\n";
>     exit(0);
>
> It again returns the input unchanged after a 'backspace' when called from
> any normal subdir and returns with cleared text when called behind a
> password proteced directory.
> I tried a proteced directory on a slash server and there it returns in
> *both* cases the original field values. So blame th WN server or if this
is
> this known behaviour too, could you tell me what causes it,  whether it is
> avoidable, and how?

No idea really.  Can't say I have ever had that problem myself, even with
SSL.  There are some methods that prevent caching of a page, and force
reloading of pages every time they are viewed.  THat would be a
server/client/http/java type issue rather than a Perl one though.

>
> btw. how do I call your signature? it crashes on me.

push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;

Save it as a script and run it.  It should print

Just another Perl hacker

Well it does for me anyway...

Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_!=1)? 's':'';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';




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

Date: Fri, 09 Nov 2001 08:52:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: unexpected behaviour behind  a protecte directory
Message-Id: <6u5nutsgdasub431its05eqaokk13g88l9@4ax.com>

Kirst Hulspas wrote:

>After POST-ing it returns a recap that can be approved or not.
>If I use the 'back button' (or backspace key) to review my input,
>it returns the original values in the filled-in form fields. So far so good.
>However, if the same html-page is submitted behind a password protected
>directory, the back-button returns an *empty* form, with all fields reset to
>blank.

>I have a feeling this behaviour is not directly caused by perl or the
>browser.

It smells like caching got turned off, likely by the server. Try messing
with returning various cache-control headers, expiration date etc.
Search the web for technical data, some RFC's etc. (I think much of this
is related to controling the behaviour of proxies.)

It would be ideal if you could see the exact headers the server sends to
your browser... can you use LWP to debug them?

-- 
	Bart.


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

Date: Fri, 09 Nov 2001 03:26:00 GMT
From: "Brian Janko" <brian@jankoNOnet.SPAMcom.INVALID>
Subject: Re: Unix executed thru CGI?
Message-Id: <c1IG7.65520$7x1.5793515@bin4.nnrp.aus1.giganews.com>


"Tintin" <tintin@snowy.calculus> wrote in message
news:WzCG7.1$hb.155731@news.interact.net.au...
>
> "Steffen Müller" <tsee@gmx.net> wrote in message
> news:9semdj$pk1$00$1@news.t-online.com...
> >
> > Anyway, if you just want to copy a file, you can use Perl to do that. No
> > reason to use a Unix command. The File::Copy module from CPAN may be
> exactly
> > what you are looking for!
>
> No need to grab File::Copy from CPAN, it's part of core Perl.
>
>
>


Great.  Thanks.  Can you point me to info on what methods the File::Copy
module has and how to code with it?

Thanks,
Brian





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

Date: Fri, 09 Nov 2001 04:43:33 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Unix executed thru CGI?
Message-Id: <slrn9umnnl.17g.garry@zfw.zvolve.net>

On Fri, 09 Nov 2001 03:26:00 GMT, Brian Janko
<brian@jankoNOnet.SPAMcom.INVALID> wrote:

> "Tintin" <tintin@snowy.calculus> wrote in message
> news:WzCG7.1$hb.155731@news.interact.net.au...
>> "Steffen Müller" <tsee@gmx.net> wrote in message
>> news:9semdj$pk1$00$1@news.t-online.com...

[ snip ]

> Great.  Thanks.  Can you point me to info on what methods the File::Copy
> module has and how to code with it?

Jeesh.  We have to read the documentation on YOUR hard drive to you?  

Try the perldoc command: 

  perldoc File::Copy

-- 
Garry Williams


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

Date: Fri, 09 Nov 2001 04:46:18 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Unix executed thru CGI?
Message-Id: <slrn9uml2b.l40.tadmc@tadmc26.august.net>

Brian Janko <brian@jankoNOnet.SPAMcom.INVALID> wrote:

>Can you point me to info on what methods the File::Copy
>module has and how to code with it?


You can read the documentation for any module installed on
your system with the perldoc program:

   perldoc File::Copy


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 09 Nov 2001 00:30:06 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Unix executed thru CGI?
Message-Id: <comdog-C212DC.00300609112001@news.panix.com>

In article <c1IG7.65520$7x1.5793515@bin4.nnrp.aus1.giganews.com>, 
"Brian Janko" <brian@jankoNOnet.SPAMcom.INVALID> wrote:

> Great.  Thanks.  Can you point me to info on what methods the File::Copy
> module has and how to code with it?

perldoc File::Copy

or check out

    http://www.perldoc.com

-- 
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html



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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 2099
***************************************


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