[17334] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4756 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 29 18:05:37 2000

Date: Sun, 29 Oct 2000 15:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <972860713-v9-i4756@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 29 Oct 2000     Volume: 9 Number: 4756

Today's topics:
    Re: Arcane Serial Question (Chris Fedde)
        Best way to shorten a long string? <none@none.ca>
    Re: Best way to shorten a long string? (Mark-Jason Dominus)
    Re: Best way to shorten a long string? (Chris Fedde)
    Re: Bitreverse an integer <bart.lateur@skynet.be>
    Re: CGI.pm + exec = error andre_sanchez@my-deja.com
        Comparing two files <peter.sundstrom@eds.com>
    Re: Detecting socket closure (Mark-Jason Dominus)
    Re: how to find oldest file in a directory (Craig Berry)
    Re: How to speedup the following (Craig Berry)
    Re: Multi process under windows NT (Tarael200)
        NetPacket module <a@nn.gf.df>
        Pattern Match <thalion@wonderd.com>
    Re: Pattern Match (Clay Irving)
    Re: Pattern Match <jeff@vpservices.com>
        pattern replace? <kelly@shakesbeer.com>
    Re: pattern replace? <not.my.real.email@bellglobal.com>
        Perl message on Linux: Setting locale failed. <quit@that.you>
        Perl/cgi coder salaries (Tarael200)
    Re: Perl/cgi coder salaries (Eric Bohlman)
    Re: Printing parameters <krahnj@acm.org>
    Re: regex help (Daniel Chetlin)
    Re: Sending mails from a Unix webserver <g.soper@soundhouse.co.uk>
    Re: Set path to perl.exe for Win 98 se <godzilla@stomp.stomp.tokyo>
    Re: Set path to perl.exe for Win 98 se <godzilla@stomp.stomp.tokyo>
        split match and escaped characters. (Tony L. Svanstrom)
    Re: split match and escaped characters. <mauldin@netstorm.net>
    Re: stat / inode question (Peter Scott)
    Re: stat / inode question (Mark-Jason Dominus)
        Stultiloquent Queries (was: even or odd?) (Tom Christiansen)
        undef values removed from argument list? <newspost@coppit.org>
    Re: undef values removed from argument list? (Randal L. Schwartz)
    Re: undef values removed from argument list? (Martien Verbruggen)
    Re: what does /warn "$x" if "$x"/ mean (Martien Verbruggen)
    Re: what does /warn "$x" if "$x"/ mean <krahnj@acm.org>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 29 Oct 2000 19:07:16 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Arcane Serial Question
Message-Id: <Ez_K5.26$T3.169981440@news.frii.net>

In article <8th9i60n9@enews2.newsguy.com>,
Asquith <asquith@macconnect.com> wrote:
>Looking for help talking to a Campbell Scientific Data logger through the 
>serial port using Perl.  Linux preferred but Win32 ok too.  Is there an
>chance that some has already done so?
>

I'm not aware of anything specifically for the Campbell Scientific
Data logger.  Still it's easy to open and talk to a serial port as
long as the protocol is synchronous.  Here is an example of a
boneheaded little script that talks to my modem port on FreeBSD.

    #!/usr/bin/perl
    #

    use strict;
    use warnings;
    my $port = "/dev/cuaa0";

    open(S, "+>$port") or die "can't open $port: $!";

    print S "at\r";
    while (<S>)
    {
	print $_;
	last if (/ok/i);
    }
    print S "at&v\r";
    while (<S>)
    {
	print $_;
	last if (/ok/i);
    }
    exit 0;

YMMV
chris
-- 
    This space intentionally left blank


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

Date: Sun, 29 Oct 2000 17:39:15 -0400
From: "k" <none@none.ca>
Subject: Best way to shorten a long string?
Message-Id: <HQ0L5.81655$YG5.61122@tor-nn1.netcom.ca>

I have a long string (several thousand characters) that I would like to
shorten before I store it in a database. Is there any way to shorten the
length of a string by encoding it in some way -  i.e. Convert it to another
format which needs fewer characters to define the same information?

Example:

# define a string
# print length($string)    displays    1000
$string = "My 1000 character in length string ... ";

# encode/compress the string to make it shorter
# print $string    displays    An encoded string "030x-m_%438%u  ... "
# print length($string)    displays    345
$encoded_string = &encode($string);

 # save to database
&save('id', $encoded_string);

# read it back in
$encoded_string = &read('id');

# decode it
$string = &decode($encoded_string);

# We are now left with the original 1000 character string

Thanks,
kh




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

Date: Sun, 29 Oct 2000 22:11:09 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Best way to shorten a long string?
Message-Id: <39fca07d.6954$2ec@news.op.net>
Keywords: Indochina, Sophocles, internecine, stilt


In article <HQ0L5.81655$YG5.61122@tor-nn1.netcom.ca>, k <none@none.ca> wrote:
>Is there any way to shorten the length of a string by encoding it in
>some way - i.e. Convert it to another format which needs fewer
>characters to define the same information?

That is called 'compression'.  You may want to look into Perl modules
with the name 'Compress'.  See search.cpan.org.

Compress::Zlib is highly thought of.  It is a Perl interface to the
well-know Zlib compression library.


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

Date: Sun, 29 Oct 2000 22:13:32 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Best way to shorten a long string?
Message-Id: <gi1L5.32$T3.170853376@news.frii.net>

In article <HQ0L5.81655$YG5.61122@tor-nn1.netcom.ca>, k <none@none.ca> wrote:
>I have a long string (several thousand characters) that I would like to
>shorten before I store it in a database. Is there any way to shorten the
>length of a string by encoding it in some way -  i.e. Convert it to another
>format which needs fewer characters to define the same information?
>

You might be able to exploit some feature of the text that you are
working with such as run length encoding of space or zero padded
fields.  But for a more general solution look for Compress::Zlib
and it's friends on CPAN.

chris

BTW. In most modern systems a "few thousand" bytes is not really
all that big, especially for a transaction based algorithm that
runs in constant memory.  In many cases using an obvious algorithm
can save more in maintanance costs than using a complex one saves in
runtime costs.
-- 
    This space intentionally left blank


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

Date: Sun, 29 Oct 2000 20:08:03 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bitreverse an integer
Message-Id: <sr0pvsg438qv4e34vjd4i9q93vo28sduru@4ax.com>

Logan Shaw wrote:

>There's actually a way to compute all powers of 2 up to and including
>the one you want all at once, but I don't guess the extra efficiency
>gained in doing so is worth the trouble.

Maybe not, but that would interest me anyway.

Yes, I can use binary search to find that number, but it's a lot of
hassle for the benefir it gives.

-- 
	Bart.


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

Date: Sun, 29 Oct 2000 16:41:09 GMT
From: andre_sanchez@my-deja.com
Subject: Re: CGI.pm + exec = error
Message-Id: <8thjv5$ndq$1@nnrp1.deja.com>



> Wishing to exec() one CGI script from another is a silly thing to
> wish.

At the risk of continuing in my sillyness, but with the hope of
reducing it, I have adjusted my objective; With mixed results.

I have a CGI script (tester.pl) that I wish to have display the output
of another script (testee.pl). Below are two versions of the testee.pl
script; version 1 returns the expected results, while version 2
returns: Malformed multipart POST.

Given that I prefer to use the technique outlined in version 2, your
ideas on how to eliminate the misbehavior are greatly appreciated.

Thank you,

Andre Sanchez

#--------------------- tester.pl ------------------------------------
#!/usr/bin/perl -w

use strict;
use CGI;

my $query = new CGI;
my ($method, $action, $encoding) =
('post', 'tester.pl', 'multipart/form-data');

if (!$query->param('checked')) {
  print $query->header();
  print $query->start_html();
  print $query->startform(-method=>$method,
			  -action=>$action,
			  -enctype=>$encoding);
  print $query->checkbox(-name => 'checked',
			 -value=> '1',
			 -label=> 'Check Box');
  print $query->submit(-value=>'Submit');
  print $query->endform();
  print $query->end_html();
} else {
  my $one = 1;
  my $two = 2;
  open(SHIP, "./testee.pl $one $two |") or die "$!";
  while(<SHIP>){
      print;
  }
}

#---- testee.pl version 1 returns desired results--------------
#!/usr/bin/perl -w

use strict;

print "Content-Type: text/html\n\n";
print "<html><body>Arguments: @ARGV</body></html>";

#---- testee.pl version 2 returns: Malformed multipart POST ---
#!/usr/bin/perl -w

use strict;
use CGI;

my $query = new CGI;
print $query->header();
print $query->start_html();
print "Arguments: @ARGV";
print $query->end_html();


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 30 Oct 2000 11:38:04 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Comparing two files
Message-Id: <8ti92m$pl1$1@hermes.nz.eds.com>

I'm using the following code to compare two files:

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

if (Filecmp('a.dat','b.dat')) {
  print "Differences\n";
}
else {
  print "Same\n";
}

sub Filecmp {
  my ($file1,$file2) = @_;

  system("cmp $file1 $file2 >/dev/null");
  return $?;
}


I'm unsure as to the best way to change the system call to a Perl
equivalent.  I assume I'd have to use a combination of array and hash like
the examples in the FAQ to do with finding elements in one array but not
another.  I'm not interested in what the differences are, only if the files
are the same or different.






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

Date: Sun, 29 Oct 2000 22:16:17 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Detecting socket closure
Message-Id: <39fca1b0.697b$21b@news.op.net>

In article <ePtK5.75100$oN2.3100601@news20.bellglobal.com>,
MNJP <not.my.real.email@bellglobal.com> wrote:
>
>That is not correct. If the socket is set to non-blocking mode (the way I
>prefer it) using fcntl(), then read and sysread will return 0 bytes until
>something is received.

However, it is correct for normal blocking sockets, which are the default.

The original posted, Fulko Hew, did not say that he was doing things
in the way that you prefer.



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

Date: Sun, 29 Oct 2000 20:14:09 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: how to find oldest file in a directory
Message-Id: <svp18h6dfrkua5@corp.supernews.com>

mr_potato_head@my-deja.com wrote:
:    I have a script using the find module looking for files that have
: today's date in the filename.  Out of the list returned, how can I find
: out which file is the oldest?  (most current file)  thanks in
: advance...

Use the -M file test operator to sort the list by age, and pick the
maximum value:

  my $oldest = (sort { -M $a <=> -M $b } @files)[-1];

For very long lists, the increased overhead of doing a full sort and
repeated -M tests will become a big enough problem to overcome the
notational convenience of this idiom.  If this is your situation, just
iterate through the list once, maintaining variables containing the
current oldest filename and its age, comparing against each list member
and updating both if you encounter an older one. 

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "As truth is gathered, I rearrange; inside
   |   out, outside in, perpetual change." -Yes


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

Date: Sun, 29 Oct 2000 20:09:20 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How to speedup the following
Message-Id: <svp0vgq7q5q5f8@corp.supernews.com>

David Steuber (nospam@david-steuber.com) wrote:
: Once, when I needed to parse very large weblog files (>10MB), I found
: regexes to be too slow.  At least the way I used them.  I ended up
: using index and substring in a very C like way to speed up the
: program.

It will nearly always be the case that any algorithm which can be simply
expressed using index and substring will run faster coded that way than
with a regex-based solution.  Regexes have astonishing expressive power,
but there's a cost for that power.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "As truth is gathered, I rearrange; inside
   |   out, outside in, perpetual change." -Yes


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

Date: 29 Oct 2000 20:04:18 GMT
From: tarael200@aol.com (Tarael200)
Subject: Re: Multi process under windows NT
Message-Id: <20001029150418.01065.00000202@ng-fr1.aol.com>

>
>Yes...get ActiveState's ActivePerl 5.6 (build 61x)...fork() is supported.
>

Is it supported under Win95?


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

Date: Sun, 29 Oct 2000 08:34:57 +0200
From: "data comm" <a@nn.gf.df>
Subject: NetPacket module
Message-Id: <8tickq$9sf$1@feedme.surfree.net.il>

hi ,
i'm looking for examples to some of the NetPacket modules
(eg. ARP,TCP,IP) , using raw_data as the input for the
encoding.

mail to harris_frnds@hotmail.com


Thanx in advance.




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

Date: Sun, 29 Oct 2000 13:06:17 -0800
From: "HappyHippo" <thalion@wonderd.com>
Subject: Pattern Match
Message-Id: <8ti39l$dk3$1@slb7.atl.mindspring.net>

I'm working a script that does some replacements to words
in a string, but I dont want it to replace words inside of html tags.

for instance
$string = "Ted is <font size"6"> 6 years old";
then I say
$string =~ s/6/15/g;

how could I do this so that it wouldnt match
the strings inside of < > chars?

any ideas?

thanks.




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

Date: 29 Oct 2000 21:24:38 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Pattern Match
Message-Id: <slrn8vp5cm.m1e.clay@panix3.panix.com>

On Sun, 29 Oct 2000 13:06:17 -0800, HappyHippo <thalion@wonderd.com> wrote:

>I'm working a script that does some replacements to words
>in a string, but I dont want it to replace words inside of html tags.
>
>for instance
>$string = "Ted is <font size"6"> 6 years old";
>then I say
>$string =~ s/6/15/g;
>
>how could I do this so that it wouldnt match
>the strings inside of < > chars?
>
>any ideas?

In your example, you can replace the number that's not quoted:

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

  $string = 'Ted is <font size"6"> 6 years old';

  $string =~ s/\s6\s/ 15 /g;
  print "$string\n";

Result:

  Ted is <font size"6"> 15 years old

-- 
Clay Irving <clay@panix.com>
I had to stop driving my car for a while...the tires got dizzy.
- Steven Wright 


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

Date: Sun, 29 Oct 2000 13:38:35 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Pattern Match
Message-Id: <39FC98DB.340D33A5@vpservices.com>

Clay Irving wrote:
> 
> On Sun, 29 Oct 2000 13:06:17 -0800, HappyHippo <thalion@wonderd.com> wrote:
> 
> >I'm working a script that does some replacements to words
> >in a string, but I dont want it to replace words inside of html tags.
> >
> >for instance
> >$string = "Ted is <font size"6"> 6 years old";
> >then I say
> >$string =~ s/6/15/g;
> >
> >how could I do this so that it wouldnt match
> >the strings inside of < > chars?
> >
> >any ideas?
> 
> In your example, you can replace the number that's not quoted:
> 
>   #!/usr/local/bin/perl -w
> 
>   $string = 'Ted is <font size"6"> 6 years old';
> 
>   $string =~ s/\s6\s/ 15 /g;
>   print "$string\n";

That will match the one particular example given, but will be worse than
useless for the general problem posed.  You did quote Steve Wright, so
perhaps this is an example of dry humor.  If so, rofl :-).

The OP will be better off using HTML::Parser, and doing the substitution
in the text() callback.

-- 
Jeff


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

Date: Sun, 29 Oct 2000 17:39:56 -0500
From: "Kelly" <kelly@shakesbeer.com>
Subject: pattern replace?
Message-Id: <svp9g5alao2ada@corp.supernews.com>

Hi,

If I want to do a pattern match and replace a carriage return with the tag
<br> (as in the following script), how do I denote a carriage return? Thanks
in advance. :)

$string =~ s/ carriage return  /<br>/gi;




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

Date: Sun, 29 Oct 2000 22:51:23 GMT
From: "MNJP" <not.my.real.email@bellglobal.com>
Subject: Re: pattern replace?
Message-Id: <LR1L5.393548$Gh.12325887@news20.bellglobal.com>


$string =~ s/\n/<br>\n/g;

"Kelly" <kelly@shakesbeer.com> wrote in message
news:svp9g5alao2ada@corp.supernews.com...
> Hi,
>
> If I want to do a pattern match and replace a carriage return with the tag
> <br> (as in the following script), how do I denote a carriage return?
Thanks
> in advance. :)
>
> $string =~ s/ carriage return  /<br>/gi;
>
>




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

Date: Sun, 29 Oct 2000 19:35:46 GMT
From: Anastasia <quit@that.you>
Subject: Perl message on Linux: Setting locale failed.
Message-Id: <39FC8A95.DB54F8F6@that.you>

I've had this problem for a while.  Some international settings have
bien corrupted in my Linux box and I'm trying to repair it with no luck.

Here's the message:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "fr",
        LC_ALL = "fr_CA",
        LANG = "fr"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

If any one has a clue, I'd appeciate some way to eliminate this.

Thanks.

-- 
a


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

Date: 29 Oct 2000 19:53:20 GMT
From: tarael200@aol.com (Tarael200)
Subject: Perl/cgi coder salaries
Message-Id: <20001029145320.25684.00000360@ng-fr1.aol.com>

Very recently, within the past day I think, there was a job advertisement for a
perl/cgi programmer, for $25-30/hour.

Someone posted $50-90 was the going salary, as of a 1997 survey.

My friend, you are quite wrong IIRC, for then they were rare. Now, they are but
a dime a dozen.

Anyone care to comment?

-Ryan



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

Date: 29 Oct 2000 21:01:38 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Perl/cgi coder salaries
Message-Id: <8ti37i$2qqc$2@news.enteract.com>

Tarael200 <tarael200@aol.com> wrote:
> Very recently, within the past day I think, there was a job advertisement for a
> perl/cgi programmer, for $25-30/hour.

> Someone posted $50-90 was the going salary, as of a 1997 survey.

> My friend, you are quite wrong IIRC, for then they were rare. Now, they are but
> a dime a dozen.

> Anyone care to comment?

Make sure you're comparing apples and apples.  Contract rates and salaries
are not the same thing, and the former are always quite a bit higher than
the latter.  The original ad was looking for contract work, not full-time
employment.  The general rule of thumb is that a contract rate is 2.5 to 3
times the equivalent hourly rate of a salaried position, so a contract
rate of $25-$30 would be the equivalent of a salary of $21K-$25K.



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

Date: Sun, 29 Oct 2000 13:45:09 -0800
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Printing parameters
Message-Id: <39FC9A65.D3AAAC3A@acm.org>

Gil Vautour wrote:
> 
> "John J. Trammell" wrote:
> 
> > On Tue, 24 Oct 2000 15:54:56 -0300, Gil Vautour <vautour@unb.ca> wrote:
> > >This may be a stupid question... In Perl CGI I want to be able to print
> > >a parameter without having to put it in a variable first.  I would like
> > >to be able to do something like:
> > >
> > >print " This is my form value $query->param(\"something\")";
> >
> > printf "This is my form value: '%s'",  $query->param("foo");
> 
> So this can only be done with printf, no such equivalent for a "here doc"?

printf <<EOP,  $query->param("foo");
This is my form value: '%s'
EOP

Do you mean like this?

John


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

Date: 29 Oct 2000 18:30:49 GMT
From: daniel@chetlin.com (Daniel Chetlin)
Subject: Re: regex help
Message-Id: <8thqcq09s7@news1.newsguy.com>

On Sun, 29 Oct 2000 18:52:44 +0800,
 Jason Chung <jason99992000@yahoo.com> wrote:
>I need some help with regex. 
>Kindly point it out to me if it's in the faqs cos I couldn't find it.
>
>$delimiter = "|";
>$mystring = "aaaaaa" . $delimiter . "bbbbbbb" . $delimiter . "cccccccc";
>
>I'm trying to get the last part of the string (b4 the delimiter) from 
>$mystring (ie. cccccccc).
>
>How do I accomplish that with regex?

Others have shown two ways to accomplish that with a REx. Here's a way
to do it that's more efficient and less error prone:

  $last_part = substr $mystring, rindex($mystring, $delimiter) + 1;

Always keep in mind that there are other tools than the one you think
should be used for any given job.

-dlc


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

Date: Sun, 29 Oct 2000 16:13:55 +0000 (GMT)
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Sending mails from a Unix webserver
Message-Id: <4a1527667fg.soper@soundhouse.co.uk>

In article <8th5oj$leh$1@orpheus.gellyfish.com>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:
> On Sat, 28 Oct 2000 22:21:07 +0100 Geoff Soper wrote:
> > I'm starting to think about building a mailing list system. I intend
> > it to be a CGI application running on a Unix webserver running Apache.
> > I see the part of the FAQ entitled 'How do I send mail?'. This seems
> > simple enough, is it a good way to send this sort of quantity (<1000)
> > of message? The messages will all be the same and will be sent to a
> > certain subset of a larger number of addresses.

> That FAQ item references several ways of sending mail - I assume that
> you mean the use of sendmail.

Sorry, yes I did.

> Running a mailing list as a CGI program seems far from ideal to me as it
> will require some intervention to cause the mailing to be done.  I read
> that you have discounted the use of majordomo but that doesnt preclude
> the downloading of the source so you can examine how it does what it
> does.

It's only ever going to be a one-way list so it's not a problem. We're an
arts organisation and I want people within our organisation to be able to
easily mail out to people who have asked to be informed of gigs by a
certain band, of news about a certain band, about our adult education
programme or press releases. This means a person can be in any number of
subsets of the total subscription group. A passworded web page seems to be
the easiest method of people sending out a message to the appropriate
group of subscribers.

I'm just concerned that running it as a CGI script will run the risk of
slowing our webserver down. I've no idea what kind of load a given
operation puts on a server and thought somebody here would be able to tell
me if what I propose is a 'no no'. The quantity of messages sent at any
one time won't exceed 1000.

> > Also it says the -odq part means the message get put into the queue as
> > opposed to being delivered directly, what is this queue?
> > 

> The mail is queued and the queue is processed at some predtermined
> interval. You will want consult the sendmail documentation and possibly
> the groups that discuss sendmail.

Will do!

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: Sun, 29 Oct 2000 08:49:21 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Set path to perl.exe for Win 98 se
Message-Id: <39FC5511.E3762DE8@stomp.stomp.tokyo>

Randy Harris wrote:
> 
> Godzilla! wrote:

> [snip]

> > One of you boys courtesy enough to post step-by-step
> > instructions on what should be used to establish a
> > DOS path statement with hopes of having Perl work?
> > For now I will be satisfied to simply get this
> > example.pl to run.
 
> Assume, for the moment that you installed Perl in c:\perl.
> Launch the command shell window.

> Type:
> set path=%path%;c:\perl\bin
 
> Assuming further that the example program is in c:\perl\eg

> c:

> cd \perl\eg
> perl example.pl
 
> If it now runs, you can permanently add the c:\perl\bin to your global
> environment.


Yeah, did the change directory part ok.
I even tried running programs in the
bin directory, nada, zilch. I tried all
the standard issue path statements, including
a %1% format and similar. I didn't try
%path% yet.
 

I will try this style of path statement today
and let you know what happens. Unfortunately,
Active State provides zero documentation on
this and, I am guesstimating a full third
of documentation cited by Active State within
their install documentation, simply doesn't exist.
Twenty to twenty-five percent of html documentation
links provided by Active State, either go nowhere,
or are circular in nature, never arriving anywhere
save for where you started initially.

I've also noted win registry entries are incorrect.
This build 618 has some serious programming errors.

Thanks for this path statement. I will get back
to you with results today.

Active State wants $200 to answer a question.

* laughs *

Just when I thought Redmond was an icon of greed.

Godzilla!


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

Date: Sun, 29 Oct 2000 12:01:01 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Set path to perl.exe for Win 98 se
Message-Id: <39FC81FD.E75E7ED6@stomp.stomp.tokyo>

Randy Harris wrote:

> Godzilla! wrote:

> [snip]

> > One of you boys courtesy enough to post step-by-step
> > instructions on what should be used to establish a
> > DOS path statement with hopes of having Perl work?
> > For now I will be satisfied to simply get this
> > example.pl to run.
 
> Assume, for the moment that you installed Perl in c:\perl.
> Launch the command shell window.

> Type:

> set path=%path%;c:\perl\bin

> Assuming further that the example program is in c:\perl\eg

> c:
> cd \perl\eg
> perl example.pl
 
> If it now runs, you can permanently add the c:\perl\bin to 
> your global environment.


As promised, some results. This path statement you
provided works fine. I have global access to perl
core now. Best I can tell, Active State install does
not attempt to set a path statement although their 
documentation claims it does. There is a note about 
a path statement being clobbered, buried in an obscure
section of their documentation. However, their note is
quite vague and no resolution is offered. Funny, they
tell you their install won't work but neglect to tell
you how to fix their install errors.

I'm figuring a good ten to fifteen megabytes of garbage
can be removed from their documention. So much of it is
either dead links, leads around in circles or leads to
a page with a title but no content. Weird. It is as if
they forgot to take out their garbage.

You boys at Active State really need to clean up your
act. There is no excuse for all these problems and errors
with your program; it is shameful.

So, thanks for your path statement, Mr. Harris, it does
work and hopefully I can now repair other problems and
damage done by Active State's install wizard. With a little
luck, I might be able to link perl with my apache web server.


Thank you again. Your efforts are appreciated. At least
you didn't ask me to pay you two-hundred smackers for
an answer like Active State would.


Godzilla!


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

Date: Sun, 29 Oct 2000 21:27:35 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: split match and escaped characters.
Message-Id: <1ejabid.uy75k3zz4cxiN%tony@svanstrom.com>

If the string is: "a@b@\@@d", then how the heck to I split on all
non-escaped @s? Ie, how do I avoid the "@" in "\@" to be viewed as a
separator, too?

I have a feeling that this is something simple that I should know, but
the solution escapes me.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Sun, 29 Oct 2000 21:37:38 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: split match and escaped characters.
Message-Id: <39FC9899.26C1DFA2@netstorm.net>

"Tony L. Svanstrom" wrote:
> 
> If the string is: "a@b@\@@d", then how the heck to I split on all
> non-escaped @s? Ie, how do I avoid the "@" in "\@" to be viewed as a
> separator, too?
> 
> I have a feeling that this is something simple that I should know, but
> the solution escapes me.
> 

A negative lookbehind can do it.

$_ = 'a@b@\@@d';
@ats = split /(?<!\\)@/;
print "$_\n" for @ats;

HTH,

-- Jim


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

Date: Sun, 29 Oct 2000 17:20:37 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: stat / inode question
Message-Id: <F%YK5.13177$q9.396489@news1.gvcl1.bc.home.com>

In article <39f9f67d.287e$32b@news.op.net>,
 mjd@plover.com (Mark-Jason Dominus) writes:
>I consulted my File of Good Advice on this one, and it said:
>
>#11907 Looking for a compiler bug is the strategy of LAST resort.  LAST resort.
>
>(No, I didn't just make this up; I really do have such a file and it
>really does say that.)

Can we see the other entries?

-- 
Peter Scott


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

Date: Sun, 29 Oct 2000 22:06:21 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: stat / inode question
Message-Id: <39fc9f5d.693b$1ab@news.op.net>
Keywords: bureaucrat, lawgiver, lectern, worn

In article <F%YK5.13177$q9.396489@news1.gvcl1.bc.home.com>,
Peter Scott <Peter@PSDT.com> wrote:
>In article <39f9f67d.287e$32b@news.op.net>,
> mjd@plover.com (Mark-Jason Dominus) writes:
>>(No, I didn't just make this up; I really do have such a file and it
>>really does say that.)
>
>Can we see the other entries?

I've been including them in my article headers for a while now.



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

Date: 29 Oct 2000 11:00:05 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Stultiloquent Queries (was: even or odd?)
Message-Id: <39fc65a5@cs.colorado.edu>

In article <39fc1359.100122189@news.easynet.be>,
Billy <billy@easynet.be> wrote:
>Does an instruction exist which can test if an number is odd (eg 1, 3,
>5, ...) or even (eg 2, 4, 6, 8, ...) ?

Welcome to our temple, grasshopper.  I predict that you will be
with us for a long, long time.  

Sit back and relax.


+---------------------+
| CASE 0: Mathematics |
+---------------------+

This is the most beautiful of the solutions I shall provide you.

    sub is_even {
	my $number = abs int shift;
	$number == 0 || is_odd($number - 1);
    }

    sub is_odd {
	my $number = abs int shift;
	$number != 0 && is_even($number - 1);
    }

There, didn't that just take your breath away?  The integers are
obviously not your friend.  They should be.  They must be.  Pause
here awhile and get to know them.  Do not proceed to Cantor until
you have done so.

+-----------------+
| CASE 1: Strings |
+-----------------+

Of course, as Perl is renowned more for its work upon strings than
upon numbers, one could argue that the most natural approach would
be instead one involving pattern matching.  This solution also has
a deep, underlying beauty.  Regard:

    sub is_even { ('x' x abs int shift) =~ /^(x*)\1$/ }
    sub is_odd  { ('x' x abs int shift) =~ /^x(x*)\1$/ }

This, too, is worthy of some dalliance, for there is more here than
casually meets the eye.

+-----------------------+
| CASE 10: More Strings |
+-----------------------+

Rather less illustrative than the previous case, one of course
also has this patently obvious approach:

    sub is_even { abs int shift =~ /[60284]$/ }
    sub is_odd  { abs int shift =~ /[53197]$/ }


+---------------+
| CASE 11: Bits |
+---------------+

For the more architecturally inclined, one could use this pair:

    sub is_even { !(split(//, unpack("B32", pack("N", abs int shift))))[-1] }
    sub is_odd  {  (split(//, unpack("B32", pack("N", abs int shift))))[-1] }


+---------------------+
| CASE 100: More Bits |
+---------------------+

Although in modern versions of Perl, those would be more easily
rendered as:

    sub is_even { !substr(sprintf("%b", abs int shift), -1) }
    sub is_odd  {  substr(sprintf("%b", abs int shift), -1) }


+-----------------------+
| THE MORAL OF OUR TALE |
+-----------------------+

Ignore all other solutions you might read in this thread, for from
them shall you learn nothing of note, nothing profound.  Eschew the
unexamined application of any facile solutions elsewhere proffered.
They do not lead down the path of wisdom and understanding.  You
will not grow.  You will wallow in myth and hearsay, and you will
have gained nothing.

Instead, you must take control of your own destiny.  Study diligently
the illustrative solutions presented above.  They were carefully
selected from a cast of thousands to provide the foundation for your
particular edification.

You see, if you had merely been thinking clearly when you formulated
your question to the oracle, its embarrassingly trivial answer would
already be yours, self-evident in the very asking.  But you did
*not* think logically and clearly, and thus you have come here to
our temple, begging of the monks' wisdom as though it were food for
the starving poor.

Very well.  Now that you are here, what we have, we share.  But
these things you seek are not so free as they might appear.  There
is no substitute for experimentation, for scholarship--for quiet
contemplation.  That is how we became what we are today.  And that
is how you will become tomorrow what we were yesterday.  You must
think, and you must work.  There is no other way.

Only once each and every one of these techniques should stand as
brilliantly clear in your mind as Euclid's venerable proof of the
infinity of primes, grasshopper, only then will you at last be ready
to leave our serene temple and venture forth into the real world
of real programmers.

Were you to leave us as you are right now, wholly unprepared for
the vicious outside world where ordered, logical thinking is a
prerequisite for all sound programming, then you like any unthinking
grasshopper caught unawares by a sudden winter's day would surely
meet a fast, cold, and miserable death.  

It's a tough world.  Prepare yourself!

Perhaps you will someday snatch the prime number from the irregular
expression and exit these gates.  Then again, perhaps you will stay
a non-programmer forever: I'd like some ketchup with those french
fries, please.  Hold the salt.

Good luck. 

Hope this helps. 

Have a nice day. 

Don't let the bedbugs bite.

--tom, who swore he would throttle the next person to ask this 
       incredibly idiotic question


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

Date: Sun, 29 Oct 2000 15:48:46 -0500
From: David Coppit <newspost@coppit.org>
Subject: undef values removed from argument list?
Message-Id: <Pine.GSO.4.21.0010291443240.543-100000@mamba.cs.Virginia.EDU>

Hi all,

A simple Perl question:

I though this:
  return;
and this:
  return undef;
were equivalent, but they're not:

----------------
#!/usr/bin/perl

print "undefined\n" unless defined bar();
foo(bar());
print "undefined\n" unless defined baz();
foo(baz());

sub bar { return; }
sub baz { return undef; }
sub foo { print "Arg list size is: " . $#_ . "\n"; }
----------------

This script prints:
undefined
Arg list size is: -1
undefined
Arg list size is: 0

So perl compacts undef values in argument lists, but only if the function
providing the actual argument doesn't explicitely return undef?

Yikes! Is there a rationale/explanation for this behavior that will help me
remember this quirk? (Or is it a bug? ;)

David

P.S. I got burned by this when calling a function using CGI::param like this:
  my_func(param('a'),param('b');
When param('a') was not defined, I got param('b')'s value where I expected
param('a') to be undef. :(



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

Date: 29 Oct 2000 13:25:18 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: undef values removed from argument list?
Message-Id: <m1bsw3barl.fsf@halfdome.holdit.com>

>>>>> "David" == David Coppit <newspost@coppit.org> writes:

David> I though this:
David>   return;
David> and this:
David>   return undef;
David> were equivalent,

You thought wrong.

David> So perl compacts undef values in argument lists,

No.

undef is the size of a scalar.  If you return undef in a list context,
it's a one element list.  Your two return statements are similar to:

  @returnvalue = (); # return;
  @returnvalue = (undef); # return undef;

Definitely different-sized lists.  Nothing hard to remember.  Just
keep track of what you're doing.  And remember, the empty list is not
an undef!

Now, in a *scalar* context, an empty list causes the target to become undef:

  $returnvalue = (); # makes it undef
  $returnvalue = (undef); # also makes it undef

So maybe that's what you (incorrectly) overgeneralized.

print "Just another Perl hacker,"

-- 
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, 30 Oct 2000 08:31:29 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: undef values removed from argument list?
Message-Id: <slrn8vp5ph.ac5.mgjv@martien.heliotrope.home>

On Sun, 29 Oct 2000 15:48:46 -0500,
	David Coppit <newspost@coppit.org> wrote:
> Hi all,
> 
> A simple Perl question:
> 
> I though this:
>   return;
> and this:
>   return undef;
> were equivalent, but they're not:

# perldoc perlsub
[snip]
       the context of the subroutine call.  If you specify no
       return value, the subroutine returns an empty list in list
       context, the undefined value in scalar context, or nothing
       in void context.  If you return one or more aggregates
       (arrays and hashes), these will be flattened together into
       one large indistinguishable list.
[snip]

> #!/usr/bin/perl
> 
> print "undefined\n" unless defined bar();

scalar context

> foo(bar());

list context

> print "undefined\n" unless defined baz();

scalar context

> foo(baz());

list context

bar() and baz() are both called in list context as arguments to foo, so

> sub bar { return; }

This will return the empty list (), and

> sub baz { return undef; }

this a single undef.

> sub foo { print "Arg list size is: " . $#_ . "\n"; }

> undefined
> Arg list size is: -1

which indicates an empty list.

> undefined
> Arg list size is: 0

which indicates a list with one element. And that element is undef.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | This matter is best disposed of from
Commercial Dynamics Pty. Ltd.   | a great height, over water.
NSW, Australia                  | 


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

Date: Mon, 30 Oct 2000 07:44:11 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: what does /warn "$x" if "$x"/ mean
Message-Id: <slrn8vp30r.ac5.mgjv@martien.heliotrope.home>

On Sun, 29 Oct 2000 08:07:26 -0500,
	Tad McClellan <tadmc@metronet.com> wrote:
> >When I say I wrote, I meant I
>                      ^^^^^^^
> >take responsiblilty for it, not credit. 
> 
> 
> Then it is fine to write that when you are writing to yourself.
> 
> When writing to others however, you should write so that *they*
> will understand it correctly.

`When I use a word,' Humpty Dumpty said in rather a scornful tone, `it
means just what I choose it to mean -- neither more nor less.' 

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.   | from a rich salesperson.
NSW, Australia                  | 


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

Date: Sun, 29 Oct 2000 13:29:08 -0800
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: what does /warn "$x" if "$x"/ mean
Message-Id: <39FC96A4.F89AE369@acm.org>

Martien Verbruggen wrote:
> 
> `When I use a word,' Humpty Dumpty said in rather a scornful tone, `it
> means just what I choose it to mean -- neither more nor less.'

s/Humpty Dumpty/Godzilla/;

:-)

John


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 4756
**************************************


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