[18613] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 781 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 27 14:05:59 2001

Date: Fri, 27 Apr 2001 11:05:09 -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: <988394709-v10-i781@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 27 Apr 2001     Volume: 10 Number: 781

Today's topics:
    Re: Am I in the perl Debugger? <bseib@jade.cc.purdue.edu>
    Re: Benchmark.pm is REALLY inaccurate? <elijah@workspot.net>
    Re: Benchmark.pm is REALLY inaccurate? (Anno Siegel)
    Re: best way to evaluate $1 so it's not read-only? <mjcarman@home.com>
    Re: binary operations (Tad McClellan)
        CGI::header is a filehandle? (Rudolf Polzer)
    Re: DBD::DB2 and CLOB? <shah@typhoon.xnet.com>
    Re: decimal-string to CORRECT binary-string ?? $binary_ nobull@mail.com
        Detect if string starts with one of a set of substrings nobull@mail.com
    Re: extracting hostname from a url? (Logan Shaw)
    Re: Finding all elements in an array matching a certian <andras@mortgagestats.com>
    Re: How to down size /usr/bin/perl ? (Anno Siegel)
    Re: How to enclose scalar for readability? nobull@mail.com
    Re: match a range of number <david.bouman@nl.xo.com>
    Re: match a range of number (Anno Siegel)
    Re: match a range of number <david.bouman@nl.xo.com>
    Re: match a range of number (Anno Siegel)
    Re: match a range of number <joe+usenet@sunstarsys.com>
    Re: operators: != vs. ne, strange behaviour (Rudolf Polzer)
    Re: operators: != vs. ne, strange behaviour (Rudolf Polzer)
    Re: Problem in Netscape with CGI Headers <flavell@mail.cern.ch>
    Re: Problem in Netscape with CGI Headers (David Pardo)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 27 Apr 2001 16:12:37 +0000 (UTC)
From: Broc Seib <bseib@jade.cc.purdue.edu>
Subject: Re: Am I in the perl Debugger?
Message-Id: <9cc5pl$eh4$1@mozo.cc.purdue.edu>

Abigail <abigail@foad.org> wrote:
> 
> Broc Seib (bseib@icd.cc.purdue.edu) wrote on MMDCCXCV September MCMXCIII
> in <URL:news:9c9mpk$8js$1@mozo.cc.purdue.edu>:
> :)  I need my code to behave a little different if I am running it
> :)  in the perl debugger.
> 
> Wouldn't that break the point of having a debugger in the first place?
> If your code behaves differently, you are suddenly debugging a
> different program.

We have a lib to speak in-house protocol. Said protocol has very short
timeout. If you fire up in debugger ( $^P != 0  ???) I set the timeout
to be much longer so it doesn't timeout on me while single-stepping.
We have high confidence in the timeout behavior; it is an affordable
risk to only auto-change the timeout when under debugger. :-)

> :)                        Is there a variable I can check to know for
> :)  sure if I am in the debugger or not?
> 
> All special variables are discussed in man perlvar.

Thanks for the tip.

Does anyone know for certain that $^P will always be zero when running
normal, and non-zero if in the debugger?

-b


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

Date: 27 Apr 2001 17:27:20 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Benchmark.pm is REALLY inaccurate?
Message-Id: <eli$0104271325@qz.little-neck.ny.us>

In comp.lang.perl.misc, xris  <xris@dont.send.spam> wrote:
> and here everyone was telling me that Benchmark was such a good 
> indicator of the speed of various routines...  so how come when I run 
> the same test three times in a row, I get three VERY different results?
> 
> > ./test.pl 
> Benchmark: timing 50000 iterations of 1, 2, 3, 4, 5...
>          1:  2 secs ( 1.57 usr  0.00 sys =  1.57 cpu)
>          2:  2 secs ( 1.53 usr  0.01 sys =  1.54 cpu)
>          3:  3 secs ( 1.56 usr  0.00 sys =  1.56 cpu)
>          4:  4 secs ( 1.72 usr  0.00 sys =  1.72 cpu)
>          5:  2 secs ( 1.77 usr  0.00 sys =  1.77 cpu)

If all of your tests run in under 30 seconds, you don't have
enough iterations.

Elijah
------
some might say that even 30 seconds is too short


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

Date: 27 Apr 2001 17:45:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Benchmark.pm is REALLY inaccurate?
Message-Id: <9ccb7a$d1f$2@mamenchi.zrz.TU-Berlin.DE>

According to Eli the Bearded  <elijah@workspot.net>:
> In comp.lang.perl.misc, xris  <xris@dont.send.spam> wrote:
> > and here everyone was telling me that Benchmark was such a good 
> > indicator of the speed of various routines...  so how come when I run 
> > the same test three times in a row, I get three VERY different results?
> > 
> > > ./test.pl 
> > Benchmark: timing 50000 iterations of 1, 2, 3, 4, 5...
> >          1:  2 secs ( 1.57 usr  0.00 sys =  1.57 cpu)
> >          2:  2 secs ( 1.53 usr  0.01 sys =  1.54 cpu)
> >          3:  3 secs ( 1.56 usr  0.00 sys =  1.56 cpu)
> >          4:  4 secs ( 1.72 usr  0.00 sys =  1.72 cpu)
> >          5:  2 secs ( 1.77 usr  0.00 sys =  1.77 cpu)
> 
> If all of your tests run in under 30 seconds, you don't have

I'm all for handy rules of thumb, but this one seems a bit coarse.  
Put that in terms of CPU cycles and you may be up to something.

Anno


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

Date: Fri, 27 Apr 2001 09:44:43 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: best way to evaluate $1 so it's not read-only?
Message-Id: <3AE985DB.7572A2CF@home.com>

xris wrote:
> 
> Bart Lateur <bart.lateur@skynet.be> wrote:
> 
>>>   sub t {
>>>      $_[0] =~ tr/a-z/A-Z/;
>>>      return $_[0];
>>>   }
>>
>> This not only returns the new value, but also modified the passed
>> argument. Unless this is intentional, this coding practice is
>> considered a very bad habit.
> 
> actually, it IS intentional; that was the whole point my my question.

Okay, but it you want this behavior, then you *can't* call your 
function with read-only arguments, including literals.

> I have several routines [...] 
> I was hoping to be able to use them as general functions, so I could
> have:
> 
>    &ISOLatin1ToHTML($var);

You don't need the leading & there anymore.
 
> [...] instead of:
> 
>    $var = &ISOLatin1ToHTML($var);

What if someone wants to do a conversion of a literal string? Now they 
have to write

my $foo = 'some string';
ISOLatin1ToHTML($foo);

instead of

my $foo = ISOLatin1ToHTML('some string');

Is that really better? My point is that "modify in place" behavior 
makes sense for some things, but not for everything. You should only do 
it for functions where it makes sense.

> passing by a normal reference won't really do what I want to do here,
> so I'm looking for other options.
> 
> > Nevertheless, this is a good question. But not for this purpose.
> 
> so, is there an answer?  benchmark seemed to show that "$1" was the
> best.  But as I tried to use it, I found that it still results in
> "undefined" variables and causes errors when I try to modify them.

You could wrap the modification in an eval{}. If it succeeds, 
everything is rosy. If it fails, you could switch to back to the old 
"return a copy" behavior. It might make an interesting exercise, but I 
don't really recommend it. For one, the dual-behavior would probably 
confuse anyone except the original programmer. Aside from that, it 
would probably just slow your little micro-optimization down.

-mjc


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

Date: Fri, 27 Apr 2001 10:22:33 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: binary operations
Message-Id: <slrn9ej059.408.tadmc@tadmc26.august.net>


[ Please put your comments *following* the quoted text that you
  are commenting on.

  Please do not quote an entire article.

  Jeopardectomy performed.
]


RayJ <rayj00@yahoo.com> wrote:
>Abigail wrote:
> 
>> I bet you fail to understand what the value of an array in scalar 
>> context is. I also fail to see the intend of your code.
>> 
>
>I bet I do too!


Feel free to ignore expert advice if you must, but I do not see
the point of asking for advice if you are going to ignore it.

It is clear to everyone that knows Perl that you do not know
what the value of an array in scalar context is, because you
are using it incorrectly.


>What I want to do is take a hex value, say a5.

I don't know what "take a value" might mean.

Show us Perl code that puts a value into a variable.

Do you mean one of the below, or something else?

   $x = 0xa5;

   $x = 165;   # a5 (base 16) is 165 (base 10)

   $x = 'a5';

   $x = <STDIN>;
   chomp $x;


>Turn a5 into 10100101 binary. 


We cannot help you with that until you tell us what a5 is.

$x *already is* 10100101 binary if you use one of the first two above.

Let's see that in action:

   $x = 0xa5;
   printf "%b\n", $x;

   
We are going to continue to go round and round if you insist on
trying to say stuff in natural language instead of saying it in
Perl.

There is plenty of room for confusion regarding the difference between
a number and the representation of that number.

Where do you "get" the "hex value" from? Show perl code that "gets" it.


>Then I may want to
>look at bit's 4 and 5 


I dunno how you are counting bits. I will assume the usual right-to-left
starting at zero, so the 2 bits of interest are:

   10100101
     ^^
     ^^

>to see what the 2 bit value is
>(00,01,10,11), or just look at bit 2 


You will have a *much* better chance of getting an answer if you
provide a Perl program that we can run that illustrates what you
want (or as close to what you want as you can get it).

Here is a Perl program that does the 2 checks above:

-------------------------------------
#!/usr/bin/perl -w
use strict;

my $x = 0xa5;
printf "%b\n", $x;           # let's see the bits

if ( $x & 0x4 ) {            # mask off bit 2
   print "bit 2 is set\n";
}
else {
   print "bit 2 is cleared\n";
}

$x >>= 4;             # discard bits 0-3
printf "%b\n", $x;

$x &= 0x3;            # mask off MSBs
printf "%b\n", $x;

if ( $x == 0 ) {
   print "value is 00\n";
}
elsif ( $x == 1 ) {
   print "value is 01\n";
}
elsif ( $x == 2 ) {
   print "value is 10\n";
}
elsif ( $x == 3 ) {
   print "value is 11\n";
}
-------------------------------------


>or bits 2-5, etc.


We leave that one as an exercise for the reader.


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


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

Date: Fri, 27 Apr 2001 18:51:08 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: CGI::header is a filehandle?
Message-Id: <slrn9ej8rs.157.eins@www42.t-offline.de>

Look at the following script:


#!/usr/bin/perl -w

use CGI;

{
 print "1:\n";
 print (CGI::header (-type => 'text/html'));

 print "2:\n";
 print scalar (CGI::header (-type => 'text/html'));
}

use CGI qw/:standard/;
print "3:\n";
print (header (-type => 'text/html'));
print "4:\n";
print (CGI::header (-type => 'text/html'));


Do you find the error without executing?











The problem is: 1. does not work because Perl thinks CGI::header was a 
file handle. But doesn't CGI.pm define it as a sub?

2. solves the problem because scalar is not a file handle.

Interestingly, the problem does not occur when importing the CGI 
namespace which is what I do _not_ want. Can you explain to me what 
the difference between the two occurances of CGI::header is? My script 
did not output a header and setting scalar before the call to CGI 
helped, but when including the CGI namespace, it works with 'CGI::', 
too. What exactly is the difference? It took me one hour to find the 
problem...

-- 
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"


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

Date: Fri, 27 Apr 2001 16:18:41 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: Re: DBD::DB2 and CLOB?
Message-Id: <9cc651$nvp$1@flood.xnet.com>

In comp.lang.perl.misc Hemant Shah <shah@typhoon.xnet.com> wrote:
:)
:)Folks,
:)
:)   How can I insert the array into a CLOB column?
:)
:)   Here is my table definition:
:)
:)  CREATE TABLE "BILLING "."DOCUMENTS"  
:)      ("INVOICE_NUM" CHAR(15) NOT NULL,
:)       "DOC_TYPE_ID" CHAR(5) NOT NULL,
:)       "DOC" CLOB(2097152) LOGGED NOT COMPACT) IN USERSPACE1 ;
:)       
:)
:)   In my perl script is create array as follows:
:)
:)   sub Function1
:)   {
:)      # Do something
:)      @RthArray;
:)   }
:) 
:)   sub Function2
:)   {
:)      # Do something
:)      @RthArray;
:)   }
:)
:)   sub Function3
:)   {
:)      # Do something
:)      @RthArray;
:)   }
:)
:)   push(@Documents, Function1());
:)   push(@Documents, Function2());
:)   push(@Documents, Function3());
:)
:)
:)   $InsertDocumentsStmt = "INSERT INTO BILLING.DOCUMENTS
:)                           (INVOICE_NUM,DOC_TYPE_ID,DOC)
:)                           VALUES
:)                           (?,?,?)
:)                       ;";
:)
:)   $InsertDocumentsStmtHandle = $DbHandle->prepare($InsertDocumentsStmt);
:)
:)   $InsertDocumentsStmtHandle->bind_param(1,$InvoiceNum);
:)   $InsertDocumentsStmtHandle->bind_param(2, "COV");
:)   $InsertDocumentsStmtHandle->bind_param(3,@Documents,SQL_CLOB);
:)   $InsertDocumentsStmtHandle->execute();
:)   $InsertDocumentsStmtHandle->finish;
:)   $DbHandle->commit;
:)
:)
:)
:)When I run the script I get following error:
:)
:)phase4.pl: ERROR DBI bind_param: invalid number of parameters: handle + 7
:)Usage: $h->bind_param($parameter, $var [, \%attr]) at ./phase4.pl line 525.
:)
:)Line 525 is the bind_param(3,@Documents,SQL_CLOB); line.
:)
:)
:)
:)I the lines as follows:
:)
:)   $InsertDocumentsStmtHandle->bind_param(1,\$InvoiceNum);
:)   $InsertDocumentsStmtHandle->bind_param(3,\@Documents,SQL_CLOB);
:)
:)I get following error:
:)phase4.pl: ERROR DBD::DB2::st execute failed: [IBM][CLI Driver] CLI0109E  
:)String data right truncation. SQLSTATE=22001 at ./phase4.pl line 526.
:)
:)
:)Thanks in advance.
:)
:)


   I fixed the problem, it was a perl problem, I needed to convert Array 
   into a Scalar:

   $Documents = join("\n", @Documents);
   $InsertDocumentsStmtHandle->execute($InvoiceNum, "COV", $Documents);

   worked for me.

-- 
Hemant Shah                           /"\  ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com       \ /  --------------------- 
                                       X     against HTML mail
TO REPLY, REMOVE NoJunkMail           / \      and postings      
FROM MY E-MAIL ADDRESS.           
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind,                Above opinions are mine only.
it's backed up on tape somewhere.      Others can have their own.


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

Date: 27 Apr 2001 17:14:33 +0100
From: nobull@mail.com
Subject: Re: decimal-string to CORRECT binary-string ?? $binary_string = unpack('B*', "$cnt"); fails
Message-Id: <u9sniugw0m.fsf@wcl-l.bham.ac.uk>

"Murat Uenalan" <murat.uenalan@gmx.de> writes:

> I simply want a CORRECT binary representation of a scalar integer.

By "CORRECT binary representation" I shall assume you mean an ASCII
string containing the characters '0' and '1'.

Note: despite the impression you may have got from listening to native
English speakers, if what you are saying in English is unclear or
ambiguous, SHOUTING does not make it any clearer.

> for my $cnt ( 0 .. 12 )
> {
>  printfln "$cnt = %s", $binary_string = unpack('B*', "$cnt");
                                                       ^^^^^^
The double quotes here are:

  1) Redundant (as Perl would infer that $cnt must be stringified).
  2) A big clue as to why this doesn't do what you want.

unpack() unpacks a packed binary structure.  "$cnt" is not a packed
binary representation of the number in $cnt. "$cnt" is the ASCII
string containing the decimal representation of the number in $cnt. To
get a packed binary reprentaion of $cnt you would use pack().

for my $cnt ( 0 .. 12 ) {
  # Change 'n' to 'c' or 'N' for 8 or 32 bits respectively 
  print $cnt,' = ', unpack('B*', pack('n',$cnt)),"\n"
}
__END__
0 = 0000000000000000
1 = 0000000000000001
2 = 0000000000000010
3 = 0000000000000011
4 = 0000000000000100
5 = 0000000000000101
6 = 0000000000000110
7 = 0000000000000111
8 = 0000000000001000
9 = 0000000000001001
10 = 0000000000001010
11 = 0000000000001011
12 = 0000000000001100

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


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

Date: 27 Apr 2001 18:12:10 +0100
From: nobull@mail.com
Subject: Detect if string starts with one of a set of substrings (was: Finding all elements in an array matching a certian criteria)
Message-Id: <u9n192gtcl.fsf@wcl-l.bham.ac.uk>

Ron Hill <hillr@ugs.com> writes:

> Subject: Finding all elements in an array matching a certian criteria

Good subject line.  Except that's not what your problem is.  You've
got that bit sorted.  Your problem is in expressing in Perl the
particular 'certain criteria' that you have in mind.

> I am trying to extract filenames from a directory based on userid. I
> figured that the perl grep function would work.

It will.

my @some_users_files = grep { (stat)[4] == some_user_id } @some_files;

> However I am unabe to extract the filenames that I want. I have
> constructed a hash with the keys as the userid's.

OK

my @some_users_files = grep { exists $some_user{(stat)[4]} } @some_files;


> I retrive the dir listing and I want to extract all filenames that
> contain the userid.

So you lied when you said "I am trying to extract filenames from a
directory based on userid".  You are trying to extact files based on
substrings in the filename.  The fact that these substrings happen to
be usernames is clearly not relevant to how you solve the problem. 

I'm not angry that you lied to us, however you should realise that
expressing clearly (to yourself) what is it that you want to do is the
first step to solving problems for yourself.

> I have included a script of what I have tried.

Good, excellent illustration of what you've tried.  I wish everyone
would do this.

> my %systems = (  'riches'  =>'1',
> 		 'loder'   =>'1',
> 		 'yamaguch'=>'1',
> 		 'gerlich' =>'1');

> my @wanted = grep { /keys %systems_(.*)/ } @allfiles;

> __DATA__
> jswade_1093207.toreview
> loder_4257062.toreview

You are not using the captured subexpression so the (.*) is redundant.

You probably want to look for the name at the stat of the string so
you should anchor the expression to the start.

And most importantly you do not want to look for the string 'keys
%systems'  - the letter 'k' followed by the letter 'e' and so on!

What you want to look for is the the pattern:

 /^(riches|loder|yamaguch|gerlich)_/

You want this pattern to be calacuated dynamically from
keys(%systems).  So that would be:

  /^(@{[ join '|', keys %systems ]})_/

[ Note: for an explaination of the @{[ ]} construct see FAQ: "How do I
expand function calls in a string?" ]

You could write...

my @wanted = grep { /^(@{[ join '|', keys %systems ]})_/ } @allfiles;

 ...but that would reconstuct the regex for each filename (remember
grep() is really a looping construct).

It would be much better to take the regex construction and compliation
outside the loop:

my $pattern= qr/^(@{[ join '|', keys %systems ]})_/;
my @wanted = grep { /$pattern/ } @allfiles;

And finally... you are going about this all wrong!

my @wanted = grep { /(.*?)_/ && $system{$1} } @allfiles;

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


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

Date: 27 Apr 2001 12:09:01 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: extracting hostname from a url?
Message-Id: <9cc93d$ji8$1@charity.cs.utexas.edu>

In article <comdog-007CA4.01432127042001@news.panix.com>,
brian d foy  <comdog@panix.com> wrote:
>In article <9cav87$i47$1@charity.cs.utexas.edu>, logan@cs.utexas.edu 
>(Logan Shaw) wrote:
>
>> In article <3AE8CA05.A9B2697C@cs.tamu.edu>,
>> Neeraj Khandelwal  <neerajk@cs.tamu.edu> wrote:
>> >hi
>> >
>> >I need to extract the hostname from a url. what would be a neat regular
>> >expression to do this? for example given url
>
>> Anyway, one way to do what you're talking about is something like this:
>> 
>> 	m<^(http://[^/]+/?)>i
>
>why use a regular expression when a URI module exists?

IMHO, sometimes a module is overkill.  If all you need is to do this
one thing, then typing "m<^(http://[^/]+/?)>i" is much easier and more
efficient than installing the URI module on every machine that will
ever use the script.

  - Logan
-- 
my  your   his  her   our   their   _its_
I'm you're he's she's we're they're _it's_


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

Date: Fri, 27 Apr 2001 12:07:26 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Finding all elements in an array matching a certian criteria
Message-Id: <3AE9993D.63EF40EE@mortgagestats.com>



Ron Hill wrote:

> Hi All,
>
> I am trying to extract filenames from a directory based on userid. I
> figured that the perl grep function
> would work. However I am unabe to extract the filenames that I want. I
> have constructed a hash with
> the keys as the userid's. I retrive the dir listing and I want to
> extract all filenames that contain
> the userid. I have included a script of what I have tried. the array
> @wanted is empty. Can anyone
> tell me how this can be done?
>
> Thanks
>
> Ron Hill
>
> #!/app/perl5.005_03_static/bin/perl -w
> use strict;
>
> my %systems = (  'riches'  =>'1',
>                  'loder'   =>'1',
>                  'yamaguch'=>'1',
>                  'gerlich' =>'1');
>
> my @allfiles=();
> while (<DATA>)  {
> chomp;
> push (@allfiles,$_);
> }
>
> my @wanted = grep { /keys %systems_(.*)/ } @allfiles;
>
> print @wanted;
> __DATA__
> jswade_1093207.toreview
> loder_4257062.toreview
> whitman_4229398.toreview
> kjrangan_4269510.toreview
> gerlich_4272527.toreview
> yamaguch_new_1370.toreview
> andersj_4272811.toreview
> pdford_4273033.toreview
> cowell_new_1482.toreview
> jfwhite_new_1494.toreview
> gerlich_new_1498.toreview
> jfwhite_new_1495.toreview
> fujiir_4272999.toreview
> gerlich_new_1497.toreview
> riches_4000097.toreview
> schnurr_new_1487.toreview
> brannon_4047079.toreview
> riches_4239252.toreview
> riches_4214803.toreview

Ron,

I'm not sure what you are trying to do in the pattern match part of your
grep statement, but try replacing your grep line with this:

my $pattern=join "|", keys %systems;
my @wanted = grep { /$pattern/} @allfiles;

That way the program will give you the output of

loder_4257062.toreviewgerlich_4272527.toreviewyamaguch_new_1370.toreviewgerlich_new_1498.toreviewgerlich_new_1497.toreviewriches_4000097.toreviewriches_4239252.toreviewriches_4214803.toreview

which, I believe, is what you want.

While we are at it, you could replace
    print @wanted;
with
    print join "\n", @wanted;
to get a more readable output.

Alternatively, you could leave out the chomp statement and get the same
effect.

Also, apparently you only use your %systems hash to access its keys, so
why bother making a hash in the first place? Just use a simple array, or
build $pattern directly.

Finally,

my @allfiles=();
while (<DATA>)  {
#chomp;
push (@allfiles,$_);
}

is  the same as

my @allfiles=<DATA>;


Here's a simplified version of your program:

#!/app/perl5.005_03_static/bin/perl -w
use strict;

my $pattern='riches|loder|yamaguch|gerlich';
my @allfiles=<DATA>;
print grep { /$pattern/} @allfiles;

__DATA__
jswade_1093207.toreview
loder_4257062.toreview
whitman_4229398.toreview
kjrangan_4269510.toreview
gerlich_4272527.toreview
yamaguch_new_1370.toreview
andersj_4272811.toreview
pdford_4273033.toreview
cowell_new_1482.toreview
jfwhite_new_1494.toreview
gerlich_new_1498.toreview
jfwhite_new_1495.toreview
fujiir_4272999.toreview
gerlich_new_1497.toreview
riches_4000097.toreview
schnurr_new_1487.toreview
brannon_4047079.toreview
riches_4239252.toreview
riches_4214803.toreview




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

Date: 27 Apr 2001 17:52:57 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to down size /usr/bin/perl ?
Message-Id: <9ccblp$d1f$3@mamenchi.zrz.TU-Berlin.DE>

According to Logan Shaw <logan@cs.utexas.edu>:
> In article <kr4G6.12259$482.59985@newsfeeds.bigpond.com>,
> Gregory Toomey <gtoomey@usa.net> wrote:
> >Create your own language an implement it. It shoud take you about  a year.
> 
> Boy, I hope it doesn't take that long.  In the fall, I'm planning to
> take a compilers class in which (I'm told) I will get to write my own
> compiler (for Pascal, yippie), and this takes only a semester.

That doesn't involve designing Pascal.

Anno


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

Date: 27 Apr 2001 18:41:55 +0100
From: nobull@mail.com
Subject: Re: How to enclose scalar for readability?
Message-Id: <u9g0eugrz0.fsf@wcl-l.bham.ac.uk>

Bart Lateur <bart.lateur@skynet.be> writes:

> Abigail wrote:
> 
> >//  but this works, too:
> >//  
> >//  "$together\Er"
> >
> >
> >Really? Now, where is that documented? Or did you typo?
> 
> "r" too much.
> 
> The "\E" provides a break, but doesn't insert anything by itself.

So does "${['']}" but I wouldn't consider using it or "\E" this way to
be an aid to _readability_ as per the subject of this thread :-)

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


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

Date: Fri, 27 Apr 2001 17:27:35 +0200
From: David Bouman <david.bouman@nl.xo.com>
Subject: Re: match a range of number
Message-Id: <3AE98FE7.452748B2@nl.xo.com>

Anno Siegel wrote:
> According to David Bouman  <david.bouman@nl.xo.com>:
>>
>>>> As was noted elsewhere it's not. I had the same doubt, but allowed a test
>>>> to convince me. Here's one simple fix (and a change):
>>>>
>>>>       sub strictly_sorted {
>>>>           @_ < 2 || shift() - $_[0] < 0 && goto &strictly_sorted;
>>>>       }
>>>
>>> How does that fix anything?  shift() and $_[0] are now operands of "-"
>>> instead of "<".  Neither operator has a specified order of evaluation.
>>
>> Substraction has, at least according to Johan Vromans' Quick Reference quide.
> 
> Could you please post the quote from Vroman? 

His reference-guide was just the first doc I checked, see below.

> I don't find anything
> in perlop to confirm the claim.  Have you, by any means, taken "left
> associativity" to mean the left operand is evaluated first?

Uhm, admittedly I did read "left associative" to imply "left-to-right 
evaluation". 

--
David Bouman


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

Date: 27 Apr 2001 15:57:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: match a range of number
Message-Id: <9cc4td$8rg$1@mamenchi.zrz.TU-Berlin.DE>

According to David Bouman  <david.bouman@nl.xo.com>:

> Uhm, admittedly I did read "left associative" to imply "left-to-right 
> evaluation". 

I can see how this could happen, but associativity, together with
precedence and parenthesizing, only determine the extent of the
operands.  The operator is still free to chose any order of evaluation.

Anno


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

Date: Fri, 27 Apr 2001 19:01:25 +0200
From: David Bouman <david.bouman@nl.xo.com>
Subject: Re: match a range of number
Message-Id: <3AE9A5E5.33767FDA@nl.xo.com>

Anno Siegel wrote:
> 
> According to David Bouman  <david.bouman@nl.xo.com>:
> 
> > Uhm, admittedly I did read "left associative" to imply "left-to-right
> > evaluation".
> 
> I can see how this could happen, but associativity, together with
> precedence and parenthesizing, only determine the extent of the
> operands.  The operator is still free to chose any order of evaluation.

I should have known better. I guess it was the lack of an (i.e. never 
having encountered any) explicit statement regarding the freedom of 
evaluation order, like the C spec makes for instance, that tricked my 
mind into believing it would be different in perl.

Otoh, I seem to recall it being stated earlier in this thread that '=' 
evaluates its right operand first. Yet perlop only reports it to be right
associative. Then, wasn't the same error made in that remark or is 
the evaluation order of '=' indeed explicitly determined?

--
David.


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

Date: 27 Apr 2001 17:40:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: match a range of number
Message-Id: <9ccatm$d1f$1@mamenchi.zrz.TU-Berlin.DE>

According to David Bouman  <david.bouman@nl.xo.com>:
 
> Otoh, I seem to recall it being stated earlier in this thread that '=' 
> evaluates its right operand first. Yet perlop only reports it to be right
> associative. Then, wasn't the same error made in that remark or is 
> the evaluation order of '=' indeed explicitly determined?

I made that statement, half-expecting it to be challenged, and I
retract it.

You are right that the documentation is silent about the evaluation
order.  While it seems logical to say that the value (i.e. the right
hand side) must be computed before an assignment can be made, evaluation
on the left side has nothing to do with values, but determines what the
value is being assigned to, as in "$x[ $i] = 13".  If we do weird things
like

    $i = 0;
    $x[ $i] = do { $i = 1 - $i; 13};

the result can depend on evaluation order.  When I ran it, it assigned
to $x[ 1], so the right side was indeed evaluated first, but I believe
a Perl interpreter would be within it's rights to do otherwise.

Anno


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

Date: 27 Apr 2001 14:00:04 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: match a range of number
Message-Id: <m3oftimdej.fsf@mumonkan.sunstarsys.com>

anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:

> 
>     $i = 0;
>     $x[ $i] = do { $i = 1 - $i; 13};
> 
> the result can depend on evaluation order.  When I ran it, it assigned
> to $x[ 1], so the right side was indeed evaluated first, but I believe
> a Perl interpreter would be within it's rights to do otherwise.

In cases like that (where the evaluation of operands produce
side-effects that can influence each other's value), with perl 
it's not so much the order of evaluation as it is the operator's 
implementation itself:

  % perl -wle 'print ++$a - ++$a; print $a'
  0
  2

-- 
Joe Schaefer     "The eternal mystery of the world is its comprehensibility."
                                               --Albert Einstein


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

Date: Fri, 27 Apr 2001 17:49:46 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: operators: != vs. ne, strange behaviour
Message-Id: <slrn9ej58q.nj0.eins@www42.t-offline.de>

Ren Maddox <ren@tivoli.com> wrote:
> On Thu, 26 Apr 2001, eins@durchnull.de wrote:
> > Why is there a difference?

(between (-1) ** 0.5 and $x=-1; $x ** 0.5)

Perhaps between execution at compile time (constant folding) and at 
runtime?

-- 
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"


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

Date: Fri, 27 Apr 2001 17:47:58 +0200
From: eins@durchnull.de (Rudolf Polzer)
Subject: Re: operators: != vs. ne, strange behaviour
Message-Id: <slrn9ej55e.nj0.eins@www42.t-offline.de>

Ren Maddox <ren@tivoli.com> wrote:
> On Thu, 26 Apr 2001, eins@durchnull.de wrote:
> 
> > Ren Maddox <ren@tivoli.com> wrote:
> >> 
> >> FWIW, on v5.6.0 built for MSWin32-x86-multi-thread, (ActiveState),
> >> I do get -2147483648.
> > 
> > And what happens on
> > 
> > my $x = -1;
> > print $x ** 0.5;
> > 
> > My ActivePerl version displays a value of -1.#IND that behaves just 
> > like NAN, but is equal to itself (like INF).
> 
> Yes, mine does as well.
> 
> > Why is there a difference?
> 
> Good question.

Since I do not have Storable and cannot install it using the 
integrated tool (forgot its name, looks like the CPAN module 
interface), I cannot check if the representation equals to that of 
NaN.
And I forgot to check for INF - could you please check since I cannot 
check at school?

perl -e "print 1e300 * 1e300";

The same -1.#IND or something else? Maybe they are really NaN and 
INF but ActivePerl does not support them (the FPU does, and AP does 
not check).

-- 
#!/usr/bin/perl -W -- WARNING: This will print 22,307 bytes! <strictsafe!>
use strict;for(my$y=-1;$y<1;$y+=.1){for(my$x=-1.9;$x<.4;$x+=.03){print'+';
my$X=my$Y=0;for(0..99){($X,$Y)=($X*$X-$Y*$Y+$x,2*$X*$Y+$y);print"\b "if$X*
$X+$Y*$Y>9;}}print"\n"};print''.reverse"\nHPAJ \a!rezloP .R yb torblednaM"


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

Date: Fri, 27 Apr 2001 16:53:25 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Problem in Netscape with CGI Headers
Message-Id: <Pine.LNX.4.30.0104271639050.25751-100000@lxplus003.cern.ch>

On Fri, 27 Apr 2001, David Pardo wrote:

> The script is(n't perfectly) workin as follows
>
> 	#!/usr/bin/perl
> 	use CGI;
> 	open (PLANTILLA,"/home/sites/site24/web/pl/form.html");

You're using many of the popular strategies for ensuring you
won't get a good answer.  Here's the ones that hit me.

1. Subject line says you think this is on-topic for
comp.infosystems.www.authoring.cgi, but you've posted it to the
Perl language group (c.l.p.misc) instead.

2. You've crossposted it to a group which anyone who's bothered to
read this group for a while knows is officially obsolete.

3. You've failed to use any of Perl's own assistance for finding
errors, yet you expect us to find them for you.  Your one saving
grace is that you're using CGI.pm.

I'd say that before posting a problem again, you'd need to quietly
read a few of the hundreds of previous postings in c.l.p.misc telling
you how to use warnings, strict etc. and how to test for success in
all cases where errors are possible (especially anything involving
opening files!).

And only then should you select an appropriate group (which will
probably, though not always, be in the c.i.www... hierarchy for this
kind of question), post just what you did, what symptoms (exactly what
symptoms, not some vague description of them) you got, any additional
tests you made (e.g lynx -head -dump to check the HTTP headers) and so
on.  Even better if you put a simple test-case online and give its
URL.

This way you'll be seen to be trying to help yourself, and you rate to
get a better quality of advice.  Good luck.



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

Date: Fri, 27 Apr 2001 16:34:42 GMT
From: ros@elcalamar.com (David Pardo)
Subject: Re: Problem in Netscape with CGI Headers
Message-Id: <3ae99f11.5155403@news.mundo-r.com>

Never mind. Won't bother you anymore

David


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

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


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