[25846] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8081 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 15 11:05:40 2005

Date: Sun, 15 May 2005 08: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           Sun, 15 May 2005     Volume: 10 Number: 8081

Today's topics:
        arrays <bob_then@yahoo.com.au>
    Re: arrays <noreply@gunnar.cc>
    Re: arrays <jurgenex@hotmail.com>
        how do I remove comma in a string <hari@pillai.co.uk>
    Re: how do I remove comma in a string <noreply@gunnar.cc>
    Re: Perl generated navigation menu <joe@inwap.com>
    Re: query = new CGI; <pilkowsk@informatik.uni-marburg.de>
    Re: Regex not matching <joe@inwap.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 15 May 2005 20:57:49 +1000
From: "Bob Then" <bob_then@yahoo.com.au>
Subject: arrays
Message-Id: <42872b26$1@dnews.tpgi.com.au>

If I have an array of 127 elements some with number and most empty how can I
filter the empty ones out I tried using /^\d/ but it didn't work




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

Date: Sun, 15 May 2005 12:58:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: arrays
Message-Id: <3eop7mF417uvU1@individual.net>

Bob Then wrote:
> If I have an array of 127 elements some with number and most empty how can I
> filter the empty ones out I tried using /^\d/ but it didn't work

First: Please study the posting guidelines for this group: 
http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html

They contain useful tips about how to ask a question here in a way that 
makes it easy to help.

The solution to your problem may be found in

     perldoc -f grep

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 15 May 2005 13:02:41 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: arrays
Message-Id: <RLHhe.2627$pb1.164@trnddc08>

Bob Then wrote:
> If I have an array of 127 elements some with number and most empty
> how can I filter the empty ones out I tried using /^\d/ but it didn't
> work

See "perldoc perlfunc". It has a section "Perl Functions by Category".
Does any of the functions listed for arrays or lists sound like it might do 
what you are looking for?
Maybe a similar name as a popular Unix command (hint, hint)?

For details see "perldoc -f grep".

jue 




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

Date: Sun, 15 May 2005 10:55:51 +0000 (UTC)
From: "Harry" <hari@pillai.co.uk>
Subject: how do I remove comma in a string
Message-Id: <d679rn$lfd$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>

Hi,
I have value - 7,3433,2343,212, would like to remove the the ,(comma) - and 
read to do some calcuations.

How do I do this pls

thanks
Hari




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

Date: Sun, 15 May 2005 12:52:43 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: how do I remove comma in a string
Message-Id: <3eoosjF470gkU1@individual.net>

Harry wrote:
> I have value - 7,3433,2343,212, would like to remove the the ,(comma)

Use the tr/// operator, described in "perldoc perlop".

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Sun, 15 May 2005 02:45:29 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Perl generated navigation menu
Message-Id: <KfadnaiEcZ2khxrfRVn-hg@comcast.com>

Michael wrote:

>      <li class="in_group"><a href="z3.html">Aquatic Creatures</a>
>         <ul>
>           <li class="this_URL"><a href="z4.html">Pretty Fish</a></li>
>           <li class="in_group"><a href="z5.html">Don't Eat</a></li>
>         </ul>
>      </li>

That matches #10 in the "Ten Most Violated Homepage Design Guidelines"
in http://www.useit.com/alertbox/20031110.html .

When you are generating z4.html, the middle line should be:

     <li class="this_URL"><b>Pretty Fish</b></li>

> It is obviously necessary know which URL is accessed, ...

No, you are creating files, and you know the name of the file that
you are creating (such as "z4.html").  This is not the case of
accessing a URL, it is the case of creating a file that will
become the target of a URL.

> How can a current URL or filename portion be accessed in Perl?

Your question would be appropriate if you were writing a CGI
to process data on the fly.  But the rest of your post implies
creating static HTML files offline, then uploading them to a
web server.

> Any ideas including code snippets (or chunks) would be greatly appreciated,
> especially with regards to transforming the above arrays into the
> examplified html structure, perhaps by using a for loop?

It is simple: use a for() loop to generate your html.
Show us what you've tried so far and we can critique it for you.

But if you are saying that you've never used a for() loop before,
this is the wrong place to be posting.  Learn the basics first,
ask for help only after you can show putting significant effort
into the task.
	-Joe


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

Date: Sun, 15 May 2005 15:02:33 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: query = new CGI;
Message-Id: <3eovifF48rgmU1@individual.net>

* A. Sinan Unur schrieb:
> "CS" <cprevra@satx.rr.com> wrote
>> 
>> print "<html><head><title>A test</title></head\n";
>> print "<body>The test was successful</body></html>";
> 
> AFAIK, that is not valid HTML.
> 
> print <<HTML;
> <html>
> <head>
> <title>A Test</title>
> </head>
> <body>
> <p>The test was successful</p>
> </body>
> </html>
> HTML

But this isn't valid HTML too. You want to point out the difference
between "transitional" and "strict" HTML. The first is almost valid for
the "transitional" DTD, yours is almost valid for the "strict" one. But
in both cases there is no DOCTYPE header as urgent required for "valid
HTML", AFAIK.

I suggest to use CGI.pm's method start_html() if valid HTML is required.
If you really want to do the HTML part *by hand* learn more about HTML's
validness first ;-)

regards,
fabian


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

Date: Sun, 15 May 2005 02:14:16 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: Regex not matching
Message-Id: <dbWdneVeSud2jxrfRVn-2g@comcast.com>

Andrew DeFaria wrote:
> Ignoramus4744 wrote:
>> it did not fail, it successfuly mapped \d* to an empty string.
> 
> OK why didn't it match it to 80 like the first pattern did? Why is it 
> required to have the "=" and the space in the pattern? Why wouldn't ".*" 
> suck that up?

/^#.*(\d*)/ = Match '#' at the beginning of the line, followed
by any number of characters (as much as possible) followed by
zero or more digits.  The greediness of the '.*' ate up everything,
including '80', which allowed (forced) \d* to match zero digits.

/^#.*(\d+)/ = Match '#' at the beginning of the line, followed
by any number of characters (as much as possible) followed by
one or more digits.  The greediness of the '.*' grab everything
possible, as long as it leaves one digit left over for \d+.  This
means that '8' is included in .* and only '0' is picked up by \d+.

/^#.*?(\d+)/ = Match '#' at the beginning of the line, followed
by as few as characters as possible to allow the rest of the regex
to match.  This means that \d+ will match '80'.  (Using \d* would also
match '80' in this case.)

Two things to remember:
  1) Use \d+ instead of \d* to avoid matching zero digits.
  2) .* is greedy; it will swallow up everything possible.  Only if
     there is more to match will it accept less than everything.

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


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