[17019] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4431 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 26 06:10:21 2000

Date: Tue, 26 Sep 2000 03:10: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: <969963010-v9-i4431@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 26 Sep 2000     Volume: 9 Number: 4431

Today's topics:
    Re: parameter passing problem <elephant@squirrelgroup.com>
    Re: Portability of Perl/Tk programs? <tye@metronet.com>
        Portable equivalent of `cat`? <ter@my-deja.com>
    Re: Portable equivalent of `cat`? (Rafael Garcia-Suarez)
    Re: References and local (Abigail)
        regex with undefined variable <news@#nospam#althepal.com>
    Re: regex with undefined variable nobull@mail.com
        rookie: How do I get regex results into array? <NIXSPAMdrh@engineer.com>
    Re: rookie: How do I get regex results into array? nobull@mail.com
        sendmail <ldbarlet@email.msn.com>
    Re: sendmail (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Tue, 26 Sep 2000 15:36:16 +1000
From: jason <elephant@squirrelgroup.com>
Subject: Re: parameter passing problem
Message-Id: <MPG.143ae0dec9c6725b9897cc@localhost>

orassilv wrote ..
>Environment:
>nt4.0,
>perl is in my path,
>running from a msdos command line.
>
>Have a file called test.pl with the following:
>   print "Hello world \n";
>   print "@ARGV \n";
>   print "First arg: $ARGV[0] \n";
>   print "Second arg: $ARGV[1] \n";
>
>When I call it with test.pl p1 p2 from the command line I get:
>Hello world
>
>First arg:
>Second arg:
>
>When I call it with perl test.pl p1 p2 from the command line I get:
>Hello world
> p1 p2
>First arg: p1
>Second arg: p2
>
>Why do I need to explicity call test.pl using "perl test.pl p1 p2" in order
>to get my parameters passed correctly into test.pl?

because your .pl file association is setup incorrectly .. I don't know 
which version of perl you're using .. but the latest 5.6 release makes 
the correct association .. so - three choices

1) keep doing the "perl program.pl parameters" thing

2) install the latest perl from ActiveState

3) adjust the association yourself .. from Explorer go to View > Options 
> File Types tab .. then in the "Registered file types" window scroll 
down to the "Perl File" entry .. highlight it - click Edit .. highlight 
the "Open" entry in the Actions window - click Edit and change the 
command line to

  drive:\path\to\perl\bin\Perl.exe "%1" %*

note the double quoted %1 (that's the filename of the perl program - 
double quotes to allow spaces in the filename) .. then the %* which is 
any number of parameters

QED

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: 25 Sep 2000 08:01:42 -0500
From: Tye McQueen <tye@metronet.com>
Subject: Re: Portability of Perl/Tk programs?
Message-Id: <8qnibn$pau@beanix.metronet.com>

) In article <m3og1isgif.fsf@solo.david-steuber.com>,
) 	David Steuber <nospam@david-steuber.com> writes:
) > I'm considering using Perl/Tk for an application that will use a GUI
) > [...]
) > I already know that there is no fork in Windows.

clintp@geeksalad.org (Clinton A. Pierce) writes:
) 
) Bzzzt.  Wrong.  Has been since 5.6. 

But there is no "reliable fork() in Windows".  It is pretty easy
to get the fork() in Perl 5.6.0 to fail rather colorfully.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Tue, 26 Sep 2000 08:50:52 GMT
From: Tim Richardson <ter@my-deja.com>
Subject: Portable equivalent of `cat`?
Message-Id: <8qpo17$v2h$1@nnrp1.deja.com>

 In a script I want to send the contents of a file to stdout.
I wonder if there is a portable way of doing this better than slurping
the file into a variable and printing the variable, portable meaning a
solution that can be run without system calls to 'cat' and its
equivalents. File::Copy seems to be one solution. The problem seems so
trivial, I wonder if I'm missing something.

This is for a cgi script, and the system function may be prevented
anyway, if the script is running on a Windows server using isapi which
therefore bans system calls since perl shares the server process.



--
Tim Richardson
(search string: qweeblebeast)


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 26 Sep 2000 09:50:12 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Portable equivalent of `cat`?
Message-Id: <slrn8t0sn3.e53.rgarciasuarez@rafael.kazibao.net>

Tim Richardson wrote in comp.lang.perl.misc:
> In a script I want to send the contents of a file to stdout.
>I wonder if there is a portable way of doing this better than slurping
>the file into a variable and printing the variable, portable meaning a
>solution that can be run without system calls to 'cat' and its
>equivalents. File::Copy seems to be one solution. The problem seems so
>trivial, I wonder if I'm missing something.

What's wrong with open() ??? No spawned processes, fast and easy:
  # Very portable code
  open FILE, $file or die "Can't open $file: $!\n";
  # Better than loading the whole file into memory :
  print while <FILE>;
  close FILE;

>This is for a cgi script, and the system function may be prevented
>anyway, if the script is running on a Windows server using isapi which
>therefore bans system calls since perl shares the server process.

Calls to the system() perl function and system calls are two very
different things. System calls are when you're using one of your
system's functionalities (opening a file for reading, etc.). system()
is internally implemented with system calls, but is not a system call by
itself.

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


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

Date: 26 Sep 2000 04:08:32 GMT
From: abigail@foad.org (Abigail)
Subject: Re: References and local
Message-Id: <slrn8t087h.lo9.abigail@alexandra.foad.org>

Daniel Chetlin (daniel@chetlin.com) wrote on MMDLXXXIII September
MCMXCIII in <URL:news:8qp02h012rj@news1.newsguy.com>:
<> On Mon, 25 Sep 2000 22:02:44 GMT,
<>  Martien Verbruggen <mgjv@verbruggen.comdyn.com.au> wrote:
<> [snip]
<> 
<> >If the implementation is wrong, the current developers will then have
<> >to make a decision on whether they believe it's worth changing or not.
<> >I don't pretend to have enough knowledge of perl's internals to be able
<> >to see the ramifications of changing this, or the influence on speed of
<> >execution, or the amount of breakage that would occur.
<> 
<> I have a decent knowledge of the internals, I suppose. I certainly can't
<> claim that I know exactly what will happen, but here is my view on the
<> ramifications:
<> 
<>   * Currently, if you want to "follow along" with how a global variable
<>     changes, you can do it with a soft reference or a reference to a
<>     glob, whereas if you want to hang on to the initial value regardless
<>     of any use of local, you do it with a hard reference. Making the
<>     change that may very well have been what was originally intended
<>     will make it impossible to hang on to the original value when local
<>     is used. It will go away completely until the end of the block or
<>     scope. IMO, regardless of the initial intention for local's
<>     behavior, taking away this flexibility is not a win.

No, you just can't say "oh, take a soft reference and it will work".
There are no soft references to lexicals, and before you say, but you
cannot localize a lexical, sure you can. You can't apply local() on a 
lexical, but you can use a lexical as a loop variable for foreach, and
Perl will localize that variable. Typeglobs don't exist for lexicals
either.

Furthermore, even if you have package variables, use of soft references
isn't always an option either. If you call a sub with a variable as argument,
Perl passes an alias to the variable as parameter. You can take a hard
reference of that, but Perl doesn't pass by name, so you can't take a
soft reference of that. And this is important when using overloading - 
you get an alias to the variables involved, and not their name.

Hence, the option "use soft references" is moot. It's a non-option.


[[ What I am trying to do is:

       use deferred_interpolation;
       my $colour;
       my $line   = "The colour is $colour.";
       foreach $colour (qw /red green blue/) {
           print $line;
       }

   and have it print:
       The colour is red.
       The colour is green.
       The colour is blue.

   It works if you do:

       use deferred_interpolation;
       my $colour;
       my $line   = "The colour is $colour.";
       foreach $c (qw /red green blue/) {
           $colour = $c;
           print $line;
       }

   deferred_interpolation.pm is heavily depended on overload::constant
   and overloaded operators (especially the overloaded concatenation
   and stringify operators). Use of soft references or references to
   typeglobs would entirely defeat the purpose of overloading; you'd
   have to resort to using totally different syntax.

   It's the implicite localization in the foreach that messes up things.

]]

<> >We can go on discussing this here, but I think the only sensible thing
<> >to do would be to submit a bug report, and to let the developers make a
<> >decision (Abigail, are you still reading this? Have you submitted a bug
<> >report). We are both second-guessing what the real behaviour should be,
<> >and neither of us really knows.
<> 
<> Sure, I have no objections to taking it to p5p. However, I'm skeptical
<> that this will really produce the discussion of it that we'd want. I
<> think there's a decent chance it'd just be ignored, unfortunately. p5p
<> has been like that lately.


I kind of want to take this to p5p, but there are a few problems with
that. It's going to take a long time to write a coherent document about
this, presenting the problem, and summerizing the discussion so far.
I currently don't have much time, and furthermore, I will lose net access
in about 72 hours; if I ever will get net access again, it will take quite
some time. My future is looking quite grim, and I will have more important
things to tend to first, like food and shelter.



Abigail
-- 
 :;$:=~s:
-:;another Perl Hacker
 :;chop
$:;$:=~y
 :;::d;print+Just.
$:;


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

Date: Tue, 26 Sep 2000 05:45:37 GMT
From: Alex Hart <news@#nospam#althepal.com>
Subject: regex with undefined variable
Message-Id: <5KWz5.11837$T6.563499@typhoon2.ba-dsg.net>

I am trying to build a mail filter that will look at three fields - To,
From, and Subject.

I have a hash for the email headers and a hash for each filter, so the
code looks like this.

if    ($email_header{'to'} =~ /$filter{'to'}/      and
$email_header{'from'} =~ /$filter{'from'}/      and
$email_header{'subject'} =~ /$filter{'subject'}/ ) {

    .....Move the mail to the right place

}

Most filters do not look at all three fields, so some of the values are
undefined. I'm getting some strange results that I don't understand with
these undefined values. It does not seem to act consistently.

I thought that if an undefined variable is the search criteria, it
should always match. I wrote some test programs, that seemed to show
this is the case. What should happen with an undefined variable in the
regex??  Please fill me in on what perl does here.

The filters do work if I put in "!$filter{'to'} or" in the condition,
but I want to understand the problem better.

thanks already.

- Alex



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

Date: Tue, 26 Sep 2000 08:40:25 +0100
From: nobull@mail.com
Subject: Re: regex with undefined variable
Message-Id: <u9pulrftgz.fsf@wcl-l.bham.ac.uk>

Alex Hart <news@#nospam#althepal.com> writes:

> $email_header{'from'} =~ /$filter{'from'}/      and
> $email_header{'subject'} =~ /$filter{'subject'}/ ) {

> I thought that if an undefined variable is the search criteria, it
> should always match.

No, check the documentation of the m// operator.  Pay particular note
to the sentence that starts "If the PATTERN evaluates to the empty
string...".

I find a good pattern to match all strings is /^/ (which says match
any string that has a start - which, of course, all strings do).

BTW: Since you are storing regular expressions in variables you should
also look into the qr// quoting operator if you've not already done
so.

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


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

Date: Tue, 26 Sep 2000 08:04:36 GMT
From: David <NIXSPAMdrh@engineer.com>
Subject: rookie: How do I get regex results into array?
Message-Id: <rtl0ts4jr245n6jkqh122454gr5vqgelgb@4ax.com>

Hi

I've been trying to populate an array with the results of a regular expression search (the
filenames) in a directory one level up with no success.  I've also tried globbing.  

@allMatches = glob ("..\\"."*$fileCheckList");
@allMatches = ("..\\/.*$fileCheckList/");     # tried another way

Any suggestions?

Many thanks,

David


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

Date: Tue, 26 Sep 2000 08:52:25 +0100
From: nobull@mail.com
Subject: Re: rookie: How do I get regex results into array?
Message-Id: <u91yy78pil.fsf@wcl-l.bham.ac.uk>

David <NIXSPAMdrh@engineer.com> writes:

> I've been trying to populate an array with the results of a regular
> expression search (the filenames) in a directory one level

I see no evidence to support this assertion. 

>  I've also tried globbing.  
> 
> @allMatches = glob ("..\\"."*$fileCheckList");

Removing the redundant concatenation that is:

@allMatches = glob ("..\\*$fileCheckList");

Is $fileCheckList a regex or a glob pattern?  If it's a glob
pattern then the above should work.

> @allMatches = ("..\\/.*$fileCheckList/");     # tried another way

That's just assigning a array to a list containing a single
interpolated string.  No regular expression operations or directory
operations in there.

> Any suggestions?

Return to start.  You haven't learnt enough Perl syntax to have the
slightest idea what you are doing.  The Perl pattern match operator is
m// (usually abbrviated to //).  The Perl functions for reading
directories are glob() or opendir()/readdir().  The Perl function
filter a list down to only those elements satisfying some condition is
grep.

Now I'm going to give you a fish.  But I don't recommend you eat it
until you are confident you could have caught it yourself.

opendir(PARENT, '..') or die "Could not open ..: $!";
@allMatches = grep { /.*$fileCheckList/ } readdir(PARENT); 
closedir(PARENT);

Note: Unlike your glob() approach in this apprroach the filenames in
@allMatches won't have .. prefixes.  If you really want them:

@allMatches = map { "..\\$_" } grep { /.*$fileCheckList/ } readdir(PARENT); 

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


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

Date: Tue, 26 Sep 2000 03:50:40 -0400
From: "ldbarlet" <ldbarlet@email.msn.com>
Subject: sendmail
Message-Id: <egZAI54JAHA.358@cpmsnbbsa07>

Can anyone point me in the right direction to learn how to use sendmail to
send email in html format?

--
Thank you,
Terry





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

Date: 26 Sep 2000 08:51:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: sendmail
Message-Id: <slrn8t0opu.lo9.abigail@alexandra.foad.org>

ldbarlet (ldbarlet@email.msn.com) wrote on MMDLXXXIII September MCMXCIII
in <URL:news:egZAI54JAHA.358@cpmsnbbsa07>:
][ Can anyone point me in the right direction to learn how to use sendmail to
][ send email in html format?

<news:comp.mail.sendmail>

But what makes you think that this group is the appropriate place to ask?
Did someone put up a sign, "we keep track of what is discussed in 80,000
different newsgroups"? I don't think so.


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'


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4431
**************************************


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