[26878] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8878 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 23 11:05:32 2006

Date: Mon, 23 Jan 2006 08:05:04 -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           Mon, 23 Jan 2006     Volume: 10 Number: 8878

Today's topics:
    Re: 3 layer hash <abigail@abigail.nl>
    Re: 3 layer hash <abigail@abigail.nl>
    Re: Blather-Adjusting Programs vjp2.at@at.BioStrategist.dot.dot.com
    Re: Blather-Adjusting Programs vjp2.at@at.BioStrategist.dot.dot.com
    Re: cpp-style include for perl? axel@white-eagle.invalid.uk
        Fetish adult sexy contacts <ssvcwvts@qrtcvurq.com>
    Re: gunzip stdin stream? (Anno Siegel)
    Re: Scanning file version 2.0 <thundergnat@hotmail.com>
    Re: Trim Double Byte Charaters in Text. <jurgenex@hotmail.com>
    Re: Trim Double Byte Charaters in Text. <thundergnat@hotmail.com>
    Re: use list to assign hash... <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 23 Jan 2006 02:04:56 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: 3 layer hash
Message-Id: <slrndt8ee8.s0s.abigail@alexandra.abigail.nl>

non@non.non (non@non.non) wrote on MMMMDXXVIII September MCMXCIII in
<URL:news:89a8t15ma24n2bam7cc9hs4pv676sfq5hu@4ax.com>:
!!  
!! >:)  the keys in layer 1 and 3 are constant.. the changing key is layer 2.
!! >:)  i need to loop through without knowing..
!! >
!! >
!! >I'd use 'each':
!! >
!! >    while (my ($key, $value) = each %{$hash {name1}}) {
!! >        my $element = $$value {$name3};
!! >        ...
!! >    }
!!  
!!  
!!  Thank you that works great :)
!!  
!!  I have
!!  x1 {name1} 
!!  	->x? {unknown} 
!!  		->  x5 {name3}
!!  
!!  Your answer loops through main1 which i only have 1 or does it go
!!  through each layer automatically and simply store all keys-values

Eh? I've no idea what you are asking here.

!!  $$value {$name3} works perfectly but how does it know to get the data
!!  from layer three...

It knows to get it from level three because I tell it so. $value is "level2",
indexing it with name3 gets you one level further. There's no magic involved.

!!                      suppose the key-value of name3 also exists in
!!  name2 ?  

That question doesn't make any sense. 



Abigail
-- 
perl -wle 'print prototype sub "Just another Perl Hacker" {};'


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

Date: 23 Jan 2006 02:06:40 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: 3 layer hash
Message-Id: <slrndt8ehg.s0s.abigail@alexandra.abigail.nl>

non@non.non (non@non.non) wrote on MMMMDXXVIII September MCMXCIII in
<URL:news:tia8t11me6qnibnt14g4t1hc4nhr9f31qe@4ax.com>:
##  O
## >I apologise for the no brainers... but i would like to learn as well
## >as use the answer... please :)
##  
##  
##  Because I need to know the value of the key ie {name2} (as well). can
##  you help with that please?


What do you think the first return value of 'each' is? Hint, the variable
named '$key' wasn't constructed by rolling a 26 face die three times.


Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: Mon, 23 Jan 2006 03:06:41 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Blather-Adjusting Programs
Message-Id: <dr1h80$cq4$1@reader2.panix.com>

   I have one idea: you score each verb and noun on, say, five,
different scales, then you pile on similarly ranked adverbs and
adjectives until you meet the volume requirement. Or you remove
accordingly. In MS-Word type environments, you score less necessary
modifiers, say , with orange-collored undersquiggles, the less
necessary, the more undersquiggles.

				- = -
    Vasos-Peter John Panagiotopoulos II, Columbia'81+, Bio$trategist
	      BachMozart ReaganQuayle EvrytanoKastorian
       http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Guilty conscience produces extremism] [Urban sprawl confounds terror]
   [Homeland Security means private firearms not lazy obstructive guards]



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

Date: Mon, 23 Jan 2006 03:06:58 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: Re: Blather-Adjusting Programs
Message-Id: <dr1h8i$cq4$2@reader2.panix.com>

talk about black holes



				- = -
    Vasos-Peter John Panagiotopoulos II, Columbia'81+, Bio$trategist
	      BachMozart ReaganQuayle EvrytanoKastorian
       http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
  ---{Nothing herein constitutes advice.  Everything fully disclaimed.}---
   [Guilty conscience produces extremism] [Urban sprawl confounds terror]
   [Homeland Security means private firearms not lazy obstructive guards]



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

Date: Mon, 23 Jan 2006 13:31:07 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: cpp-style include for perl?
Message-Id: <vU4Bf.6366$wl.1011@text.news.blueyonder.co.uk>

Mike Ballard <dont_w@nt_spam.org> wrote:
 
> I have a number of scripts where many have identical blocks of code
> (subroutines, some variable setting, etc.); have been reading through some
> posts on packages/use/require and am getting a little lost in the
> intricacies when really all I'm looking for is a cpp-style "#include" stmt
> ("C preprocessor", not C++) - is there anything like that for perl?

Yes. The cpp :)

Command line switch -P...  but see the warnings in perldoc perlrun.
 
Axel



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

Date: Sat, 21 Jan 2006 01:12:05 +0000
From: "Sexy Couple" <ssvcwvts@qrtcvurq.com>
Subject: Fetish adult sexy contacts
Message-Id: <#$n9iCvHGHA.3716@winisp-ti82.winisp.net>

Kinky couple looking to explore our fantasies.
And indulge in various pleasures of the flesh.

Find us at : www.passionjuicy.co.uk

Profile..




03437


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

Date: 23 Jan 2006 12:02:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: gunzip stdin stream?
Message-Id: <dr2gk7$lqe$2@mamenchi.zrz.TU-Berlin.DE>

Markus Dehmann  <markus.dehmann@gmail.com> wrote in comp.lang.perl.misc:
> I have a convenient way to open possibly gzip'ed files:
> 
> open(F, ($f =~ m/\.gz$/) ? "gunzip -c $f |" : "$f");
> 
> So, if the file name ends in .gz I send it through gunzip.  So far, so 
> good. (I don't want to use the PerlIO:Gzip module because it's not 
> installed by default, so it's a hassle.)
> 
> But now, my script should be callable in the following ways:
> $ cat data | ./script.pl
> $ ./script.pl data.gz
> $ ./script.pl data
> 
> Usually, I would just use the while loop: while(<>){...}. But that does 
> not read gzip'ed data.
> 
> How would you handle that? I could think of the following code, but it's 
> long and not nice ...

[snip]

    /\.gz$/ and $_ = "gunzip -c $_ |" for @ARGV;
    print while <>;

Anno
-- 
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article.  Click on 
"show options" at the top of the article, then click on the 
"Reply" at the bottom of the article headers.


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

Date: Mon, 23 Jan 2006 09:53:24 -0500
From: thundergnat <thundergnat@hotmail.com>
Subject: Re: Scanning file version 2.0
Message-Id: <LNCdneZKVvl7cEneRVn-tQ@rcn.net>

Raghuramaiah Gompa wrote:
> In article <GYednQNUg8-_ElPeRVn-hg@rcn.net>,
> thundergnat  <thundergnat@hotmail.com> wrote:

>>
>>Here's a quick rewrite of your script to correct all of
>>the above problems,
>>with some other minor enhancements.
>>
> 
> snip  --- snip ----

> I wonder whether this code can be modifed to "highlight 
> all instances of text between quotes".  For example, if 
> the previous 
> sentence is in a file, the code should show the line with 
> red color for "highlight all instances of text between 
> quotes".  Is it possible? ..  Raghu 
> 

Yes. It's possible. Though iy may be easier if you take a
slightly different approach. I wrote a little demo script
not too long ago that does that.... (rumage, rumage...)


Here you go: http://www.perlmonks.org/?node_id=522464

try a search string like:

(?<=')\b[^']+\b(?=')

for single quotes or 

(?<=")\b[^"]+\b(?=")

for double quotes.


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

Date: Mon, 23 Jan 2006 15:12:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Trim Double Byte Charaters in Text.
Message-Id: <Pn6Bf.2647$jO3.1966@trnddc07>

OttawaTrade wrote:
> I wonder if there is an easier way to delete double byte charators
> from text.

Easier than what?
And what exactly do you mean by "double byte characters"?

If a character is encoded in a single byte or multiple bytes depends very 
much on the encoding that you are using. Therefore saying double byte 
without naming the encoding doesn't make much sense.

On a different note I highly doubt that randomly removing part of your data 
will increase its quality, but of course that is your call to make.

I at least would be quite annoyed if you'd sent a letter to Jrgen Exner

jue 




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

Date: Mon, 23 Jan 2006 10:22:15 -0500
From: thundergnat <thundergnat@hotmail.com>
Subject: Re: Trim Double Byte Charaters in Text.
Message-Id: <ouKdneaTyp40aUnenZ2dnUVZ_sidnZ2d@rcn.net>

yong wrote:
> OttawaTrade wrote:
> 
>> I wonder if there is an easier way to delete double byte charators from
>> text. The main reason for me to do this is to save space in mysql, 
>> because I
>> want to use TEXT instead of MEDIUMTEXT.
>>
>>
> 
> try \X .
> 
> It's represents a unicode char in Regular Express.


Ummm. That would certainly save space. You DO realize that characters
like a, g, R, M, %, & ? (to name just a few) are Unicode characters
don't you?



my $sentence = 'Is this Unicode? àèìòù';
$sentence =~ s:\X::g;
print "$sentence Apparently so...";


prints

 Apparently so...


If you are trying to find non-ascii characters you are better off
looking specifically for non-ascii characters.

try 

$sentence =~ s/[^[:ascii:]]//g;

instead.


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

Date: Mon, 23 Jan 2006 06:35:10 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: use list to assign hash...
Message-Id: <slrndt9jbu.4h2.tadmc@magna.augustmail.com>

Sean <seanatpurdue@hotmail.com> wrote:
> After the following code, memory of hash is like
> {
> "fact"=>undef,
> "story"=>undef,
> }
> Is it true?


Yes.


> ----------------------------
> #!/usr/bin/perl;
> use strict;
> my %hash;
> my @my_list = ("fact", "story");
> @hash{@my_list} =();
> -------------------------------


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


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8878
***************************************


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