[18890] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1058 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 4 21:06:10 2001

Date: Mon, 4 Jun 2001 18: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: <991703109-v10-i1058@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 4 Jun 2001     Volume: 10 Number: 1058

Today's topics:
        Best way to do this? <bcoon@sequenom.com>
    Re: Best way to do this? <bart.lateur@skynet.be>
    Re: Best way to do this? <krahnj@acm.org>
    Re: Count Occurences of a character in a string <ren@tivoli.com>
    Re: Deleting old files <uri@sysarch.com>
    Re: Deleting old files <godzilla@stomp.stomp.tokyo>
    Re: Deleting old files (Randal L. Schwartz)
    Re: Deleting old files <godzilla@stomp.stomp.tokyo>
    Re: Deleting old files (Craig Berry)
    Re: Deleting old files (Craig Berry)
    Re: Deleting old files (Craig Berry)
    Re: Deleting old files (Randal L. Schwartz)
    Re: FAQ 5.5:   How can I manipulate fixed-record-length <elijah@workspot.net>
    Re: Looking for critique - Please be kind ! <krahnj@acm.org>
    Re: OT :: What to do if you've been kill filed <uri@sysarch.com>
    Re: Perl and SHTML <geeks@comcen.com.au>
    Re: Perl and SHTML <bean@REMOVETOSENDagentkhaki.com>
    Re: Perl and SHTML <nospam@newsranger.com>
    Re: perl/cgi and dynamic hyperlink <godzilla@stomp.stomp.tokyo>
    Re: Silly pipe() question <ren@tivoli.com>
    Re: String Matching Problem <ren@tivoli.com>
    Re: String Matching Problem (Randal L. Schwartz)
        Using both "perl -I" and GetOpt::Std at same time (Emmett McLean)
        Web Host that supports Gimp or Image Magick... (krakle)
    Re: xslint <elijah@workspot.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 04 Jun 2001 16:24:06 -0700
From: BCC <bcoon@sequenom.com>
Subject: Best way to do this?
Message-Id: <3B1C1896.B19D7257@sequenom.com>

I have an some arrays like this:

@array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
@align  = ();
@switch = ("A", "B");

I was playing around, and thought it would be cool to do some sort of
switch, like this:

for ($i = 0; $i < @array; $i++) {
  push(@align, $switch[$i%2]);
}

Which generates a nice array like this:
@align = ("A", "B", "A", "B", "A", "B", etc.....

But then I was trying to build an array that would correspond to
groupings in @array, i.e.:
@array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
@align   = ("A", "A", "A", "A", "B", "B", "B", "B", "A", "A", "B", "B",
"B", "B");

Where the logic assigns the same switch for any value and anything that
follows it that is either an equal value or a 0.  And the switch
alternates....

I tried several variations on this one:
for ($i = 0; $i < @array; $i++) {
  if ($tmp = $array[$i] || $array[$i] == 0) {
    push(@align, $switch[0]);
  } else {
    push(@align, $switch[1]);
  }
  $tmp = $array[$i];
}

I know the $switch[1] and [0] are wrong in push.

But I am having a senior moment and can't figure out how to do it
correctly.

Thanks,
Bryan



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

Date: Mon, 04 Jun 2001 23:55:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Best way to do this?
Message-Id: <4n7ohtgmnuui9ognt0r68td3ulml7iudit@4ax.com>

BCC wrote:

>But then I was trying to build an array that would correspond to
>groupings in @array, i.e.:
>@array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
>@align   = ("A", "A", "A", "A", "B", "B", "B", "B", "A", "A", "B", "B",
>"B", "B");
>
>Where the logic assigns the same switch for any value and anything that
>follows it that is either an equal value or a 0.  And the switch
>alternates....
>
>I tried several variations on this one:
>for ($i = 0; $i < @array; $i++) {
>  if ($tmp = $array[$i] || $array[$i] == 0) {
>    push(@align, $switch[0]);
>  } else {
>    push(@align, $switch[1]);
>  }
>  $tmp = $array[$i];
>}
>
>I know the $switch[1] and [0] are wrong in push.

You need to keep a backup of  the index value, and only change it when
necessary.

    @array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
    my @switch = ('B', 'A');
    my $index = 1;
    @align = ();
    for ($i = 0; $i < @array; $i++) {
       if (my $tmp = $array[$i]) {
           $index = $tmp % 2;
       }
       push(@align, $switch[$index]);
    }
    print "@align\n";
-->
	A A A A B B B B A A B B B B

-- 
	Bart.


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

Date: Tue, 05 Jun 2001 00:41:44 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Best way to do this?
Message-Id: <3B1C2AEB.2ED7467E@acm.org>

BCC wrote:
> 
> I have an some arrays like this:
> 
> @array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
> @align  = ();
> @switch = ("A", "B");
> 
> I was playing around, and thought it would be cool to do some sort of
> switch, like this:
> 
> for ($i = 0; $i < @array; $i++) {
>   push(@align, $switch[$i%2]);
> }
> 
> Which generates a nice array like this:
> @align = ("A", "B", "A", "B", "A", "B", etc.....
> 
> But then I was trying to build an array that would correspond to
> groupings in @array, i.e.:
> @array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
> @align   = ("A", "A", "A", "A", "B", "B", "B", "B", "A", "A", "B", "B",
> "B", "B");
> 
> Where the logic assigns the same switch for any value and anything that
> follows it that is either an equal value or a 0.  And the switch
> alternates....
> 
> I tried several variations on this one:
> for ($i = 0; $i < @array; $i++) {
>   if ($tmp = $array[$i] || $array[$i] == 0) {
>     push(@align, $switch[0]);
>   } else {
>     push(@align, $switch[1]);
>   }
>   $tmp = $array[$i];
> }
> 
> I know the $switch[1] and [0] are wrong in push.

@switch = qw(B A);
@array  = (1, 0, 0, 0, 2, 2, 0, 0, 3, 0, 4, 0, 0, 0);
@align  = ();

push @align, $_ ? $x = $switch[ $_ % 2 ] : $x for @array;



John
-- 
use Perl;
program
fulfillment


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

Date: 04 Jun 2001 18:25:05 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Count Occurences of a character in a string
Message-Id: <m3vgmbvne6.fsf@dhcp9-173.support.tivoli.com>

On Mon, 4 Jun 2001, tadmc@augustmail.com wrote:

> Gary Baker <bakerg@volpe.dot.gov> wrote:
>>How can you count the number of times a character occurs in
>>a string? 
> 
>    perldoc -f tr

As well as:

perldoc -q count

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 04 Jun 2001 22:14:14 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Deleting old files
Message-Id: <x74rtvzydl.fsf@home.sysarch.com>

>>>>> "CS" == Chris Stith <mischief@velma.motion.net> writes:

  CS> Randal L. Schwartz <merlyn@stonehenge.com> wrote:
  >>>>>>> "Chris" == Chris Stith <mischief@velma.motion.net> writes:

  Chris> /^(.*?)\./;
  Chris> unlink( $_ ) if $time > $1;

  >> Oooh ouch OOOh  ouch ouch ouch.  Don't use $1 unless you are SURE
  >> that the regex did in fact match.  Otherwise, you'll be deleting the
  >> next file using the previous file's criterion!

  >> Bad code.  No donut. :)

  CS> Ouch indeed. Make those two lines above into this:

  CS>     if ( /^(.*?)\./ ) { unlink( $_ ) if $time > $1 }

cleaner in a single expression IMO:

	unlink( $_ ) if /^(.*?)\./ && $time > $1 ;

or (not as good):

	/^(.*?)\./ && $time > $1 && unlink( $_ ) ;

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: Mon, 04 Jun 2001 15:39:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Deleting old files
Message-Id: <3B1C0E06.F25C8099@stomp.stomp.tokyo>

Uri Guttman wrote:
 
> >>>>> "CS" == Chris Stith <mischief@velma.motion.net> writes:
 
>   CS> Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>   >>>>>>> "Chris" == Chris Stith <mischief@velma.motion.net> writes:
 
>   Chris> /^(.*?)\./;
>   Chris> unlink( $_ ) if $time > $1;
 
>   >> Oooh ouch OOOh  ouch ouch ouch.  Don't use $1 unless you are SURE
>   >> that the regex did in fact match.  Otherwise, you'll be deleting the
>   >> next file using the previous file's criterion!
 
>   >> Bad code.  No donut. :)
 
>   CS> Ouch indeed. Make those two lines above into this:
 
>   CS>     if ( /^(.*?)\./ ) { unlink( $_ ) if $time > $1 }
 
> cleaner in a single expression IMO:
 
>         unlink( $_ ) if /^(.*?)\./ && $time > $1 ;
 
> or (not as good):
 
>         /^(.*?)\./ && $time > $1 && unlink( $_ ) ;



You could simply reset $1 to null after use.

* demure smile *

Godzilla!


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

Date: 04 Jun 2001 15:52:25 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Deleting old files
Message-Id: <m1wv6rj1sm.fsf@halfdome.holdit.com>

>>>>> "Godzilla!" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:

Godzilla!> You could simply reset $1 to null after use.

A read-only variable?  Hmm.

-- 
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: Mon, 04 Jun 2001 16:04:57 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Deleting old files
Message-Id: <3B1C1419.3D72FD92@stomp.stomp.tokyo>

Randal L. Schwartz naïvely wrote:
 
> Godzilla! quipped:
 
> > You could simply reset $1 to null after use.
 
> A read-only variable?  Hmm.


/()/;


Gotcha!

MUUUUUHAHAHAHAHAHAAAAA!


Godzilla!   Queen of Perl Heretics.


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

Date: Tue, 05 Jun 2001 00:03:53 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Deleting old files
Message-Id: <tho8f9e6ep3695@corp.supernews.com>

Chris Stith (mischief@velma.motion.net) wrote:
: Ouch indeed. Make those two lines above into this:
: 
:     if ( /^(.*?)\./ ) { unlink( $_ ) if $time > $1 }

Or, less twistily,

  unlink($_) if /^(.*?)\./ && $time > $1;

-- 
   |   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 00:05:37 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Deleting old files
Message-Id: <tho8ihm7qpcgc2@corp.supernews.com>

Randal L. Schwartz (merlyn@stonehenge.com) wrote:
: >>>>> "Godzilla!" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:
: 
: Godzilla!> You could simply reset $1 to null after use.
: 
: A read-only variable?  Hmm.

  'z' =~ /(a)/;    # Reset $1 to null :)

-- 
   |   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 00:06:44 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Deleting old files
Message-Id: <tho8kk7i9pj1db@corp.supernews.com>

Godzilla! (godzilla@stomp.stomp.tokyo) wrote:
: Randal L. Schwartz naïvely wrote:
: > Godzilla! quipped:
: > > You could simply reset $1 to null after use.
: > A read-only variable?  Hmm.
: 
: /()/;

That will reset $1 to the empty string '', which is a different value from
undef.

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


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

Date: 04 Jun 2001 17:44:19 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Deleting old files
Message-Id: <m1n17niwm4.fsf@halfdome.holdit.com>

>>>>> "Craig" == Craig Berry <cberry@cinenet.net> writes:

Craig> Randal L. Schwartz (merlyn@stonehenge.com) wrote:
Craig> : >>>>> "Godzilla!" == Godzilla!  <godzilla@stomp.stomp.tokyo> writes:
Craig> : 
Craig> : Godzilla!> You could simply reset $1 to null after use.
Craig> : 
Craig> : A read-only variable?  Hmm.

Craig>   'z' =~ /(a)/;    # Reset $1 to null :)

No, that doesn't change $1 a bit.  If you want $1 to be undef,
it's 'z' =~ /z/.

But that still doesn't provide any gain over simply testing the next
match properly.  In fact, it wastes cycles.

There's no way to deliberately set $1 without invoking the regex
engine, and that's silly to do when proper coding prevents the need
for it.

-- 
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: 5 Jun 2001 00:08:17 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: FAQ 5.5:   How can I manipulate fixed-record-length files?
Message-Id: <eli$0106042002@qz.little-neck.ny.us>

In comp.lang.perl.misc, Benjamin Goldberg  <goldbb2@earthlink.net> wrote:
> Not only doesn't it scale well, but it's a bad habit to get into -- you
> should almost never use symbolic references, when there are other ways
> to do what you want.

Agreed.

> our ($PS_T) = 'A6 A4 A7 A5 A*';
> our (@PS_N) = qw!pid tt stat time command!;
 ...
> Here I've eliminated the variables ($pid, $tt, $stat, $time, $command)
> which were never really needed in the first place, and changed
> everything which was global, but didn't need to be, into a lexical.

Huh? Do I misunderstand 'our'? Your variables, since not 'my'ed or
'local'ed are global variables.

$ perldoc -f our
       our EXPR
               An "our" declares the listed variables to be valid
               globals within the enclosing block, file, or
               ^^^^^^^

Elijah
------
would use 'my' since he does not like to gratuitously break compatibility


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

Date: Mon, 04 Jun 2001 22:13:37 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Looking for critique - Please be kind !
Message-Id: <3B1C080F.16FF9C6A@acm.org>

"Matthew J. Salerno" wrote:
> 
> I am working on a script that will sort 20+ gigs mp3's and I am almost
> finished.  All I have left to do is make sure that no file is
> overwrittn.  I am hoping that someone can give me some advice about
> optomizing the script.  There will be 9000+ records in the initial
> array.  Any assistance will be appreciated.
> 
> 1. Remove "the" from the beginning of any file name.
> 2. Change all "_" into blank spaces.
> 3. Capitalize the first letter in each word.
> 4. Move all files into a specific dir depending on their first
> character.
> 
> Thanks,
> Matt
> 
> #!/usr/bin/perl -w
> use strict;
> use File::Find;
> use File::Copy;
> 
> my $path = "/foo/bar/";
> my $destpath = "/bar/foo/testdir";
> my $extension = ".mp3";
> my $logfpath = "/foo/log/cap.log";
> my ($outpt, $var, $value, @files, @renary, %masterlst);
> 
> &getfiles;
> 
> open(LOGFILE, ">$logfpath") || die "Cannot create output log \-
> $logfpath \- $!\n";
> 
> &renfiles;
> 
> &mvfiles;
> 
> close LOGFILE;
> 
> exit;
> 
> sub getfiles {
>     find sub { push @files, $File::Find::name if /$extension$/i && -e; }, "$path";

$extension is declared as ".mp3". In regular expressions the period (.)
with match _any_ character. The -e tests for the existence of the file
but since find can't find the file if it doesn't exist this test is
redundant.

find sub { push @files, $File::Find::name if /\Q$extension$/i }, $path;


>         if ( $#files < 0 ){
>                 die "\nNo files found\n\n";

die "\nNo files found\n\n" unless @files;

>                 }
> }



John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 04 Jun 2001 22:11:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: OT :: What to do if you've been kill filed
Message-Id: <x77kyrzyhm.fsf@home.sysarch.com>

>>>>> "LM" == Lou Moran <lmoran@wtsg.com> writes:

  LM> --So let's say you get kill filed what do you do to be un kill filed?

you wait and participate in a decent manner. other people will followup
to you and that will be seen by even those who killfiled you. if enough
of those quotes of yours show growth, then some may note it and change
their scores for you or explicitly read some of your posts.

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 09:22:29 +1000
From: "Kiel R Stirling" <geeks@comcen.com.au>
Subject: Re: Perl and SHTML
Message-Id: <3b1c1835$1@nexus.comcen.com.au>


Dan <nospam@newsranger.com> wrote:
>I have a page that contains a text box and when it is submitted it calls a Perl
>file.  That Perl file then takes the input and loads the selected stock quote.
>This part works fine, but I want to integrate this .pl file into a .shtml file
>so I can put it wherever I want to in my layout.  The .shtml layout file
>contains top and bottom includes which have exec commands inside of them.  I
>cannot think of a way to get input from a input box into a .shtml file.  Would
>it be possible to retrieve the MSFT portion using an exec command with a .pl
>file on a page like quote.shtml?MSFT
>
>Can I use an exec command or something similar to that in a .pl file?  I have
>not been able to come up with any good answers to this problem...  Any ideas?
>
>Thanks,
>Dan
>
Have u read the apache doc's at www.apache.org? 
If not try there.

Regards,

Kiel R Stirling.
[geeks@comcen.com.au]



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

Date: Mon, 04 Jun 2001 20:18:46 -0400
From: bean <bean@REMOVETOSENDagentkhaki.com>
Subject: Re: Perl and SHTML
Message-Id: <jd8oht8rtvd8nskfrrnnj1f3k3pnegolcg@4ax.com>

I'm not entirely sure what you're trying to do here, so I should
probably keep my big mouth shut - am I asking for it or what?

Presumably, what happens is this: when the user fills in the form
field and clicks 'submit' the information is processed by a Perl
script and then the appropriate stock quote is found - based on this
info - and displayed. 

My suggestion would be this: why not have the form send the
information to a script that then dynamically (right word?) generates
all of the HTML for the follow-up page. So it would do all of its
processing, and then do something like this:

print "Content-type: text/html\n\n";

print "<html>\n\n";

print "<head>\n\n";

print "<title>The Treefrog Network / $info{'firstname'} ";

(code taken from a site I did that does exactly what is described
above, found at http://treefrog.shacknet.nu).

My other suggestion would be to have the script that handles the
information from the form do this:

print "Location: pagewithinformation.shtml?stockquotename=MIC";

And then have the 'pagewithinformation.shtml' have an SSI that takes
the 'stockquotename=MIC' part of the path and uses it to access and
display the correct information. 

Unfortunately, I'm not sure if the second suggestion will work. 

Good luck. Wish I could have been of more help. Perhaps next time.

bean


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

Date: Tue, 05 Jun 2001 00:50:29 GMT
From: Dan <nospam@newsranger.com>
Subject: Re: Perl and SHTML
Message-Id: <p1WS6.4450$v4.227644@www.newsranger.com>

In article <jd8oht8rtvd8nskfrrnnj1f3k3pnegolcg@4ax.com>, bean says...
>
>I'm not entirely sure what you're trying to do here, so I should
>probably keep my big mouth shut - am I asking for it or what?
>
>Presumably, what happens is this: when the user fills in the form
>field and clicks 'submit' the information is processed by a Perl
>script and then the appropriate stock quote is found - based on this
>info - and displayed. 
>
>My suggestion would be this: why not have the form send the
>information to a script that then dynamically (right word?) generates
>all of the HTML for the follow-up page. So it would do all of its
>processing, and then do something like this:
>
>print "Content-type: text/html\n\n";
>
>print "<html>\n\n";
>
>print "<head>\n\n";
>
>print "<title>The Treefrog Network / $info{'firstname'} ";
>
>(code taken from a site I did that does exactly what is described
>above, found at http://treefrog.shacknet.nu).
>
>My other suggestion would be to have the script that handles the
>information from the form do this:
>
>print "Location: pagewithinformation.shtml?stockquotename=MIC";
>
>And then have the 'pagewithinformation.shtml' have an SSI that takes
>the 'stockquotename=MIC' part of the path and uses it to access and
>display the correct information. 
>
>Unfortunately, I'm not sure if the second suggestion will work. 
>
>Good luck. Wish I could have been of more help. Perhaps next time.
>
>bean

Well, what I really wish I could do in the .shtml page is this:
<!--#exec cgi="/cgi-bin/getquotes.pl?<!--#echo var="QUERY_STRING"-->"-->

But that doesn't work...

Dan




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

Date: Mon, 04 Jun 2001 15:45:52 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: perl/cgi and dynamic hyperlink
Message-Id: <3B1C0FA0.CE899F3A@stomp.stomp.tokyo>

buggs wrote:
 
> Godzilla! wrote:
 
> > You are wasting your time although your motivation
> > and intent are both good. This is commendable.
 
> I don't relate to the concept of time.

You don't have wrinkles and gray hair yet.


> I don't relate to the concepts of good and bad.

You have never been in jail.


> I only use them when talking to people who do.

I always genuflect before speaking. This throws
people off guard.


> > Socratic Irony is an art I well practice. There
> > are times I do string along this troll until he
> > is suckered into exposing himself for being just
> > that, a troll.
 
> Yes, I noticed you have mastership in this dicipline ;-)
> But I don't think it's a good strategy, most of the time.
 
You are not addicted to the allure of being a con.


Godzilla!


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

Date: 04 Jun 2001 17:32:23 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Silly pipe() question
Message-Id: <m38zj7x4eg.fsf@dhcp9-173.support.tivoli.com>

On Sat, 2 Jun 2001, abigail@foad.org wrote:

> pipe() already has a return value - success or not; you'd lose that.
> You then need to do something like returning an empty list, and
> checking the number of arguments returned.

Not that I'm advocating this change, but if it were to happen,
returning an empty list on failure would seem to be perfectly fine.
Since list assignment in a scalar context returns the number of
elements available to be assigned, checking the boolean value of the
assignment would have the same behavior as now.  No need to explicitly
check the number of arguments returned:

  my($RDR, $WRTR) = pipe or die "Could not create pipe: $!\n";

[snip]

> Furthermore, if pipe() would be argument less, returning both sides
> of the pipe(), how should such a modified pipe act in scalar
> context?

That one, I cannot answer. :)  Oh wait, I know... it should have an
implicit fork and give the WRITER to the parent and the READER to the
child.  No, wait, the READER to the parent and the WRITER to the
child...  Yeah, yeah, that's it....

[Whimsy follows]

Now, what might be really interesting would be to be able to pass two
existing handles to pipe() and have it connect them together, without
changing their existing connections (assuming the correct sides are
what are already connected).  Something along the lines of:

open my $in_fh,  "<", $in_file  or die "Could not read $in_file: $!\n";
open my $out_fh, ">", $out_file or die "Could not create $out_file: $!\n";
pipe $out_fh, $in_fh            or die "Could not create pipe: $!\n";
# and then like magic, $in_file is copied to $out_file...

Talk about a scary plan.... :)

-- 
Ren Maddox
ren@tivoli.com


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

Date: 04 Jun 2001 15:56:35 -0500
From: Ren Maddox <ren@tivoli.com>
Subject: Re: String Matching Problem
Message-Id: <m3lmn8vu9o.fsf@dhcp9-173.support.tivoli.com>

On Mon, 04 Jun 2001, hluan@americasm01.nt.com wrote:

> I got a piece of code from Perl CookBook page 154.
> ($parent = $name) =~ s#/[^/]+$##; and
> ($root = $name ) =~ s#.*/##; 

Glancing at this page in the Cookbook reveals that that second line
was actually:

($path = $root) =~ s#.*/##;       # basename

The point being that the comment of "basename" indicates that the
purpose of this line of code is to remove the path.  Of course,
calling the new variable $path is confusing, as is your choice of
calling it $root.  Still, it's not completely clear to me from your
post whether or not this is the behavior you expected and you just
want to understand it better, or if the behavior is different from
what you expected.

> for a path like ../ab/cd/ef
> $parent will be ../ab/cd and
> $root will be ef after it goes through these
> two lines.

Yes, exactly.

> I have problem to understand #, why there is one # in 
> the start of the string and ## at the end of it.

When you use the s/// operator, you can replace the "/" with just
about any character you want.  When you are dealing with patterns that
contain "/", choosing a different character is advised.  Other than
"'", which prevents variable interpolation, the choice of character is
unimportant.

"s#.*/##" simple means to replace everything up to (and including) a
"/" with nothing.  Perhaps slightly more lucid:

          s             {.*/}           {}

means     substitute    this   with     this

> Can somebody explain it in detail and what I should
> use if I use / / style instead of #. What is the benefit
> to use # instead of / /.

Clarity.

One other point is that the greedy nature of "*" results in this
removing everything up to the *last* "/".

-- 
Ren Maddox
ren@tivoli.com


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

Date: 04 Jun 2001 17:45:22 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: String Matching Problem
Message-Id: <m1itibiwkd.fsf@halfdome.holdit.com>

>>>>> "Ren" == Ren Maddox <ren@tivoli.com> writes:

Ren> Glancing at this page in the Cookbook reveals that that second line
Ren> was actually:

Ren> ($path = $root) =~ s#.*/##;       # basename

And that's not even correct.  It's missing an "s" suffix to permit dot
to match newline.  Newlines are legal characters in Unix pathnames.

-- 
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: 4 Jun 2001 16:17:10 -0700
From: emclean@slip.net (Emmett McLean)
Subject: Using both "perl -I" and GetOpt::Std at same time
Message-Id: <9fh4tm$f28@slip.net>


Hi,

I'd like to use Getopt::Std in a Perl script
which runs from the command line with a
hypen I option. The problem I'm running into
is that Perl checks for libraries before
stepping through the Getopt command line
checking I've built.

The script runs from the command line with the following syntax :

/usr/local/bin/perl -I/home/emmmcl01/mylib myscript.pl -o 1 -d 3

and it baulks
Can't locate CWLRhicDb.pm in @INC (@INC contains: 
/home/emmmcl01/perl/sun4-solaris  ...
BEGIN failed--compilation aborted at ./SEP.pl line 11.

I'd like for the checking in @INC to occur after
the GetOpt checking?

Any suggestions?

Thanks,

Emmett








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

Date: 4 Jun 2001 17:44:11 -0700
From: krakle@visto.com (krakle)
Subject: Web Host that supports Gimp or Image Magick...
Message-Id: <237aaff8.0106041644.210d811d@posting.google.com>

Hello, Its me again. I am currently working on a web based project in
Perl (CGI) that allows a visitor to create a graphic and transload it
to there web host. This Web based program is geared towards WebTV,
Dream Cast and other set top box users who cannot download and use
programs. Anyways, I am in search of a Web Host that supports either
GIMP or Image Magick. Any recomendations or would I have to get a
Dedicated Server?

ps. I searched through the archives and found a similar
question/answer but that host doesnt appear to support nither one.

pss. If you are going to flame my post (and I dont know how my post
could possibly be flamed) dont bother. Its rather childish and
immature not to mention a waist of time.

Thank You!


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

Date: 4 Jun 2001 23:55:18 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: xslint
Message-Id: <eli$0106041955@qz.little-neck.ny.us>

In comp.lang.perl.misc, brian d foy  <comdog@panix.com> wrote:
> > Tim wrote:
> > > Alternatively, is there a site where I can get a zip file which
> > > installs EVERY module that is available on CPAN?
> if you want to install every module, just create a Bundle from the
> module list and let CPAN.pm have at it.

A good start, but lots of modules exist to give perl interfaces to
various libraries or programs that will also need to be installed.
In many cases these will not be something that CPAN.pm could deal
with (think, eg, of the Oracle modules) so someone doing this should
expect a lot of install failures.

Elijah
------
thinks it is a bad idea to install modules before they are needed


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

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


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