[25800] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8039 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 2 06:05:33 2005

Date: Mon, 2 May 2005 03:05:06 -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           Mon, 2 May 2005     Volume: 10 Number: 8039

Today's topics:
    Re: [Golf-ish] Ordered hash keys (Anno Siegel)
    Re: a regex question .. <geoff.cox@notquitecorrectfreeuk.com>
    Re: a regex question .. <geoff.cox@notquitecorrectfreeuk.com>
    Re: a regex question .. <someone@example.com>
        CGI & Formatting or a Perl Problem?! <hackeras@gmail.com>
    Re: CGI & Formatting or a Perl Problem?! <joe@inwap.com>
    Re: CGI & Formatting or a Perl Problem?! <pilkowsk@informatik.uni-marburg.de>
        Help with perl array <please@touchmywilly.com>
    Re: REMOTE_HOST aint working <pilkowsk@informatik.uni-marburg.de>
    Re: REMOTE_HOST aint working <joe@inwap.com>
    Re: REMOTE_HOST aint working <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 2 May 2005 08:38:56 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: [Golf-ish] Ordered hash keys
Message-Id: <d54ov0$hnh$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Damian James <djames@thehub.com.au> wrote:
> 
> >   my @fields = @mappings[ map $_*2, 0..($#mappings/2) ];
> 
> > Is there a simpler, shorter
> > or more elegant 'hashificator' that might be suitable in place of the
> > arithmetic one I've shown? 
> 
> 
> You can save 3 strokes by generating the slice indexes with:
> 
>    grep $_%2, 0..$#mappings
> 
> instead of map().

Yes, but that selects odd elements, not even ones.

Anno


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

Date: Mon, 02 May 2005 07:37:58 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: Re: a regex question ..
Message-Id: <n4mb711lv4nvajju33solmaj1k974ip45r@4ax.com>

On Sat, 30 Apr 2005 21:29:18 GMT, "John W. Krahn"
<someone@example.com> wrote:

>> I didn't know about the look ahead etc so thanks for that ....
>
>The information about those should be on your hard drive in the perlre.pod 
>document.
>
>perldoc perlre
>
>Or on the web at: http://perldoc.perl.org/perlre.html


Thanks John - will follow up on this.

Cheers

Geoff


>
>
>Of course TMTOWTDI.  :-)
>
>my $newname = join '', 'new-', map /\A\d\z/ ? "0$_" : $_, split /(\d+)/, $name;
>
>
>
>John



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

Date: Mon, 02 May 2005 07:39:43 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: Re: a regex question ..
Message-Id: <h6mb71ds6890jkmjf3uu60q7m5pbf1q0pv@4ax.com>

On Sun, 1 May 2005 00:49:07 +0200, Fabian Pilkowski
<pilkowsk@informatik.uni-marburg.de> wrote:

>    (my $newname = $name) =~ s/(\d+)/sprintf '%02u', $1/eg;
>
>IMHO, this is more intuitive than searching for enclosing non-digits *by
>hand* ;-)

Fabian,

Thanks again - a more elegant solution - will work out how it works!.

Cheers

Geoff




>
>regards,
>fabian



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

Date: Mon, 02 May 2005 09:04:29 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: a regex question ..
Message-Id: <x2mde.22866$tg1.18131@edtnps84>

Geoff Cox wrote:
> On Sun, 1 May 2005 00:49:07 +0200, Fabian Pilkowski
> <pilkowsk@informatik.uni-marburg.de> wrote:
> 
>>   (my $newname = $name) =~ s/(\d+)/sprintf '%02u', $1/eg;
>>
>>IMHO, this is more intuitive than searching for enclosing non-digits *by
>>hand* ;-)
> 
> Thanks again - a more elegant solution - will work out how it works!.

You have to be careful with that solution as it will not work if there are
numbers outside the range of the %u format.

$ perl -le'
my $name = q/1def333ghi5jkl/;
print $name;
( my $newname = "new-$name" ) =~ s/(\d+)/ sprintf "%02u", $1 /eg;
print $newname;
'
1def333ghi5jkl
new-01def333ghi05jkl

$ perl -le'
my $name = q/1def3333333333333333333333ghi5jkl/;
print $name;
( my $newname = "new-$name" ) =~ s/(\d+)/ sprintf "%02u", $1 /eg;
print $newname;
'
1def3333333333333333333333ghi5jkl
new-01def4294967295ghi05jkl


Also, because of the /e (eval) option it is slower.



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 02 May 2005 12:10:21 +0300
From: Nikos <hackeras@gmail.com>
Subject: CGI & Formatting or a Perl Problem?!
Message-Id: <d54qpq$s8$1@nic.grnet.gr>

This may be or may not be a Perl question, i dont know.
I also asked this in the css and alt.html ngs but they didnt care to answer.

The code is correct, it does not  give any errors but i cant see 
anything printed. Please take a look.


====================================================
print start_form(-action=>'index.pl');
       print p( {-align=>'center'}, span( {class=>'tip'}, " Some Greek 
text" ),
                                    popup_menu( -name=>'select', 
-values=>\@display_files ),
                                    submit('ÅðéëïãÞ'));
print end_form;
=====================================================


and inside styles.css i have:

========================
td.tip {
      font: 18px times;
      color: cyan;
}
========================

But i cant see the quoted text in "big centered lime colored text".
And also in the following snippet:



And also in this as well i cannot se

==============================================
    while( $row = $sth->fetchrow_hashref )
    {
       print table( {class=>'user_form'},

          Tr(
             td( {-width=>'25%'},      {class=>'name'},    $row->{name} 
     ),
             td( {-width=>'50%'},      {class=>'email'}, $row->{email}    ),
             td( {-width=>'25%'},      {class=>'date'},    $row->{date} 
     )
          ),

          Tr(
             td(                       {class=>'host'},    "Ao?? oio 
Ecoiy" ),
             td( {colspan=>2},         {class=>'tip'},    $row->{pray}     )
          ),

          Tr(
             td(                       {class=>'tip'},    "?niou?ee? 
Ineiaiii?iaoiaoee? Ai?aen?a" )),
             td( {colspan=>2},         {class=>'remark'}, $row->{remark}   )
          ),

          Tr(
             td( {colspan=>3},         {class=>'host'},    $row->{host} 
       )
          ),

          br() x 2;
    }
==============================================

All the classes exist.Here is user_form:

table.user_form {
	background-image: url(/data/images/swirl.jpg);
  	width: 55%;
   	color: lime;
   	text-align: center;
	font: 18px times;
	border: 5px inset blue;
	border-collapse: collapse;
}


-- 
"Of course I cant stop you. And that would really bum me out
if that were my job. But my job isnt to stop you, its to
make it as difficult as possible, for as many as possible,
for as long as possible ."


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

Date: Mon, 02 May 2005 02:42:03 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: CGI & Formatting or a Perl Problem?!
Message-Id: <27mdnWul1sVwaOjfRVn-gw@comcast.com>

Nikos wrote:

> The code is correct, it does not  give any errors but i cant see 
> anything printed. Please take a look.

Access the CGI with your browser, then use the "Save As" menu item
to store the perl CGI-generated HTML to your hard disk.  Then perform
a side-by-side comparison between the saved HTML and hand crafted HTML.
Edit the saved HTML until it looks right.  Then retro-fit those
changes into your perl script.


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

Date: Mon, 2 May 2005 11:50:29 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: CGI & Formatting or a Perl Problem?!
Message-Id: <3dmbdoF6s9d0fU1@individual.net>

* Nikos schrieb:

> This may be or may not be a Perl question, i dont know.
> I also asked this in the css and alt.html ngs but they didnt care to answer.
> 
> The code is correct, it does not  give any errors but i cant see 
> anything printed. Please take a look.
> 
> ====================================================
> print start_form(-action=>'index.pl');
>        print p( {-align=>'center'}, span( {class=>'tip'}, " Some Greek 
> text" ),
>                                     popup_menu( -name=>'select', 
> -values=>\@display_files ),
>                                     submit('ÅðéëïãÞ'));
> print end_form;
> =====================================================

Please re-format your code when posting here. It could be easier to read
if your newsreader won't break long lines. Avoid this by writing:


    print start_form(-action=>'index.pl');
    print p(
        {-align=>'center'},
        span( {class=>'tip'}, "Some Greek text" ),
        popup_menu( -name=>'select', -values=>\@display_files ),
        submit( 'ÅðéëïãÞ' )
    );
    print end_form;


I can't retrace that you can't see anything printed out by this.
  
> 
> and inside styles.css i have:
> 
> ========================
> td.tip {
>       font: 18px times;
>       color: cyan;
> }
> ========================

Err, your CSS class 'tip' is only defined for <td>-tags, and not for
<span>. Please fix that and it should work.

regards,
fabian


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

Date: Mon, 02 May 2005 10:03:33 GMT
From: Nick <please@touchmywilly.com>
Subject: Help with perl array
Message-Id: <VVmde.14922$qK3.6049@fe1.news.blueyonder.co.uk>

I have a partial perl script that i want to understand and then be able 
to change. It simply searches a text file for text and print that text 
to a web page. I want to understand the array and be able to add 
multiple more lines.

At the moment, it has two fields (surname and forename), i need to 
expand that to around 6 or 7 fields.

Ultimately, i want to be able to search a text file for specific text 
and have it output all matches (the complete line) to a web page.

Below is what i have so far:

#!/usr/bin/perl -w

use CGI;
use CGI::Carp qw(fatalsToBrowser);      # Hook errors to browser

#search_file.pl
read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});
$buffer =~ tr/+/ /;
$buffer =~ s/\r/ /g;
$buffer =~ s/\n/ /g;
@pairs = split(/&/,$buffer);
foreach $pair(@pairs){
($key,$value)=split(/=/,$pair);
$formdata{$key}.="$value";
}
$search=$formdata{'search'};

open(INFO, "names_file.txt"); # Open db for reading
@array=<INFO>;
close (INFO);

print "Content-type:text/html\n\n"; #Content Header

print <<End_of_head;
<html>
<head><title>Display File Contents</title></head>
<body>
<h4>This script displays the contents of names_file.txt.</h4>
End_of_head

foreach $line (@array){
if ($line =~ /$search/){
($last,$first)=split(/\|/,$line);
print <<End_of_line;
Your search returned: $first $last<br>
End_of_line
}
}

print <<End_of_Doc;
</body>
</html>
End_of_Doc


Any help much appreciated.

Nick


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

Date: Mon, 2 May 2005 01:43:10 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: REMOTE_HOST aint working
Message-Id: <3dl7q3F6ctb39U1@individual.net>

* Nikos schrieb:

> Fabian Pilkowski wrote:
> 
> Guys i just missed a line upon deletion of extra quotes when i
> replied, thats all.

Please quote properly. You call it carelessness, but why are you
careless about quoting? Don't you realize that your behaviour is
annoying other readers (and potential helpers)? Are you thinking
it doesn't matter? Please be more gentle to one who is trying to
help you.

And please, don't argue with us about that. Just do it! Be more
careful instead of careless.

thanks,
fabian


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

Date: Mon, 02 May 2005 02:53:42 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: REMOTE_HOST aint working
Message-Id: <-76dnSc0U-MxZejfRVn-oA@comcast.com>

Nikos wrote:

>> Yes. Read the dcoumentation for your web server.
> 
> I searched the docs. nothing relevant.

You didn't do a very good job looking for it.  It's right there,
listed as being part of the core configuration directives.
http://httpd.apache.org/docs/mod/core.html

	-Joe


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

Date: Mon, 02 May 2005 03:00:22 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: REMOTE_HOST aint working
Message-Id: <PsmdnbbO0e2lZ-jfRVn-pw@comcast.com>

Nikos wrote:
> This can be done also liek you said but that would require the use of an
> extra module that would have to be downloaded from CPAN.

Wrong!

'use Socket;' does *not* require downloading any modules from CPAN.

I suggest that you familiarize yourself with the list of modules
that come bundled in with the perl sources.
	-Joe


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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