[21946] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4168 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Nov 24 11:05:33 2002

Date: Sun, 24 Nov 2002 08:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 24 Nov 2002     Volume: 10 Number: 4168

Today's topics:
    Re: 5.8.0 port? (Gothicdream6)
    Re: @INC, use, $LD_LIBRARY_PATH, & modules <dave@dave.org.uk>
    Re: a question on regular expression <usenet@dwall.fastmail.fm>
    Re: a question on regular expression <usenet@dwall.fastmail.fm>
        automatic email anniversay script <itshardtogetone@hotmail.com>
    Re: automatic email anniversay script <nobody@dev.null>
        Changing server problem (Angus)
    Re: complex foreach loop with deep hashes (sorted hash  (Jay Tilton)
    Re: complex foreach loop with deep hashes (sorted hash  (Tad McClellan)
    Re: complex foreach loop with deep hashes (sorted hash  (Tad McClellan)
        detecting getpwnam() errors -- how? (Rahul Dhesi)
    Re: disambiguating print (was Re: Basic syntax question <dtweed@acm.org>
        File Processing question (Pularis)
    Re: File Processing question <nobody@dev.null>
    Re: Find Text in a variable <blnukem@hotmail.com>
    Re: Find Text in a variable <robertbu@hotmail.com>
    Re: Find Text in a variable <robertbu@hotmail.com>
        hash values ref counted? (Paul Wood)
        Help with grep + hash value (Trent Hare)
    Re: Help with grep + hash value (Jay Tilton)
    Re: Help with grep + hash value (Jay Tilton)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 24 Nov 2002 08:54:57 GMT
From: gothicdream6@aol.com (Gothicdream6)
Subject: Re: 5.8.0 port?
Message-Id: <20021124035457.05783.00006660@mb-ms.aol.com>

Larry,

Check the following URL:
http://www.perl.com/CPAN/ports/#zos

I learned about Perl 5.8.0 being released from a newsletter that I subscribed
to. 

http://www.cgiwebsite.com

I hope this helps you.


>Has anyone built a port of perl 5.8.0 for OS/390 or Z/OS?  If not,  how 
>long before someone usually gets around to doing this?
>
>I'm having trouble with the Configure shell script on OS/390 2.8 and am 
>hoping I could get a binary distribution instead.  
>
>Alternatively, could someone walk me through the configure process?
>Thanks,
>
>Larry




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

Date: Sun, 24 Nov 2002 10:00:59 +0000
From: "Dave Cross" <dave@dave.org.uk>
Subject: Re: @INC, use, $LD_LIBRARY_PATH, & modules
Message-Id: <pan.2002.11.24.10.00.58.731370@dave.org.uk>

On Sat, 23 Nov 2002 09:43:31 +0000, Abernathey Family wrote:

> Dave Cross wrote:
>> 
>> On Fri, 22 Nov 2002 21:07:35 +0000, Abernathey Family wrote:
>> 
>> > How can I use modules that are not where "my" perl is installed?
>> 
>> With "use lib"
>> 
>> > I need modules & libs that are scattered.
>> 
>> Why? Why not install them all in the same place?
>> 
> --snip--
> 
> I'm in a multi-national company with access via afs to groups with their
> own builds/installations of Perl.
> By the way, some of modules have c-libraries with them. "use lib
> "pathname" works for getting the path into the @INC array but I still
> get an error from Linux Dyna-loader that it can't find them. The error
> goes away when I set my LD_LIBRARY_PATH variable to point at the
> c-libraries. But this variable has to be set "outside" of my Perl
> script. Modifying my script's local copy of this variable
> $ENV{LD_LIBRARY_PATH} doesn't work.

Have you tried setting $ENV{LD_LIBRARY_PATH} in a BEGIN block?

BEGIN {
  $ENV{LD_LIBRARY_PATH} = '/path/to/shared/objects';
}

use lib /path/to/perl/modules;

use Some::Wierd::Module;


hth,

Dave...

-- 
  Brian: Oh screw Maximilian!
  Sally: I do.
  Brian: So do I.



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

Date: Sun, 24 Nov 2002 08:00:43 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: a question on regular expression
Message-Id: <Xns92D01EA309DEAdkwwashere@63.240.76.16>

"David K. Wall" <usenet@dwall.fastmail.fm> wrote:

> "Kurt Gong" <gongwm@163.net> wrote:
> 
>> hello, i wanna find inverted repeats in dna sequence. for example:
>> there are 4 different nucleotides in dna sequence: A, T, C ,G
>> A pairs with T, and C pairs with G.
>> the inverted repeats is something like :
>> XXXXATCGXXXXCGATXXX, X represents one random nucleotide of A, T,
>> C, G. this kind of pattern can form stem-loop structure which is
>> very important for various molecular interaction.
>> my question is how to construct a regular expression to find out
>> such a pattern from a long dna sequence which may contains many of
>> this inverted repeats.
>> thanx in advance.
> 
> Maybe I misunderstood.  I thought you wanted to find ALL inverted 
> sequences of a given length.  Anyway, here's a program that does 
> that.  I don't guarantee it -- i just threw it together for fun.

Here's a version with better-organized output:

-----------
use strict;
use warnings;

my $min = 2;
my $max = 5;

my $dna;
{
    local $/ = undef;
    $dna = <DATA>;
}
$dna = lc $dna;
$dna =~ tr/agct//cd;


my %repeats;
for my $repeat_length ($min .. $max) {
    for (
      my $offset=0; 
      $offset < length($dna) - $repeat_length; 
      $offset++
      ) {
        
        my $seq = substr $dna, $offset, $repeat_length;
        my $rev = reverse $seq;

        # runs of one base are boring
        next if
            $seq eq 'a' x $repeat_length or
            $seq eq 'g' x $repeat_length or
            $seq eq 't' x $repeat_length or
            $seq eq 'c' x $repeat_length;
        
        while ( $dna =~ /$rev/g ) {
            my $pos_found = pos($dna) - $repeat_length;
            next if
                    # palindrome
                ($offset == $pos_found)         
                    # overlap
                or ($offset + $repeat_length > $pos_found)  
                ;
            $repeats{$seq}{original}{$offset}++;
            $repeats{$seq}{inverted}{$pos_found}++;
        }
    }
}
foreach my $seq (sort keys %repeats) {
    print  "$seq\n",
        "\tOriginal: ", 
        join(',', sort {$a <=> $b} keys %{$repeats{$seq}{original}}),   
        "\n",
        "\tInverse:  ", 
        join(',', sort {$a <=> $b} keys %{$repeats{$seq}{inverted}}), 
        "\n\n";
}

# some test data -- organism="Mesembryanthemum crystallinum"  :-)


__DATA__
gccctggctcccgtctgttc
-----------

Here's a portion of the output:

cct
	Original: 2
	Inverse:  8

ct
	Original: 3,7,14
	Inverse:  8,13,18


The 'ctc' at position 7 makes for some odd results: the 'ct' at 3 is 
inverted at 8, 13, and 18, while the 'ct' at 7 is inverted at 13 and 
18 only.  I'm not sure what, if anything, this means in the original 
context, but that's for the OP to decide.

I'm sorry;  I didn't use regular expressions much. :-)

-- 
David Wall - me@dwall.fastmail.fm
"Oook."


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

Date: Sun, 24 Nov 2002 08:06:32 GMT
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: a question on regular expression
Message-Id: <Xns92D01FA166D18dkwwashere@63.240.76.16>

Benjamin Goldberg <goldbb2@earthlink.net> wrote:

> Kurt Gong wrote:
>> 
[finding inverted repeats in a DNA sequence]

[snip program]
> 
> [untested]

I think you should have tested it.  Unless I'm mistaken (a frequent 
occurrence), it misses things it should have found.  

-- 
David Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: Sun, 24 Nov 2002 16:21:49 +0800
From: "itshardtogetone" <itshardtogetone@hotmail.com>
Subject: automatic email anniversay script
Message-Id: <arq1ri$st3$1@reader01.singnet.com.sg>

I wish to have a script that automatically sends "greetings" when the time
coincides, .... eg if their birthday falls on the 20th december, an email,
with my "customised wordings", will be sent to them .. say on the 19th
december, can this be done?

Thanks




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

Date: Sun, 24 Nov 2002 12:36:41 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: automatic email anniversay script
Message-Id: <3DE0C790.2090000@dev.null>



itshardtogetone wrote:

> I wish to have a script that automatically sends "greetings" when the time
> coincides, .... eg if their birthday falls on the 20th december, an email,
> with my "customised wordings", will be sent to them .. say on the 19th
> december, can this be done?

Yes!

For the scheduling you will want to use cron on UNIX or Task Scheduler 
under Windows.

For the implicit "How do I send mail?" part of your question, see the 
answer in perlfaq9 by typing perldoc -q "How do I send mail?"

Be sure the recipient does want to get a greeting from you; otherwise 
you are just another spammer.

How did you know my birthday was on the 20th.



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

Date: 24 Nov 2002 07:57:40 -0800
From: angusnisbet@yahoo.com (Angus)
Subject: Changing server problem
Message-Id: <f1601cc4.0211240757.53977f38@posting.google.com>

I have had the Extropia.com web-store successfully working for a
couple of years and I have just moved it, unchanged except for the
obviously needed changes to the setup file, to a new server.

It now refuses to work and I have managed to isolate the problem to a
few lines in the sub add_to_the_cart. About ten lines down in that sub
is the following syntax:

chomp $_; 
my @row = split (/\|/, $_); 
my $item_number = pop (@row); 
$highest_item_number = $item_number if ($item_number >
$highest_item_number);

When I hash out these lines the script will launch, though obviously I
cannot add to the cart. Without the hashes I get an 'internal server
error'.

Any suggestions? 

Thanks.


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

Date: Sun, 24 Nov 2002 05:21:51 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: complex foreach loop with deep hashes (sorted hash slices (using an array for keys))
Message-Id: <3de05710.228686719@news.erols.com>

On Sun, 24 Nov 2002 00:43:58 +0100, "Seansan"
<sheukels=cuthere=@yahoo.co.uk> wrote:

: Right. Thx Jay Tilton for nothing.

My pleasure.  Puzzling, though.  My "nothing" echoed much of Tad's good
advice.

: "Tad McClellan" <tadmc@augustmail.com> wrote in message
: news:slrnau01ch.3pa.tadmc@magna.augustmail.com...
:
: > If you had "keys %LIST" there as you should, then you could
: > just replace it with @G_ITEMS.
:
: Then the sort doesnt work

"Doesn't work" is a content-free statement.
What should the program do that it does not?
What does the program do that it should not?

The sort() returns a list of hash keys, sorted by some arbitrary
property of the hash values for those keys.  Is this somehow not what
you want?

: > What's with the one-element slices?
:
: That how sort works, if I understand correctly that you are refering to  at
: the $a and $b.

No, Tad was asking about the one-element _array_ slices.
"@{$LIST{$a}}[$x]"  is analogous to "@foo[$x]", and that's better
written as "$foo[$x]".

: I'm just interested in the use of hash slices with this particuliar problem

A hash slice is a set of hash values.
The sort() returns a set of hash keys.
Which one of these choices do you want the foreach() loop to iterate
across?

: > You should not post to comp.lang.perl, it was removed about 7 *years*
: ago...
:
: Works fine.

It restricts your possible audience to clients of the broken news
servers that still carry the group.  Ever wonder why c.l.p has so few
participants?



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

Date: Sat, 23 Nov 2002 23:13:47 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: complex foreach loop with deep hashes (sorted hash slices (using an array for keys))
Message-Id: <slrnau0o0b.49v.tadmc@magna.augustmail.com>

Seansan <sheukels=cuthere=@yahoo.co.uk> wrote:


> Thx Jay Tilton for nothing.


What is that for?

Good luck with solving your Perl problem.


>> where is the call to the "keys" function ?
> sry. forgot to add the keys. (I was playing with the code)


You should have posted your real code.

Now you've used up your 3 minutes already on code that does
not even exist. Oh well.

Good luck with solving your Perl problem.


>> Is that truly the code you have?
> Yes.


No it wasn't.


>> Do you have warnings enabled?
> Nope.


Good luck with solving your Perl problem.


>> You should not post to comp.lang.perl, it was removed about 7 *years*
> ago...
> Works fine.


No it doesn't.


> Thx in advance, Sean


Yeah right.


[snip TOFU]

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


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

Date: Sat, 23 Nov 2002 23:06:12 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: complex foreach loop with deep hashes (sorted hash slices (using an array for keys))
Message-Id: <slrnau0ni4.49v.tadmc@magna.augustmail.com>

Seansan <sheukels=cuthere=@yahoo.co.uk> wrote:

>> > foreach $no (sort {uc @{$LIST{$a}}[$x] cmp uc @{$LIST{$b}}[$x]} keys
> %LIST)
>>                                                                 ^^^
>> where is the call to the "keys" function ?


Why is there now a call to the keys function there?

You are quoting _me_ there.

You don't get to change what I said, that would be forgery.


> sry. forgot to add the keys. (I was playing with the code), 


So we were wasting time debugging code that does not exist.

What is the point of that?



>> Is that truly the code you have?
> Yes.


That code (you snipped it) had no keys() call in it.

Your real code had a keys call in it.

It was not your real code.


>> What's with the one-element slices?
> That how sort works, if I understand correctly that you are refering to  at
> the $a and $b.


You do not understand correctly.

You are using a one-element array slice (that's why I underlined
the at-sign).

See the "Slices" section in

   perldoc perldata


>> Do you have warnings enabled?
> Nope. 


Warnings would have said something about your array slice.


> I'm just interested in the use of hash slices with this particuliar problem


That is a strange thing to say, seeing as there are no hash
slices in that code.


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


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

Date: Sun, 24 Nov 2002 11:07:23 +0000 (UTC)
From: c.c.eiftj@65.usenet.us.com (Rahul Dhesi)
Subject: detecting getpwnam() errors -- how?
Message-Id: <arqbtb$c0n$1@blue.rahul.net>

The problem:
  How to detect an error occurring within the getpw* class of functions.
  When such a function returns empty array or undef, either the user
  does not exist (or in the case of getpwent no more entries are left);
  or an error occurred and we should retry.  I would like to know how to
  tell the difference between 'no such user' and 'an error occurred; try
  again'.

Where I looked:
  The perl faqs do not mention this.  My experiments showed that perl
  5.6.1 on RedHat Linux 7.2 does not seem to set $! after a failure
  within getpwent.  The perl source code for 5.6.1 (in the file
  pp_sys.c) indicates that errno is being saved after the C function
  getpwnam() is called and being restored later, but the comments do not
  indicate that $! should be checked in perl scripts.

  According to The Open Group, the way to detect getpwnam() errors in C
  code is by setting errno to 0 and checking errno if getpwnam() returns
  null. If errno is zero, the user does not exist; if errno is nonzero,
  an error occurred.  Experiments show that on a RedHat Linux 7.2 system
  getpwnam() in a C program sets errno to ENOENT if the user is not
  found, or to some other value if some other error occurs.

I am looking for suggestions.

I don't read this newsgroup, so send replies by email.  (JUST KIDDING!
Please post replies here rather than emailing them.)
-- 
Rahul



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

Date: Sun, 24 Nov 2002 13:59:15 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: disambiguating print (was Re: Basic syntax question on using arrays   returned from function)
Message-Id: <3DE0D9AD.A8FC0EF3@acm.org>

Tad McClellan wrote:
> Dave Tweed <dtweed@acm.org> wrote:
> > I still find it confusing that this doesn't work as I expect if the first
> > argument is a function call that the parser doesn't know about yet. In
> > other words, given
> >
> >    perl -we "print (foo ('x')); sub foo {'Hi'}"
> >
> > the parser still thinks that foo is meant to be a filehandle,
> 
> That is a completely separate thing from the earlier discussion.
> 
>    Subject: disambiguating print
> 
> Was a poor choice on my part, as we were discussing disambiguating
> function arg lists. That is, all functions, not just the
> particular print() function.
> 
> This new issue is about filehandles not being first class data types.

Yes, and this in turn brought about the special comma-less, whitespace-
required syntax used for filehandles in print(f) argument lists, which
I have always felt was a particularly egregious wart.

> So in your case above, I would _still_ not resort to unary plus
> ('cause I'd still have to pause and figure out what the trickery
> was for).
> 
> In that case, if Perl wants a filehandle, I'd just give it a filehandle:
>    print STDOUT (foo ('x'));
> or
>    print (STDOUT foo ('x'));

Not a general solution, as I might have select()ed a different default
filehandle. I'd have to

   print {select} foo ('x');
or
   print ({select} foo ('x')) ... # parens needed to delimit print args

which is a really ugly way to work around a syntax kludge. But I guess
it's the best way to document my intent.

-- Dave Tweed


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

Date: 24 Nov 2002 01:19:09 -0800
From: pularis@go.com (Pularis)
Subject: File Processing question
Message-Id: <aef550d9.0211240119.424ffaec@posting.google.com>

How can I extract a particular word while I am reading a file and then
replace that word with something else ?. I have a plain text file and
I am making an html file out of it and when I see some particular
words I need to insert hmtl liks. I need to keep everything else on
the line intact, just that word needs to be replaced with something
else. Any help will be much appreciated.


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

Date: Sun, 24 Nov 2002 12:42:07 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: File Processing question
Message-Id: <3DE0C8D6.6080404@dev.null>



Pularis wrote:

> How can I extract a particular word while I am reading a file and then
> replace that word with something else ?


Well, there is the good old s/// substitution operator, as in

$text=~s/ask the newsgroup/read the manual/;






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

Date: Sun, 24 Nov 2002 11:06:55 GMT
From: "Blnukem" <blnukem@hotmail.com>
Subject: Re: Find Text in a variable
Message-Id: <jp2E9.34603$op6.27748@news4.srv.hcvlny.cv.net>

Ok that seem's to match to the first ip address of 192.168.1.1 I need to
find the second ip address of 254.52.585.547 in the string shouldnt this
seek to the end of the stirng and find the last ip address of 254.52.585.547

#!/usr/bin/perl

use strict;

my $content = "(mac address: 00-20-52-d7-76-d6) ip address:192.168.1.1subnet
mask:255.255.252.0
dhcpserver:disabled wan:(mac address: 00-24-65-d1-78-b7)
ipaddress:254.52.585.547 subnet mask:255.255.252.0 ";

my ($ip) = $content =~  /ip address:([0-9.]+)/;
print( defined($ip) ? ($ip, "\n") : "No match\n" );





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

Date: Sun, 24 Nov 2002 14:46:25 GMT
From: "robertbu" <robertbu@hotmail.com>
Subject: Re: Find Text in a variable
Message-Id: <5D5E9.9112$Ho2.731@nwrddc04.gnilink.net>


"Blnukem" <blnukem@hotmail.com> wrote in message
news:jp2E9.34603$op6.27748@news4.srv.hcvlny.cv.net...
> Ok that seem's to match to the first ip address of 192.168.1.1 I need to
> find the second ip address of 254.52.585.547 in the string shouldnt this
> seek to the end of the stirng and find the last ip address of
254.52.585.547
>
> #!/usr/bin/perl
>
> use strict;
>
> my $content = "(mac address: 00-20-52-d7-76-d6) ip
address:192.168.1.1subnet
> mask:255.255.252.0
> dhcpserver:disabled wan:(mac address: 00-24-65-d1-78-b7)
> ipaddress:254.52.585.547 subnet mask:255.255.252.0 ";
>
> my ($ip) = $content =~  /ip address:([0-9.]+)/;
> print( defined($ip) ? ($ip, "\n") : "No match\n" );
>

----- Original Message -----
From: "Blnukem" <blnukem@hotmail.com>
Newsgroups: comp.lang.perl.misc
Sent: Sunday, November 24, 2002 3:06 AM
Subject: Re: Find Text in a variable

"Blnukem" <blnukem@hotmail.com> wrote:


> Ok that seem's to match to the first ip address of 192.168.1.1 I need to
> find the second ip address of 254.52.585.547 in the string shouldnt this
> seek to the end of the stirng and find the last ip address of
254.52.585.547
>
> #!/usr/bin/perl
>
> use strict;
>
> my $content = "(mac address: 00-20-52-d7-76-d6) ip
address:192.168.1.1subnet
> mask:255.255.252.0
> dhcpserver:disabled wan:(mac address: 00-24-65-d1-78-b7)
> ipaddress:254.52.585.547 subnet mask:255.255.252.0 ";
>
> my ($ip) = $content =~  /ip address:([0-9.]+)/;
> print( defined($ip) ? ($ip, "\n") : "No match\n" );
>


First off, Benjamin Goldberg's code above is better/more complete than mine,
but I'd toss the defined().  If this code was dropped into a loop, or if $ip
happened to be defined earlier, it would fail.

As for finding the second occurrance, you have many choices.  Here
are three (and I'm far from an expert on regular expressions):

#!/usr/bin/perl

use strict;
use warnings;

my $content = "(mac address: 00-20-52-d7-76-d6) ip address:192.168.1.1subnet
mask:255.255.252.0 dhcpserver:disabled wan:(mac address:
00-24-65-d1-78-b7)ip address:254.52.585.547 subnet mask:255.255.252.0 ";

# Confine the search to text matching at the end of the string
if ($content =~  /ip address:([0-9.]+) subnet mask:[0-9.]+ $/)
  {
  print "$1\n";
  }
else
  {
  print "No match\n";
  }


# print the second occurrance
if ($content =~  /(?:ip address:([0-9.]+).+){2}/)
  {
  print "$1\n";
  }
else
  {
  print "No match\n";
  }

# Put all occurrance in an array
my (@ip) = $content =~  /ip address:([0-9.]+)/g;
if (@ip)
 {
 foreach (@ip)
   {
   print "$_\n";
   }
 }
else
 {
 print "No match";
 }




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

Date: Sun, 24 Nov 2002 15:25:59 GMT
From: "robertbu" <robertbu@hotmail.com>
Subject: Re: Find Text in a variable
Message-Id: <bc6E9.18409$hi6.1274@nwrddc02.gnilink.net>


"robertbu" <robertbu@hotmail.com> wrote in message
news:5D5E9.9112$Ho2.731@nwrddc04.gnilink.net...
>
>  If this code was dropped into a loop, or if $ip
> happened to be defined earlier, it would fail.

Typed before I thought, loop wouldn't cause it to fail, but a previous my
declaration and assignment would cause it to fail.

== Rob ==





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

Date: 23 Nov 2002 22:38:23 -0800
From: paul@torporific.org (Paul Wood)
Subject: hash values ref counted?
Message-Id: <a2702001.0211232238.54f662fc@posting.google.com>

Hi, I've found myself writing something along the lines of...

%hash = (
  'space1.key1' => 1,
  'space1.key2' => 2,
  'space2.key1' => 3,
);

{
  local %hash = map { $_ =~ /^space1\.(.+)/ ? ($1, $hash{$_}) : () }
keys %hash;
  print $hash{'key1'}, "\n"; # prints 1
}

Now, does locally changing the name of the keys make an extra copy of
the value? I'm just worried because they may be big strings.

Thanks.


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

Date: 23 Nov 2002 22:41:03 -0800
From: trent@autoimages.com (Trent Hare)
Subject: Help with grep + hash value
Message-Id: <bc421eed.0211232241.7b78f131@posting.google.com>

Hi Gents and Ladies - 

I'm stuck...
Is it possible to add a regex to the hash value "$_" in order to
excude more items from being pushed into the @orphanpics??

______code snippet_____

push @orphanpics, grep {not exists $h{$_}} @pictures;
                                      ^^^

Any help appreciated.
Trent


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

Date: Sun, 24 Nov 2002 07:33:34 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Help with grep + hash value
Message-Id: <3de07f6b.239019080@news.erols.com>

trent@autoimages.com (Trent Hare) wrote:

: I'm stuck...
: Is it possible to add a regex to the hash value "$_" in order to
: excude more items from being pushed into the @orphanpics??
: 
: ______code snippet_____
: 
: push @orphanpics, grep {not exists $h{$_}} @pictures;

Nothing to it.

If you want to exclude based on the hash key,

    grep { /your regex here/ && not exists $h{$_} } @pictures;

If you want to exclude based on the hash value,

    grep { $h{$_} =~ /your regex here/ && not exists $h{$_} } @pictures;



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

Date: Sun, 24 Nov 2002 07:43:13 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: Help with grep + hash value
Message-Id: <3de08289.239817639@news.erols.com>

tiltonj@erols.com (Jay Tilton) wrote:

: If you want to exclude based on the hash value,
: 
:     grep { $h{$_} =~ /your regex here/ && not exists $h{$_} } @pictures;

I wasn't paying close enough attention.  That line is just silly.



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

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


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