[18946] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1141 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 15 14:05:47 2001

Date: Fri, 15 Jun 2001 11:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <992628311-v10-i1141@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Jun 2001     Volume: 10 Number: 1141

Today's topics:
    Re: A simple pattern match problem? (Sweth Chandramouli)
    Re: A simple pattern match problem? (Craig Berry)
    Re: A simple pattern match problem? <joe+usenet@sunstarsys.com>
    Re: A simple pattern match problem? <ren@tivoli.com>
    Re: A simple pattern match problem? (E.Chang)
    Re: Another possible need for a pattern match <ren@tivoli.com>
        Best way for batch renaming specific files <michael.segulja@kingwoodcable.net>
    Re: Best way for batch renaming specific files <mischief@velma.motion.net>
    Re: Calling executables <flavell@mail.cern.ch>
    Re: Calling executables (Rafael Garcia-Suarez)
    Re: Cookbook Socket 605 <bart.lateur@skynet.be>
    Re: Design pattern for a generic functions dispatcher <abe@ztreet.demon.nl>
    Re: Foreach Not Behaving Properly (long) <c_clarkson@hotmail.com>
    Re: Foreach Not Behaving Properly <ren@tivoli.com>
        How to pass parameter between two cgi programs??? <stingchung@kimo.com.tw>
    Re: How to pass parameter between two cgi programs??? <mischief@velma.motion.net>
    Re: HTML input box variables? <flavell@mail.cern.ch>
    Re: HTML input box variables? <alan@headru.sh>
    Re: Multiplexing stdin and stderr to screen and logfile (LMC)
        Perl for Palm <chbarr@shell.one.net>
        Printing filenames that are in a directory <springb2k@yahoo.com>
    Re: Printing filenames that are in a directory (E.Chang)
    Re: Printing filenames that are in a directory <ren@tivoli.com>
        quick array question <Martin.Bower@ib.bankgesellschaft.de>
    Re: quick array question (E.Chang)
    Re: quick array question <tony_curtis32@yahoo.com>
        replace with logic in Perl (Bal Paudyal)
    Re: replace with logic in Perl <bart.lateur@skynet.be>
    Re: replace with logic in Perl (E.Chang)
    Re: signals nobull@mail.com
        special characters <vrdoljak@uclink.berkeley.edu>
        Why is bare << deprecated ? <kjetil.skotheim@usit.uio.no>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Jun 2001 16:25:50 GMT
From: sweth+perl@gwu.edu (Sweth Chandramouli)
Subject: Re: A simple pattern match problem?
Message-Id: <iGqW6.82923$G5.17838268@news1.rdc1.md.home.com>

In article <tijb1deh8m9v54@corp.supernews.com>,
Craig Berry <cberry@cinenet.net> wrote:
>E.Chang (echang@netstorm.net) wrote:
>: cberry@cinenet.net (Craig Berry) wrote in
>: >   $string =~ tr/\n//s;
>: 
>: This is certainly the version to use, since it's much faster.  
>: 
>: Is this effect of /s  with a null replacement character documented 
>: anywhere?
>
>It's not an effect of /s, it's a general principle of tr///.  If the
>replacement string is shorter than the pattern string and /d isn't
>specified, then excess pattern characters translate to themselves.
	I thought that excess pattern chars translate to the last
replacement char:

$  echo 'ABCD' | perl -pe 'tr/ABCD/A/'
AAAA

	.  I could see tr/// interpreting "null replacement" as
"translate everything to itself", which when combined with /s would
produce the observed result; it's definitely not doing "excess pattern
translates to itself", though.

	-- Sweth.

-- 
Sweth Chandramouli ; <sweth+perl@gwu.edu>


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

Date: Fri, 15 Jun 2001 16:51:41 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: A simple pattern match problem?
Message-Id: <tikf8tn4oj35fa@corp.supernews.com>

E.Chang (echang@netstorm.net) wrote:
: Yes, the end-of line sent by the form is a CRLF pair.  On some 
: operating systems this is also the end of line character, but in Unix 
: the end of line character is just the LF.  A modification of the 
: revious suggestion Craig Berry would be 
: 
:     tr/\015\012/\n/s;

That won't work.  It translates \015 to \n, and leaves \012 unmodified,
whether or not the two appear adjacent to one another.  It also compacts
runs of \015 or \012 to single instances, but neither will be found in a
well-formed input field.  You probably want

  s/\015\012/\n/g;

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "Magick is the art and science of causing change in conformity
   |   with Will."  - Aleister Crowley


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

Date: 15 Jun 2001 13:11:28 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: A simple pattern match problem?
Message-Id: <m3ae39acsf.fsf@mumonkan.sunstarsys.com>

cberry@cinenet.net (Craig Berry) writes:

> E.Chang (echang@netstorm.net) wrote:
> : Yes, the end-of line sent by the form is a CRLF pair.  On some 
> : operating systems this is also the end of line character, but in Unix 
> : the end of line character is just the LF.  A modification of the 
> : revious suggestion Craig Berry would be 
> : 
> :     tr/\015\012/\n/s;
> 
> That won't work.  It translates \015 to \n, and leaves \012 unmodified,
                                                              ~~~~~~~~~~
ITYM "turns \012 into \n as well, and the s will squash them into a 
single "\n" should they appear together." So it seems to work OK after
all:

  % perl -wle '$_ = "\015\012"; tr/\015\012/\n/s; print map{ord}/./gs'
  10

  % perldoc perlop
                      ... If the "/s" modifier is specified,
               sequences of characters that were transliterated
               to the same character are squashed down to a
               single instance of the character.


               If the "/d" modifier is used, the REPLACEMENTLIST
               is always interpreted exactly as specified.
               Otherwise, if the REPLACEMENTLIST is shorter than
               the SEARCHLIST, the final character is replicated
               till it is long enough.  If the REPLACEMENTLIST is
               empty, the SEARCHLIST is replicated.  This latter
               is useful for counting characters in a class or
               for squashing character sequences in a class.

                ...

-- 
Joe Schaefer       "There are two times in a man's life when he should not
                    speculate: when he can't afford it, and when he can."
                                               --Mark Twain



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

Date: 15 Jun 2001 09:49:27 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: A simple pattern match problem?
Message-Id: <m366dxiyrs.fsf@dhcp9-173.support.tivoli.com>

On Fri, 15 Jun 2001, leapius@hotmail.com wrote:

> None of these methods seem to work for me. I think I should have
> been more clear in my application; This data is coming from a
> textbox in a form and I want to remove any blank lines the user
> inputs. These patern matches, although working for a normal string
> will simply refuse to work for the hash that is sent from the
> form. Is this something to do with "\r" as well?

Yes.

Depending on your ultimate goal, one of these may work for you:

tr/\n\r/\n/sd;        # if you don't need the "\r"-s, faster

or

s/\r\n(?=\r\n)//g;    # if you do need the "\r"-s, slower

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 15 Jun 2001 17:25:02 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: A simple pattern match problem?
Message-Id: <Xns90C18903AACE5echangnetstormnet@207.106.92.86>

cberry@cinenet.net (Craig Berry) wrote in
<tikf8tn4oj35fa@corp.supernews.com>: 

> E.Chang (echang@netstorm.net) wrote:
> : Yes, the end-of line sent by the form is a CRLF pair.  On some 
> : operating systems this is also the end of line character, but in
> Unix : the end of line character is just the LF.  A modification of
> the : revious suggestion Craig Berry would be 
> : 
> :     tr/\015\012/\n/s;
> 
> That won't work.  It translates \015 to \n, and leaves \012
> unmodified, whether or not the two appear adjacent to one another. 
> It also compacts runs of \015 or \012 to single instances, but
> neither will be found in a well-formed input field.  You probably
> want 
> 
>   s/\015\012/\n/g;

Are you sure?  I figured that after the CR is translated to \n there 
are then multiple contiguous newlines which are in turn squished 
together.  It does rely on \n being \012, which I believe is the OP's 
situation.  I tested with

$string1 = $string2 = 
  "line1\015\012\015\012line2\015\012\015\012line3";
$string1 =~ s/(\015\012)+/\n/g;
$string2 =~ tr/\015\012/\n/s;
print $string1 eq $string2, "\n";

as well as printing the modified strings and checking the total length, 
and the result was true.  I since checked substr($string2, 5, 1) and it 
does seem to be a newline.

-- 
EBC


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

Date: 15 Jun 2001 09:53:46 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Another possible need for a pattern match
Message-Id: <m31yoliykl.fsf@dhcp9-173.support.tivoli.com>

On Fri, 15 Jun 2001, leapius@hotmail.com wrote:

> I need to substitute a string with the equivalent number of stars
> "*".
> 
> E.g:
> 
> hello = *****
> love perl = *********

I didn't see my favorite solution posted, so here it is:

tr//*/c;

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 15 Jun 2001 12:14:31 -0500
From: "Michael Segulja" <michael.segulja@kingwoodcable.net>
Subject: Best way for batch renaming specific files
Message-Id: <3b2a407c$1_3@newsfeeds>

I have some files name filename.0001, filename.0002....filename.0450, etc.
I want to rename these files to filename.0001.tif,
filename.0002.tif....filename.0450.tif, but I'm not sure how.  I'm sure Perl
is the best solution for this since I'm running Linux, but I'm not a Perl
programmer.  Is this something that is easy enough to figure out with a
decent tutorial?  I'd like to learn how to do it, but I haven't found
anything on the Internet that is specific to something like this.

Can someobody give me a head start or some ideas on where to look?

Thank you very much,

Michael




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Fri, 15 Jun 2001 17:52:32 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Best way for batch renaming specific files
Message-Id: <tikir0lobk0uc0@corp.supernews.com>

Michael Segulja <michael.segulja@kingwoodcable.net> wrote:
> I have some files name filename.0001, filename.0002....filename.0450, etc.
> I want to rename these files to filename.0001.tif,
> filename.0002.tif....filename.0450.tif, but I'm not sure how.  I'm sure Perl

$file_name = s/(.)/$1\.tif/g;


> is the best solution for this since I'm running Linux, but I'm not a Perl
> programmer.  Is this something that is easy enough to figure out with a
> decent tutorial?  I'd like to learn how to do it, but I haven't found
> anything on the Internet that is specific to something like this.

> Can someobody give me a head start or some ideas on where to look?

Try this command from your prompt:
    perldoc perlop

Chris

-- 
The purpose of a language is not to help you learn the
language, but to help you learn other things by using the
language. --Larry Wall, The Culture of Perl, August 1997



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

Date: Fri, 15 Jun 2001 16:57:36 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Calling executables
Message-Id: <Pine.LNX.4.30.0106151654400.11135-100000@lxplus003.cern.ch>

On 15 Jun 2001, Igal Corcos wrote:

> Is there another way to call executable programs from a Perl script
> besides system(LIST) (or exec); ?

High time to make the acquaintance of the Perl documentation.

Part 1: FAQs.

perldoc -q system

  "Why can't I get the output of a command with system()?"

Part 2: Perl functions

perldoc -f system

               This is not what you
               want to use to capture the output from a command,
               for that you should use merely backticks or
               `qx//'

Have fun



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

Date: 15 Jun 2001 13:45:45 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Calling executables
Message-Id: <slrn9ik4dl.9ak.rgarciasuarez@rafael.kazibao.net>

Igal Corcos wrote in comp.lang.perl.misc:
} Is there another way to call executable programs from a Perl script
} besides system(LIST) (or exec); ?

Strange question. You should describe more precisely your problem if you
want an accurate answer (...how to call an executable and get some kind
of result / information / behavior...)

Shortly : yes, there are other ways. There's the backquote operator
(search for "qx" in perlop) and the open() function (see "Pipe Opens" in
perlopentut).

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Fri, 15 Jun 2001 15:36:55 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Cookbook Socket 605
Message-Id: <6sakit8h5h9qub5qf61f58cpkr03v17nd1@4ax.com>

spurcell wrote:

>All has worked solidly for talking to another box for a year. I have the
>need to actually create the Handle and pass it to another routine. I have
>always used a global for the past year, but as I am fixing up some old code,
>I am using strict and do not want to make it a global.
>
>If I have the following line in a sub called makeSocket()
>sub makeSocket {
>my $handle = IO::Socket::INET->new(PeerAddr => "XXX.XXX.XXX.XXX",PeerPort =>
>'8xxx') or die $@;
>}
>
>and later on  I want to print to that handle in another sub
>sub askProduct {
>    my $msg = "\%BEGIN\tHello What A Good Day You Are Having";
>   print $handle "$msg";
>}

What is wrong wit ha global? You WANT a global.

Well alright, have it your way. Declare the variable $handle with "my"
outside of the sub, in front of where you first use it.

It's almost the same as a global, except that you cannot access it from
in another file.

-- 
	Bart.


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

Date: Fri, 15 Jun 2001 17:05:56 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Design pattern for a generic functions dispatcher
Message-Id: <lc7kitg4gn09gqn0q3e85ndkg7vfdkajfe@4ax.com>

On Fri, 15 Jun 2001 11:16:22 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

> Abe Timmerman wrote:
> 
> >my %action_map = (
> >	ACTION1 => 'MyModule::SubModule::Myfunction',
> >	ACTION2 => 'MyOtherModule::MyOtherFunction',
> >);
> 
> I prefer sub refs.
> 
> my %action_map = (
> 	ACTION1 => \&MyModule::SubModule::Myfunction,
> 	ACTION2 => \&MyOtherModule::MyOtherFunction,
> );

So do I, but they will only work if the module in question is loaded.

The OP wanted dynamic loading to avoid loading all modules when only one
is needed per invocation of the program.

-- 
Good luck, Abe
Amsterdam Perl Mongers http://amsterdam.pm.org
perl -we '$_="rekcah lreP rehtona tsuJ";print$2while s/(.*)(.)/$1/g'


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

Date: Fri, 15 Jun 2001 11:37:08 -0500
From: "Charles K. Clarkson" <c_clarkson@hotmail.com>
Subject: Re: Foreach Not Behaving Properly (long)
Message-Id: <B2CDF597D1F140AC.4F45768BCC1A14E7.5706D7E95198E298@lp.airnews.net>

Barry Allwood <barryallwood@aol.com> wrote

: Hey,
:
: I am making a news script not to similar to newspro
: and I was wondering why when I use 2 foreach loops
: to display news I get an extra box
: (http://www.sky-scraper.net/phoenix/bpnews2.cgi) at
: the bottom, here is the code if you need it
:
: #!/usr/bin/perl
: require "bpcs.pl";
: print "Content-type: text/html\n\n";
: &Parse(\%in);
: $AID = $in{'AID'};
:
: open (NEWS, "< news.txt") or &die("crappy shit");
: @article = <NEWS>;
: close (NEWS);
:

    A look at Barry's site revealed the secretive
news.txt contained:

1:x:Wooohooo!:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:0:x:0
2:x:Wrong Statement:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:1:x:1
3:x:Number3:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:0:x:0
4:x:Number4:x:Yes This Fantastic Thing Actually
Works!:x:ElBazo:x:25/05/01:x:0:x:1

: foreach (@article) {
: my ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:             $NewsDate, $Display, $Bump) = split /:x:/;
: &NewsTemplate(@article) if (($AID == '') &&
:             ($Display == 0)) && ($Bump == 1);
: }
:
: foreach (@article) {
: my ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:           $NewsDate, $Display, $Bump) = split /:x:/;
: if ($AID == $NewsAID) {
: #Print The Returned Article
: &NewsTemplate(@article) unless ($Display == 1);
: } elsif ($AID != $NewsAID) {
: #Do Nothing, It Does Not Return A Value
: }
:
: #Print All Of The Articles if There is no submission
: #in the AID
: &NewsTemplate(@article) if (($AID == '') &&
:            ($Display == 0)) && ($Bump == 0);
: }
:
    Then, after some coercion, Barry added:

: Oki, here is the sub, and the AID is a specific
: article, if you do this in the Url ?AID=2 it
: will show article 2
:
: sub NewsTemplate {
:
: $_ = ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:         $NewsDate, $Display, $Bump) = split /:x:/;
:
: open(TEMPLATE, "article.tmpl") or
:             die "can't open article.tmpl: $!";
:     local($/) = undef;
:     my $ArticleOut = <TEMPLATE>;
:     close(TEMPLATE);
:     $ArticleOut =~ s/\$BP_NewsText/$NewsText/g;
:     $ArticleOut =~ s/\$BP_NewsDate/$NewsDate/g;
:     $ArticleOut =~ s/\$BP_NewsPerson/$NewsPerson/g;
:     $ArticleOut =~ s/\$BP_NewsTitle/$NewsTitle/g;
:     print $ArticleOut;
:
: }

    Further investigation showed that the top secret
file article.tmpl contained some rather misshapened
HTML. No offense, Barry, but if you program as well
as you ask questions, you may want to seek another
profession.

    The question:
: I am making a news script not to similar to
: newspro and I was wondering why when I use 2
: foreach loops to display news I get an extra box
: (http://www.sky-scraper.net/phoenix/bpnews2.cgi)
: at the bottom, here is the code if you need it

    Well, the problem isn't with the foreach. It's
a problem with the subroutine 'NewsTemplate'. The
first line is:

: $_ = ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:         $NewsDate, $Display, $Bump) = split /:x:/;

<rant>
    Never, never, never, never, never, never, never,
never, never, never, never, never, never, rely on
the value in $_ to pass values to a subroutine.
</rant>

    Now, that split is working on $_, but do you
know what is in $_ each time we enter the sub?

    I did a quick test and found:
$_ = 4:x:Number4:x:Yes This Fantast . . .
$_ = 1:x:Wooohooo!:x:Yes This Fanta . . .
$_ = 3:x:Number3:x:Yes This Fantast . . .
$_ = 7

    before each box printed. Where did the 7 come
from? Believe it or not, it's left over from this
sub. Changing that first line to:

: ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:         $NewsDate, $Display, $Bump) = split /:x:/;

    seems to fix the extra box problem, but you're
still relying on $_ in the split. The curious
thing is you already did this split *before* you
entered the sub:

: my ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:             $NewsDate, $Display, $Bump) = split /:x:/;
: &NewsTemplate(@article) if (($AID == '') &&
:            ($Display == 0)) && ($Bump == 0);

<rant>
    It's probably not a good habit to call subs
with the '&' prefix. It's a handy way to circumvent
prototyping and doesn't hurt anything here. It's
just not a good habit. Leave it to the experts.
</rant>

    I first noticed that @article is being passed
with each call to NewsTemplate, but the sub doesn't
use article array, all we need is: $NewsTitle,
$NewsText, $NewsPerson, and $NewsDate. So let's
just pass those:

: NewsTemplate($NewsTitle, $NewsText,
:    $NewsPerson, $NewsDate) if $AID == '' &&
:            $Display == 0 && $Bump == 0;

Then we can change:

: sub NewsTemplate {
:
: $_ = ($NewsAID, $NewsTitle, $NewsText, $NewsPerson,
:         $NewsDate, $Display, $Bump) = split /:x:/;

to:

: sub NewsTemplate {
:
: my ($NewsTitle, $NewsText, $NewsPerson, $NewsDate) = @_;

    Now, we're not relying on $_ to pass values.


    BTW, Every time NewsTemplate is called
article.tmpl is read in. It would be faster if you
read it in once and used $ArticleOut as a global or
passed it in with the call to NewsTemplate:

    Near where news.txt gets opened place:

: open(TEMPLATE, 'article.tmpl') or
:             die "can't open article.tmpl: $!";
:     read TEMPLATE, my $template, -s TEMPLATE;
: close(TEMPLATE);

    Then call NewsTemplate with:

: NewsTemplate($template, $NewsTitle, $NewsText,
:    $NewsPerson, $NewsDate) . . .

    And start NewsTemplate with:

: sub NewsTemplate {
: my $ArticleOut = shift;
: my ($NewsTitle, $NewsText, $NewsPerson, $NewsDate) = @_;


HTH,
Charles K. Clarkson
Clarkson Energy Homes, Inc.


He who laughs last thinks slowest.





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

Date: 15 Jun 2001 10:28:29 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Foreach Not Behaving Properly
Message-Id: <m3wv6dhiea.fsf@dhcp9-173.support.tivoli.com>

On 12 Jun 2001, barryallwood@aol.com wrote:

> I am making a news script not to similar to newspro and I was
> wondering why when I use 2 foreach loops to display news I get an
> extra box (http://www.sky-scraper.net/phoenix/bpnews2.cgi) at the
> bottom, here is the code if you need it
> 
> #!/usr/bin/perl
> 
> require "bpcs.pl";
> 
> print "Content-type: text/html\n\n"; 
> 
> &Parse(\%in);
> 
> $AID = $in{'AID'};
> 
> open (NEWS, "< news.txt") or &die("crappy shit");
> @article = <NEWS>; 
> close (NEWS);
> 
> foreach (@article) { my ($NewsAID, $NewsTitle, $NewsText,
> $NewsPerson, $NewsDate, $Display, $Bump) = split /:x:/;
> 
> &NewsTemplate(@article) if (($AID == '') && ($Display == 0)) &&
> ($Bump == 1); }

Passing @article to NewsTemplate() from within the foreach over
@article seems like a very strange thing to do.  From your subsequent
post of the NewsTemplate() code, it uses $_ and doesn't do anything
with @_, so passing @article isn't causing a problem.  But neither is
it needed.  As things are, you could simply remove @article from the
argument list for NewsTemplate(), though I would prefer passing $_
explicitly instead (and modifying NewsTemplate() appropriately).

In any event, that's not causing the problem.

> foreach (@article) {
> 
> my ($NewsAID, $NewsTitle, $NewsText, $NewsPerson, $NewsDate,
> $Display, $Bump) = split /:x:/;
> 
> if ($AID == $NewsAID) { 
> 
> #Print The Returned Article
> &NewsTemplate(@article) unless ($Display == 1);
> 
> } elsif ($AID != $NewsAID) {
> #Do Nothing, It Does Not Return A Value 
> }
> 
> #Print All Of The Articles if There is no submission in the AID
> &NewsTemplate(@article) if (($AID == '') && ($Display == 0)) &&
> ($Bump == 0); }

Ah, here we go.  You're calling NewsTemplate an extra time at the end,
but $_ isn't set to anything, so the template is going to be blank.  I
expect this stems from confusion engendered by uselessly passing
@article.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 16 Jun 2001 01:24:15 +0800
From: Have a nice day! <stingchung@kimo.com.tw>
Subject: How to pass parameter between two cgi programs???
Message-Id: <63hkitcpvepf8nb9bti6pj4q38sg8f63ae@4ax.com>

How can I pass parameter from a cgi program to another cgi program???

thanks a lot!!!


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

Date: Fri, 15 Jun 2001 17:55:17 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: How to pass parameter between two cgi programs???
Message-Id: <tikj05mkqqej12@corp.supernews.com>

Have a nice day! <stingchung@kimo.com.tw> wrote:
> How can I pass parameter from a cgi program to another cgi program???

1) as a cookie
2) as a hidden form field
3) in a temporary file keyed by some other info
4) by using a session management module
5) in a database, keyed by some other info
6) search for 'session' and 'cgi' on CPAN and Google Groups, and
   read up

Chris

-- 
For the pleasure of others, please adhere to the following
rules when visiting your park:
    No swimming.  No fishing.  No flying kites.  No frisbees.
    No audio equipment. Stay off grass.  No pets. No running.



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

Date: Fri, 15 Jun 2001 16:53:18 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: HTML input box variables?
Message-Id: <Pine.LNX.4.30.0106151625070.11135-100000@lxplus003.cern.ch>

On Fri, 15 Jun 2001, alan@ wrote:

> Hi, here you go :-
>
> #!/usr/bin/perl

Bang!




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

Date: Fri, 15 Jun 2001 18:34:58 +0100
From: "alan@" <alan@headru.sh>
Subject: Re: HTML input box variables?
Message-Id: <9gdgu7$q11$1@newsg3.svr.pol.co.uk>


Alan J. Flavell <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.30.0106151625070.11135-100000@lxplus003.cern.ch...
> On Fri, 15 Jun 2001, alan@ wrote:
>
> > Hi, here you go :-
> >
> > #!/usr/bin/perl
>
> Bang!
>
>

Is that good Bang or bad Bang ?





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

Date: Fri, 15 Jun 2001 13:58:29 -0400
From: "Antoine Beaupre (LMC)" <Antoine.Beaupre@lmc.ericsson.se>
Subject: Re: Multiplexing stdin and stderr to screen and logfile
Message-Id: <3B2A4CC5.5010708@lmc.ericsson.se>


Hi.

Actually there's "script" on FreeBSD that does just that: log 
transparently everything.

However, it spawns a shell. It is not exactly what I am looking for. And 
it's not all portable..

For the record, I have been able to make it work properly.

I already had wrapper functions for print (doing auto newline 
completion, "verbosity handling", etc) so changing the print to syswrite 
was a 2 line diff. :)

Thanks anyways.

A.

John W. Krahn wrote:

> Benjamin Goldberg wrote:
> 
>>This isn't a perl solution, but isn't there a unix program called "type"
>>or somesuch which creates a tty, handles all stdin, stdout, and stderr
>>for the program given on the commandline, even allowing normal
>>interaction with a user?
> 
> Are you thinking of "expect"?
> 
> 
> John
> 



-- 
--
La sémantique est la gravité de l'abstraction.



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

Date: Fri, 15 Jun 2001 15:25:09 -0000
From: Charles Barilleaux <chbarr@shell.one.net>
Subject: Perl for Palm
Message-Id: <tika6lthe3k8e2@corp.supernews.com>

Hi!

I was wondering: I've been a Perl user for almost 10 years, but just got
my first Palm PDA (OK, a Visor). I've seen a few events happen:

* Perl for CE released
* Allusions to having Perl on Palm in various Perl.com articles.

So, I have to wonder: how close are we to Perl on the Palm? Are there any
mailing lists or web sites about the present effort?

thanks,
Charles
chbarr@one.net


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

Date: Fri, 15 Jun 2001 08:25:49 -0700
From: "Mr. Ed" <springb2k@yahoo.com>
Subject: Printing filenames that are in a directory
Message-Id: <tika2dotnniu9b@corp.supernews.com>

I'm trying to print filenames (on my DOS prompt, but eventually to a
textfile) from a directory I'm opening, there are a couple of files in the
directory I'm trying to open. Instead of printing the names of my files, I
get a numeral : 61 in my print response. Below is the code:

opendir THISDIR, "." or die "FATAL Problem with opening directory: $!";
@allfiles = readdir THISDIR;
$allfiles=@allfiles; $filecounter=0;
print $allfiles;#trying to print filenames
close THISDIR;

What may I be doing wrong?

Thanks
Ed





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

Date: Fri, 15 Jun 2001 15:54:12 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: Printing filenames that are in a directory
Message-Id: <Xns90C1799D77559echangnetstormnet@207.106.92.86>

"Mr. Ed" <springb2k@yahoo.com> wrote in
<tika2dotnniu9b@corp.supernews.com>: 

> I'm trying to print filenames (on my DOS prompt, but eventually to
> a textfile) from a directory I'm opening, there are a couple of
> files in the directory I'm trying to open. Instead of printing the
> names of my files, I get a numeral : 61 in my print response. Below
> is the code: 
> 
> opendir THISDIR, "." or die "FATAL Problem with opening directory: 
>$!"; 
> @allfiles = readdir THISDIR;
> $allfiles=@allfiles; $filecounter=0;

The assignment to a scalar means @allfiles is bing used in scalar 
context.  $allfiles is the number of elements in @alllfiles.  You can 
to iterate over the elements of @allfiles.

> print $allfiles;#trying to print filenames

   foreach (@allfiles) {
        print "$_\n";
   }

Or combine the elements into a single string.  It's much faster than 
the loop.

   print join "\n", @allfiles;

If you simply use 

   print "@allfiles";

the file names will be printed separated by a single space.

> close THISDIR;

   closedir THISDIR;

(Question to the experts:  Does it make a difference?)

-- 
EBC


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

Date: 15 Jun 2001 10:59:23 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Printing filenames that are in a directory
Message-Id: <m3ofrphgys.fsf@dhcp9-173.support.tivoli.com>

On Fri, 15 Jun 2001, springb2k@yahoo.com wrote:

> I'm trying to print filenames (on my DOS prompt, but eventually to a
> textfile) from a directory I'm opening, there are a couple of files
> in the directory I'm trying to open. Instead of printing the names
> of my files, I get a numeral : 61 in my print response. Below is the
> code:
> 
> opendir THISDIR, "." or die "FATAL Problem with opening directory: $!";
> @allfiles = readdir THISDIR;
> $allfiles=@allfiles; $filecounter=0;

The problem is here.  In scalar context, as @allfiles is here when
being assigned to $allfiles, an array returns its size.  So $allfiles
gets the size of @allfiles.  You might want:

$allfiles = "@allfiles";

though you could just print that directly:

print "@allfiles";

In a double-quoted string, an array is expanded and joined with the
value of $", which is a space by default.

For that matter, you could do the join explicitly and print the
readdir results directly:

print join " ", readdir THISDIR;

> print $allfiles;#trying to print filenames
> close THISDIR;

Note that if you'd like the files printed one per line, then I find
this construct slightly better than the join:

print "$_\n" for readdir THISDIR;

so that the final element also gets a newline.  You could still use
the join and just pass an extra empty element at the end.  Since
readdir is a unary operator, this works:

print join "\n" readdir THISDIR, "";

though it seems overly difficult for humans to parse correctly.

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 15 Jun 2001 17:52:21 +0200
From: Martin Bower <Martin.Bower@ib.bankgesellschaft.de>
Subject: quick array question
Message-Id: <3B2A2F35.6C28A57@ib.bankgesellschaft.de>

I have an array @rows    , and each row contains a number of "~"
seperated fields.
e.g     "first~second~name~end" , "first~last"

is there a quick way to tell the highest number of fields for the entire
array ?





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

Date: Fri, 15 Jun 2001 16:21:12 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: quick array question
Message-Id: <Xns90C17E311BC5Dechangnetstormnet@207.106.92.86>

Martin Bower <Martin.Bower@ib.bankgesellschaft.de> wrote in
<3B2A2F35.6C28A57@ib.bankgesellschaft.de>: 

> I have an array @rows    , and each row contains a number of "~"
> seperated fields.
> e.g     "first~second~name~end" , "first~last"
> 
> is there a quick way to tell the highest number of fields for the
> entire array ?

Here's one way - simple though not necessarily the quickest.

   @rows = ("A~B~C~D", "A~B~C~D~E", "A~B");
   my $fields;
   foreach (@rows) {
      $fields = $tildes if (my $tildes = tr/~/~/) > $fields;
   }
   print $fields+1;

Output is 5.

-- 
EBC
The cat said there's a rat in separate.


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

Date: 15 Jun 2001 11:25:40 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: quick array question
Message-Id: <87n179iubf.fsf@limey.hpcc.uh.edu>

>> On Fri, 15 Jun 2001 17:52:21 +0200,
>> Martin Bower <Martin.Bower@ib.bankgesellschaft.de> said:

> I have an array @rows , and each row contains a number
> of "~" seperated fields.  e.g "first~second~name~end" ,
> "first~last"

> is there a quick way to tell the highest number of
> fields for the entire array ?

Unless you're encapsulating some meta-data about the array
somewhere, you won't do better than a linear scan of all
the array elements (and quadratic overall because you have
to scan all the individual elements to count the fields).

You might want to describe what this data is modelling, it
feels like there should be a better data structure
(e.g. LoL).

hth
t
-- 
Just reach into these holes.  I use a carrot.


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

Date: 15 Jun 2001 08:32:50 -0700
From: balpaudl@iohk.com (Bal Paudyal)
Subject: replace with logic in Perl
Message-Id: <82c9c59d.0106150732.3d0ab8e3@posting.google.com>

Hi everybody!

Let's say I have a string.
$_="$$&&&&abc&&&??? action someone@party.com- emailing is not easy!";

I would like to replace all non word with a space except @ and dot. If I did

s/\W/ /g; #it will also replace @ and dot.

Any one line solution?
I had to do something pretty crazy looking things like
s/'/ /g; s/\#/ /g ; and whole lot of them!

Thanks!
Bal


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

Date: Fri, 15 Jun 2001 15:59:20 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: replace with logic in Perl
Message-Id: <f5ckit0pcb48oqn2kreu959q4lhaqffvfo@4ax.com>

Bal Paudyal wrote:

>Let's say I have a string.
>$_="$$&&&&abc&&&??? action someone@party.com- emailing is not easy!";
>
>I would like to replace all non word with a space except @ and dot. If I did
>
>s/\W/ /g; #it will also replace @ and dot.

	s/[^\w\@.]/ /g;

-- 
	Bart.


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

Date: Fri, 15 Jun 2001 16:06:50 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: replace with logic in Perl
Message-Id: <Xns90C17BC1D9EE5echangnetstormnet@207.106.92.86>

balpaudl@iohk.com (Bal Paudyal) wrote in
<82c9c59d.0106150732.3d0ab8e3@posting.google.com>: 

> Hi everybody!
> 
> Let's say I have a string.
> $_="$$&&&&abc&&&??? action someone@party.com- emailing is not
> easy!"; 


$ and @ have special meaning, and $$ is a special variable.  Use single 
quotes or escape those characters.

> I would like to replace all non word with a space except @ and dot.
> If I did 
> 
> s/\W/ /g; #it will also replace @ and dot.

make a character class that negates the characters you want.

   s/[^\w.@]/ /g;

-- 
EBC


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

Date: 15 Jun 2001 17:13:54 +0100
From: nobull@mail.com
Subject: Re: signals
Message-Id: <u97kyd201p.fsf@wcl-l.bham.ac.uk>

"Todd Smith" <todd@designsouth.net> writes:

> Subject: signals

Huh?  One usually uses the subject line to describe the nature of ones
question not to put the answer.  This is an interesting variation on
the concept of jeopardy-posting.

> How do I make perl run a subroutine instead of printing out an error message
> if the script dies? And I don't mean on a 'die', I mean if it has an error
> that I wasn't aware of (but still compiles).

Well, a signal handler is one way but I think you'd be better of
wrapping the whole thing in eval {}.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Fri, 15 Jun 2001 10:51:20 -0700
From: Gordon Vrdoljak <vrdoljak@uclink.berkeley.edu>
Subject: special characters
Message-Id: <3B2A4B18.11E1C8CF@uclink.berkeley.edu>

Hello,
I was working on a program to read in materials from a text file, generate a
form, and then with a seperate cgi script, attach prices to the materials.  I
spent an hour figuring out that if I have '()' characters in the material file,
it won't match (ie $variable =~ /^$searchvar/; won't work if I have ()'s in
$variable).

I was wondering what other special characters I should watch out for or exclude,
or if there are any ways around this.
Gordon

-- 
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
Gordon Ante Vrdoljak                                  Electron Microscope Lab
ICQ 23243541   http://nature.berkeley.edu/~gvrdolja   26 Giannini Hall
vrdoljak@uclink.berkeley.edu                          UC Berkeley
phone (510) 642-2085                                  Berkeley CA 94720-3330
fax   (510) 643-6207 cell (510) 290-6793


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

Date: Fri, 15 Jun 2001 16:39:43 GMT
From: Kjetil Skotheim <kjetil.skotheim@usit.uio.no>
Subject: Why is bare << deprecated ?
Message-Id: <1103_992623183@f3bpc14>

Why is bare << deprecated?
perl -we '$a=<<;'







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

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


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