[18895] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1063 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 5 14:10:45 2001

Date: Tue, 5 Jun 2001 11:10:20 -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: <991764620-v10-i1063@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 5 Jun 2001     Volume: 10 Number: 1063

Today's topics:
    Re: Deleting old files <cochise@sky.net>
    Re: Deleting old files (Randal L. Schwartz)
    Re: Deleting old files (Craig Berry)
    Re: Dereferencing undefined value <uri@sysarch.com>
        Editing a single line in file (Perrera)
    Re: Editing a single line in file (Tad McClellan)
    Re: Editing a single line in file <keesh@users.sf.net>
    Re: Editing a single line in file <rsherman@ce.gatech.edu>
    Re: hash array (M.J.T. Guy)
    Re: How can I generate unique number combinations? <pkrupa@redwood.rsc.raytheon.com>
    Re: How can I generate unique number combinations? (Tad McClellan)
    Re: How can I generate unique number combinations? (Greg Bacon)
        Intercepting Internet Requests (Babber)
    Re: Matching expresions problem (Greg Bacon)
    Re: Newbie guide <c-kleinheitz@freenet.de>
        Newbie Question <nick_deller@hotmail.com>
    Re: Newbie Question (John Joseph Trammell)
    Re: Newbie Question (Helgi Briem)
        Newbie: $ character end string? What is wrong? <radiotito@yahoo.com>
    Re: Newbie: $ character end string? What is wrong? <keesh@users.sf.net>
    Re: Newbie: $ character end string? What is wrong? (John Joseph Trammell)
    Re: Newbie: $ character end string? What is wrong? <andras@mortgagestats.com>
    Re: Newbie: $ character end string? What is wrong? <uri@sysarch.com>
    Re: OT :: What to do if you've been kill filed <godzilla@stomp.stomp.tokyo>
    Re: OT :: What to do if you've been kill filed <lmoran@wtsg.com>
        pack = lousy performance <NoSpam@SpammerKiller.com>
    Re: pack = lousy performance <thunderbear@bigfoot.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 05 Jun 2001 10:41:43 -0500
From: Steve <cochise@sky.net>
Subject: Re: Deleting old files
Message-Id: <3B1CFDB7.BA17C5AB@sky.net>

I wrote:
> 
> Is there a way to delete files that are older that a certain time?
> 
> I've got some temporary graphics whose names are based on the time that
> they were created using localtime.
> 
>         991680688.gif
>         991679373.gif
>         etc.


I appreciate all of the suggestions ... to be honest, I don't really
understand a few of them :(.  This is what I came up with:

	## Delete temporary .gif files that are older than 12 hours

	@FILES = grep -M > .5, <9*.gif>;

	foreach $FILES (@FILES) {
		unlink $FILES;
	}

Seems to work fine.  As September 8th approaches I guess I'll need to
change my time based naming system away from Unix Epoch.

Thanks for everyone's help!

Steve


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

Date: 05 Jun 2001 09:18:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Deleting old files
Message-Id: <m1d78ihpd3.fsf@halfdome.holdit.com>

>>>>> "Steve" == Steve  <cochise@sky.net> writes:

Steve> I wrote:
>> 
>> Is there a way to delete files that are older that a certain time?
>> 
>> I've got some temporary graphics whose names are based on the time that
>> they were created using localtime.
>> 
>> 991680688.gif
>> 991679373.gif
>> etc.


Steve> I appreciate all of the suggestions ... to be honest, I don't really
Steve> understand a few of them :(.  This is what I came up with:

Steve> 	## Delete temporary .gif files that are older than 12 hours

Steve> 	@FILES = grep -M > .5, <9*.gif>;

Steve> 	foreach $FILES (@FILES) {
Steve> 		unlink $FILES;
Steve> 	}

unlink takes a list, so you can shorten this to:

unlink grep -M > 0.5, <9*.gif>;

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 05 Jun 2001 18:01:29 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Deleting old files
Message-Id: <thq7jp64oq11b7@corp.supernews.com>

Steve (cochise@sky.net) wrote:
: 	@FILES = grep -M > .5, <9*.gif>;
: 
: 	foreach $FILES (@FILES) {
: 		unlink $FILES;
: 	}

By convention, ordinary perl variables are mixed or lower-case.  Following
this convention will make you code more readable by others and cleaner
looking when mixing your own names with those imported from modules.

Also, it's a useful habit to give simple scalars singular rather than
plural names.

Given that unlink takes a list of files, you can express your approach
more compactly as

  unlink grep -M > .5, <9*.gif>;

: Seems to work fine.  As September 8th approaches I guess I'll need to
: change my time based naming system away from Unix Epoch.

Or continue using the epoch time, but stop counting on its starting with
9. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "God becomes as we are that we may be as he is."
   |               - William Blake


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

Date: Tue, 05 Jun 2001 16:35:30 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Dereferencing undefined value
Message-Id: <x7y9r6yje5.fsf@home.sysarch.com>

>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:

  TM> foreach provides an "lvalue context" (due to its aliasing, I suppose),
  TM> so autoviv occurs.

  TM> Looks like if() does not provide lvalue context?

good points on the lvalue vs rvalue. (randal noted them too).

  TM> autoviv gets not enough coverage in the docs, but at least you
  TM> know the search term to use now.

which is why i wrote a tutorial on autoviv:

http://tlc.perlarchive.com/articles/perl/ug0002.shtml

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: 5 Jun 2001 08:31:39 -0700
From: felipe16@chilesat.net (Perrera)
Subject: Editing a single line in file
Message-Id: <2dc5f482.0106050731.5db9667c@posting.google.com>

I need to edit one line of a flat datafile.  How do I do this?  The
editing will be done throught the web through a form.

Thanks for your help...


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

Date: Tue, 5 Jun 2001 10:52:13 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Editing a single line in file
Message-Id: <slrn9hpsgt.2rh.tadmc@tadmc26.august.net>

Perrera <felipe16@chilesat.net> wrote:

>I need to edit one line of a flat datafile.  How do I do this?
                ^^^^^^^^
                ^^^^^^^^


By checking the Perl FAQ *before* posting to the Perl newsgroup:

   perldoc -q "one line"

       How do I change one line in a file/delete a line in a
       file/insert a line in the middle of a file/append to the
       beginning of a file?


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


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

Date: Tue, 05 Jun 2001 15:44:11 GMT
From: "Ciaran McCreesh" <keesh@users.sf.net>
Subject: Re: Editing a single line in file
Message-Id: <f77T6.5516$IY1.947624@news1.cableinet.net>

In article <2dc5f482.0106050731.5db9667c@posting.google.com>, "Perrera"
<felipe16@chilesat.net> said:
> I need to edit one line of a flat datafile.  How do I do this?  The
> editing will be done throught the web through a form.  Thanks for your
> help...

perldoc perlfaq5

HTH

-- 
Ciaran McCreesh
mail:         keesh at users dot sf dot net
web:          http://www.opensourcepan.com


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

Date: Tue, 05 Jun 2001 11:54:56 +0500
From: Robert Sherman <rsherman@ce.gatech.edu>
Subject: Re: Editing a single line in file
Message-Id: <3B1C8240.AEB0D039@ce.gatech.edu>

Perrera wrote:

> I need to edit one line of a flat datafile.  How do I do this?  The
> editing will be done throught the web through a form.
>
> Thanks for your help...

depends on your criteria for determining which line to edit...perhaps a
pattern match, or make use of seek or $.  (that's a special variable,
btw, not just a $).

for more info try perldoc -q line

-rob



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

Date: 5 Jun 2001 16:50:38 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: hash array
Message-Id: <9fj2ku$n3e$1@pegasus.csx.cam.ac.uk>

Ren Maddox  <ren@tivoli.com> wrote:
>
>This has the side effect of leaving "x" around as a key in %hash.  The
>value is gone, because of the local, but the key is still there.
>
>Actually, something strange seems to happen as a result of that
>"local".  The key survives the block even if it is explicitly deleted
>within the block.  I assume the "restore the old value" aspect of
>"local" is (re-)creating the key upon exit of the block.

Yes.  That's exactly what's happening.

local() has some rather odd semantics when you poke in the dustier
corners ...


Mike Guy


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

Date: Tue, 05 Jun 2001 09:09:23 -0600
From: "Peter A. Krupa" <pkrupa@redwood.rsc.raytheon.com>
Subject: Re: How can I generate unique number combinations?
Message-Id: <3B1CF623.8ABBD6CE@redwood.rsc.raytheon.com>

>perldoc -q permute
Found in C:\Perl\lib\pod\perlfaq4.pod
  How do I permute N elements of a list?

            Here's a little program that generates all permutations of all

            the words on each line of input. The algorithm embodied in the

            permute() function should work on any list:

                #!/usr/bin/perl -n
                # tsc-permute: permute each word of input
                permute([split], []);
                sub permute {
                    my @items = @{ $_[0] };
                    my @perms = @{ $_[1] };
                    unless (@items) {
                        print "@perms\n";
                    } else {
                        my(@newitems,@newperms,$i);
                        foreach $i (0 .. $#items) {
                            @newitems = @items;
                            @newperms = @perms;
                            unshift(@newperms, splice(@newitems, $i, 1));
                            permute([@newitems], [@newperms]);
                        }
                    }
                }



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

Date: Tue, 5 Jun 2001 10:14:28 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How can I generate unique number combinations?
Message-Id: <slrn9hpqa4.2m8.tadmc@tadmc26.august.net>

Chris Spurgeon <cspurgeon@electronicink.com> wrote:
>Given a series of digits, I want to generate all of the different ways
>they can be arranged.


What you want are "permutations" not "combinations".

   perldoc -q permute

The code there processes non-space chunks, to get it to process
individual characters instead, change this line:

    $_ = '12345';
    permute([split //], []);
                   ^^
                   ^^  split on empty string


>I wrote the following script, 

>it just strikes me as very
>inelegant and inefficient.  And it will only get worse as the number
>of digits increases.  My question is, is there a prettier way to do
>this?


Recursion to the rescue!


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


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

Date: Tue, 05 Jun 2001 18:04:23 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: How can I generate unique number combinations?
Message-Id: <thq7p74vil7he6@corp.supernews.com>

In article <5643c417.0106050640.604f34ce@posting.google.com>,
    Chris Spurgeon <cspurgeon@electronicink.com> wrote:

: Given a series of digits, I want to generate all of the different ways
: they can be arranged. [...]

As Tad suggested, use recursion.

If you're given a list of length one, then there's nothing to do.
Otherwise, shift off the first element and compute all permutations
of the shortened list.  Then take the shifted element and stick it
in all the available slots (i.e., at the front, between all elements,
and at the rear).

    #! /usr/local/bin/perl -w

    use strict;

    sub perm {
        my @items = @_;

        # nothing to do if only one (or none) items
        return [ @items ] if @items <= 1;

        # pull off the first element
        my $first = shift @items;

        my @result;
        # permute the shortened list
        for ( perm(@items) ) {
            # stick the saved item on the front
            push @result, [ $first, @$_ ];

            # stick the saved item after every element
            for (my $i = 1; $i <= @$_; ++$i) {
                push @result, [ @{$_}[0..$i-1], $first, @{$_}[$i..$#$_] ];
            }
        }

        @result;
    }

    die "Usage: $0 [arg]\n" unless @ARGV;

    my @a = split //, shift;

    for (perm @a) {
        print join('', @$_), "\n";
    }

Hope this helps,
Greg
-- 
One of the paradoxes of software engineering is that people with bad ideas
and low productivity often think of themselves as supremely capable. They
are the last people whom one can expect to fall in line with a good strategy
developed by someone else.  -- Phil Greenspun


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

Date: 5 Jun 2001 10:47:33 -0700
From: babberc@yahoo.co.uk (Babber)
Subject: Intercepting Internet Requests
Message-Id: <1d1c61a1.0106050947.6210d9f3@posting.google.com>

I am writing a program using perl which automatically send requests to
web sites to retrieve information. In my case, I want to search a
newpaper's site
for particular adverts. The site uses .cfm which I think is
ColdFusion. I want to know how to intercept what is sent to the web
site when the "search" button on Internet Explorer is pressed so that
I can use that information in a HTTP Request. I have had success with
cgi
requests, because what is being sent out appears in the address bar of
Internet Explorer, but can't figure this one out. Any help would be
appreciated

Babber


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

Date: Tue, 05 Jun 2001 15:59:30 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Matching expresions problem
Message-Id: <thq0f2ies1cp55@corp.supernews.com>

In article <3B1CEC1A.E60073B5@americasm01.nt.com>,
    Luan, Hao [SKY:QE21:EXCH] <hluan@americasm01.nt.com> wrote:

: I have some problems to understand the behavior of the matching
: result. Here is the code
:
: [snip code]
:
: The purpose of the code is to add in extra string the signal name in
: force -nets/pins clause. The signal name sometimes is plain string,
: sometimes is plain string with "" However, I don't want to add in
: this extra string if the signal name start with $ or [. here is my
: test file
:
: [snip input]
:
: Now is the result
: ====
: process_force.pl test.set log.set
: force -pins "TOP.GND"
: force -pins TOP.vdd
: force -pins  TOP.vdd
: force -phase * -pins  TOP.vdd
: force -pins             TOP.vdd
: force -nets "TOP.high_fanout"
: force -nets [high_fanout]
: force -nets $high_fanout]
: force -nets "TOP. $high_fanout] <-------A
: force -nets "TOP. [high_fanout] <-------B
: force -nets "TOP.high_fanout]"
: force -nets TOP.low_fanout
: ===========================================
: everything is fine expect A, B lines should not be changed.

I believe the following code produces the desired output:

    % cat try
    #! /usr/local/bin/perl -w

    use strict;

    while (<DATA>) {
        if (/force/ && !/^\#/){
            if (/(force.*-(?:pins|nets)\s+)(.+)/) {
                my $cmd  = $1;
                my $arg = $2;

                print;
                if ($arg =~ /^(?:"\s*)?[\$\[]/) {
                    print;
                }
                else {
                    $arg =~ s/^("?)\s*/$1TOP./;
                    print $cmd, $arg, "\n";
                }
                print "\n";
            }
        }
    }
    __DATA__
    force -pins "GND"
    force -pins vdd
    force -pins  vdd
    force -phase * -pins  vdd
    force -pins             vdd
    force -nets "high_fanout"
    force -nets [high_fanout]
    force -nets $high_fanout]
    force -nets "   $high_fanout]
    force -nets "   [high_fanout]
    force -nets "   high_fanout]"
    force -nets low_fanout
    % ./try
    force -pins "GND"
    force -pins "TOP.GND"

    force -pins vdd
    force -pins TOP.vdd

    force -pins  vdd
    force -pins  TOP.vdd

    force -phase * -pins  vdd
    force -phase * -pins  TOP.vdd

    force -pins             vdd
    force -pins             TOP.vdd

    force -nets "high_fanout"
    force -nets "TOP.high_fanout"

    force -nets [high_fanout]
    force -nets [high_fanout]

    force -nets $high_fanout]
    force -nets $high_fanout]

    force -nets "   $high_fanout]
    force -nets "   $high_fanout]

    force -nets "   [high_fanout]
    force -nets "   [high_fanout]

    force -nets "   high_fanout]"
    force -nets "TOP.high_fanout]"

    force -nets low_fanout
    force -nets TOP.low_fanout

Hope this helps,
Greg
-- 
The right to dispose of one's income belongs to the producer, and if he
wishes to give it to an heir, a charity, or to flush it down the toilet--
that is the producer's right. It is not any of your concern, and it certainly
is not the concern of the government.        -- Ayn Rand


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

Date: Tue, 05 Jun 2001 15:27:24 +0200
From: Christopher Kleinheitz <c-kleinheitz@freenet.de>
Subject: Re: Newbie guide
Message-Id: <3B1CDE3C.D3289CE2@freenet.de>

Hi,

Kevin Kirwan schrieb:

> I'm just starting out learning PERL.  Anyone have any suggestions as to
> "how-to" guides, or web-tutorials that would help an old ksh script hack
> learn PERL?

There is no way to learn PERL but if you want to learn Perl look at
http://www.perl.com

HTH

Chris

--
Christopher Kleinheitz Offenburg Germany http://jahresarbeit.virtualave.net
"Der Dienst wird mit der dem Wesen des Eisenbahnbetriebs entsprechenden
Raschheit, aber ohne Überstürzung ausgeführt" Dienstvorschrift 408 der Bahn




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

Date: Tue, 5 Jun 2001 17:30:16 +0100
From: "only1britney.com" <nick_deller@hotmail.com>
Subject: Newbie Question
Message-Id: <8O7T6.1527$YB3.329442@news2-win.server.ntlworld.com>

I am a complete newbie and I need a few answers.
dont get too excited they are actual probably an insult to most of yours
inteligernce.
Anyway

1. What is better perl/cgi
2. If they are both the same how does each one differ
3. Which perl/cgi program do you recommend for a beginner.  I am not willing
to spend any money at this stage

Thanking you all in advance






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

Date: Tue, 05 Jun 2001 16:52:06 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: Newbie Question
Message-Id: <slrn9hq10s.qe4.trammell@bayazid.hypersloth.net>

On Tue, 5 Jun 2001 17:30:16 +0100, <nick_deller@hotmail.com> wrote:
> 
> 1. What is better perl/cgi
> 2. If they are both the same how does each one differ

This is like asking "which is better: bricks or houses?".  Perl
is something you can use to build a CGI program; you can use it
to build other things too.

> 3. Which perl/cgi program do you recommend for a beginner.  I
> am not willing to spend any money at this stage

I think your time would be better spent learning what CGI and
Perl are; perhaps you should take a trip to the library?

-- 
Just Another Perl Hacker.


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

Date: Tue, 05 Jun 2001 17:03:57 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: Newbie Question
Message-Id: <3b1d0e9b.547972623@news.isholf.is>

On Tue, 5 Jun 2001 17:30:16 +0100, "only1britney.com"
<nick_deller@hotmail.com> wrote:

>I am a complete newbie and I need a few answers.
>dont get too excited they are actual probably an insult to most of yours
>inteligernce.
>Anyway
>
>1. What is better perl/cgi
>2. If they are both the same how does each one differ

Apples and oranges.  CGI stands for Common Gateway 
Interface and is a protocol to describe how web servers
can run programs using data submitted to them from a
web form and return the results.

Perl is a programming language that can be used to write
a CGI application, but you can use almost all programming
languages to write CGI, including C, Basic, Pascal or shell
script.

>3. Which perl/cgi program do you recommend for a beginner.  I am not willing
>to spend any money at this stage

I would not recommend any "perl/cgi program" for a beginner.
If you are interested in learning how to program, Perl is 
quite a good choice, but remember that learning the basics
of programming in general may take a while.  If you want to 
use Perl to write a CGI application, there is a superb 
module or set of pre-written functions called CGI.pm that
almost always comes pre-installed with Perl on any computer
that has Perl.

Some good sites for further info:

www.perldoc.com
www.activestate.com
www.perl.com
http://www.perl.org/CGI_MetaFAQ.html

Regards,
Helgi Briem


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

Date: Tue, 05 Jun 2001 18:54:00 +0200
From: Valentin 30IR976 <radiotito@yahoo.com>
Subject: Newbie: $ character end string? What is wrong?
Message-Id: <3B1D0EA8.90D84703@yahoo.com>

Hello people, and sorry for this newbie question.

I have this code:

------------------------------------
$string="Hello world";

if ($string =~ /$Hello/)
{
        print"Hello is at the the end\n";
}

----------------------------------------
And...what does the message print? $Hello doesnt match if Hello appears
at the end of $string?

Many thanks ...

Tito



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

Date: Tue, 05 Jun 2001 17:00:54 GMT
From: "Ciaran McCreesh" <keesh@users.sf.net>
Subject: Re: Newbie: $ character end string? What is wrong?
Message-Id: <af8T6.5807$IY1.999092@news1.cableinet.net>

In article <3B1D0EA8.90D84703@yahoo.com>, "Valentin 30IR976"
<radiotito@yahoo.com> said:
> Hello people, and sorry for this newbie question.  I have this code:

Keep newbie out of the subject to avoid annoying people.

> if ($string =~ /$Hello/)

/$Hello/ won't match because it means "The end of the string followed by
'Hello'", which ain't possible (ignoring modifiers). You're probably
after /Hello$/ , which means "'Hello' followed by the end of the string".

-- 
Ciaran McCreesh
mail:         keesh at users dot sf dot net
web:          http://www.opensourcepan.com


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

Date: Tue, 05 Jun 2001 17:02:44 GMT
From: trammell@bayazid.hypersloth.invalid (John Joseph Trammell)
Subject: Re: Newbie: $ character end string? What is wrong?
Message-Id: <slrn9hq1kq.qhs.trammell@bayazid.hypersloth.net>

On Tue, 05 Jun 2001 18:54:00 +0200, Valentin 30IR976 wrote:
> Hello people, and sorry for this newbie question.
> 
> I have this code:
> 
> ------------------------------------
> $string="Hello world";
> 
> if ($string =~ /$Hello/)
> {
>         print"Hello is at the the end\n";
> }

if ($string =~ /^Hello/)
{
    print "Hello is at the the beginning\n";
}

if ($string =~ /Hello$/)
{
    print "Hello is at the the end\n";
}

Hope that helps.

-- 
Torg: Quick, blow up that shiny thing!
Kiki: Ooooh!


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

Date: Tue, 05 Jun 2001 13:13:01 -0400
From: Andras Malatinszky <andras@mortgagestats.com>
Subject: Re: Newbie: $ character end string? What is wrong?
Message-Id: <3B1D131D.4662ED6D@mortgagestats.com>



Valentin 30IR976 wrote:

> Hello people, and sorry for this newbie question.
>
> I have this code:
>
> ------------------------------------
> $string="Hello world";
>
> if ($string =~ /$Hello/)
> {
>         print"Hello is at the the end\n";
> }
>
> ----------------------------------------
> And...what does the message print? $Hello doesnt match if Hello appears
> at the end of $string?
>
> Many thanks ...
>
> Tito

I'm sure you have run your code and you have found that it prints

        Hello is at the end

The reason is, that Perl looks at the pattern that you are trying to match
and sees the scalar variable $Hello in there. $Hello contains nothing, and
there are several instances of nothing in $string. For example, there is
nothing before the H in Hello, and that nothing will match your regexp. I
presume this is not what you wanted.

If you want to use $ to indicate that you are looking for a match at the
end of  $string, you want to put it at the end of your regexp like this:

$string =~ /Hello$/

This tells Perl to look for the following sequence of symbols

H, e, l, l, o, <end-of-line>

I hope this helps.




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

Date: Tue, 05 Jun 2001 17:19:23 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Newbie: $ character end string? What is wrong?
Message-Id: <x7vgmayhd0.fsf@home.sysarch.com>

>>>>> "CM" == Ciaran McCreesh <keesh@users.sf.net> writes:

  >> if ($string =~ /$Hello/)

  CM> /$Hello/ won't match because it means "The end of the string
  CM> followed by 'Hello'", which ain't possible (ignoring
  CM> modifiers). You're probably

actually it means "interpolate the variable $Hello and use its value as
the regular expression". $ only means end of string anchor if it is at
the end of the regex (or subregex).

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info:     http://www.sysarch.com/perl/OOP_class.html


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

Date: Tue, 05 Jun 2001 10:33:10 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: OT :: What to do if you've been kill filed
Message-Id: <3B1D17D6.26291022@stomp.stomp.tokyo>

Lou Moran wrote:
 
> --So let's say you get kill filed what do you do to be un kill filed?
> Short of changing your identity that is.


Killfiles are for ostrichlike weenies.

I would rather be killfiled and remain killfiled.

I consider being killfiled a blessing, at least for those
cases where I am actually killfiled, which is rare. Most
often, a claim of a killfile is lie.

As it applies to this group, announcements of killfiling
amounts to nothing more than gorilla like chest pounding
ego behavior, as if gorillas actually pound their chests.

There is a person here who appears under myriad fakenames
whom encourages others to killfile a person, most often, 
infamous Godzilla! His exhibited behavior is quite contrary 
to his true thoughts.

 "I hope people killfile her because I don't want others
  reading her correcting my mistakes and, she scares the
  crap out of me."

This is, of course, his unhealthy fragile masculine ego speaking,
as is the case with most others whom announce killfiling.

Killfiles are for ostrichlike weenies.

Being truly killfiled is a blessing from my perspective.
Those who killfile me are people I consider to be less
than intelligent and certainly hateful. It is a blessing
to not be annoyed by them via responses to my articles;
they are killfiling themselves, for me.

Should I killfile, which I don't, I would killfile all
articles orginating from google.com, or bearing a return
address of yahoo, mailcom and similar anonymous remailers.
My experience is literally all articles originating from
google and those with an address of yahoo, are trolls.


Killfiling me it truly a blessing. Make it so.


Godzilla!


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

Date: Tue, 05 Jun 2001 14:01:27 -0400
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: OT :: What to do if you've been kill filed
Message-Id: <ka7qht497f7r2q6hi2tmm23kv4u4gpgq8p@4ax.com>

On 5 Jun 2001 11:14:02 GMT, rachel@lspace.org (Rachel Coleman) wrote
wonderful things about sparkplugs:

SNIP
>I think you also have to look at why you were killfiled and why that
>bothers you.  Why do you want a particular person to read your posts? 
SNIP

I should begin by mentioning that I don' think I have been killfiled
by anyone here.  (or anywhere else.) I was wondering with the large
amount of plonk(ing) and public KFs what a person who is normally a
decent person but had a bad posting day (or whatever would do.)

Personally I think it would baother me a lot if I was KF'ed as I try
not to ask too may *bad* questions.  I have found www sites to be
*easier* on *bad* questions, ut I like it here.  I don't even mind
most of the yelling.  

<shrug>I was asking as *sort of* a public service.</shrug> 


--
BSOD? In my day we didn't have 0000FF!
lmoran@wtsg.com


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

Date: Tue, 05 Jun 2001 12:42:26 -0400
From: Spammer Killer <NoSpam@SpammerKiller.com>
Subject: pack = lousy performance
Message-Id: <3B1D0BF2.46911D80@SpammerKiller.com>

I need to process several tens of millions of index records into a
compact search system. I chose to use a hash for each field type,
replacing the field with an integer identifying the corresponding hash
entry. I use Raphael Manfredi's _SUPERB_ Storable.pm to periodically
save the state of the application, since it takes several hours to run.
(Last time I checked, Standard Template Library did not have such a
useful and simple object persistence package!)

Each index record reduces to 6 integers. Naturally, I thought the "best"

way to store these would be in packed binary form as follows:

#!/usr/bin/perl -w
use integer;
 ...
while(<>) {
    ...
    print pack 'LLCCSS', $i1, $i2, $i3, $i4, $i5, $i6;
    ...
}

where $i1 - $i6 identify an entry in one of the corresponding hashes.
The 'LLCCSS' limits the size of each integer to a value already
determined to be acceptable from a prior analysis of the data.

NOW, here's the problem. Replacing the print statement with
    print join(',', $i1, $i2, $i3, $i4, $i5, $i6), "\n";

RUNS OVER THREE TIMES FASTER!

This is quite puzzling since I expected the cost of converting each
integer to a string, then joining them, to be far greater than simply
packing the binary into a buffer. If "pack" is even being compiled, it
must be done so very inefficiently!

ALSO puzzling, the following runs just about as slow as the "pack"
version. (I had hoped that eliminating "join" would speed it up even
more.<G>):

#!/usr/bin/perl -w
use integer;
 ...
$, = ',';
while(<>) {
    ...
    print $i1, $i2, $i3, $i4, $i5, $i6;
    print "\n";
    ...
}

Anyway, the "non-pack" version produces a text file that is about three
times as large as the binary file produced by the way-too-slow "pack"
version. Since I'm running on an NTFS disk partition, turning on file
compression reduces the physical size of the text file to about the same

as the binary file, with a negligible performance hit.

So, curiosity brings me to this forum - any theories to explain the poor

"pack" performance?

Thanks!

PS. "perl -v" returns:

This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 623 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 16:27:07 Dec 15 2000

PPS. This post was originally rejected by comp.lang.perl.moderated!



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

Date: Tue, 05 Jun 2001 18:56:21 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: pack = lousy performance
Message-Id: <3B1D1D45.5AB32F7F@bigfoot.com>

Spammer Killer wrote:

> Each index record reduces to 6 integers. Naturally, I thought the "best"

The integers are stored as strings.  This is the most likely reason for
the results you are getting.

A guru may explain how you can treat the integers you get as integers
without conversion at all.

-- 
  Thorbjørn Ravn Andersen                "...plus...Tubular Bells!"
  http://bigfoot.com/~thunderbear


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

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


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