[17544] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4964 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 24 21:05:30 2000

Date: Fri, 24 Nov 2000 18:05:08 -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: <975117908-v9-i4964@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 24 Nov 2000     Volume: 9 Number: 4964

Today's topics:
        $1 doesn't seem to hold anything after matching <V@T.K>
    Re: $1 doesn't seem to hold anything after matching <tony_curtis32@yahoo.com>
    Re: $1 doesn't seem to hold anything after matching (Tad McClellan)
    Re: $1 doesn't seem to hold anything after matching <uri@sysarch.com>
    Re: $1 doesn't seem to hold anything after matching <s2mdalle@titan.vcu.edu>
    Re: Check for integer <bart.lateur@skynet.be>
    Re: Check for integer <lincmad001@telecom-digest.zzn.com>
    Re: Compiling Curses-1.05 Module (Chris Fedde)
    Re: Counting bits. <lincmad001@telecom-digest.zzn.com>
    Re: Counting bits. (Martien Verbruggen)
    Re: How many free space on my Hd ? <s2mdalle@titan.vcu.edu>
        newbie problem with win32 activestateperl and apache (Grimpoteuthis)
    Re: Perl and JPG (Martien Verbruggen)
    Re: perl options <bart.lateur@skynet.be>
    Re: perl options (Flint Slacker)
    Re: perl options (Martien Verbruggen)
    Re: perl sysadmin script (Tom Hoffmann)
    Re: perl2exe, does anybody know this software? <bart.lateur@skynet.be>
    Re: Problem w/ Meta Characters <jeffp@crusoe.net>
    Re: Retrieving HTML variables (values) in Perl <ayambema@adelphia.net>
        Retrieving HTML variables in Perl <ayambema@adelphia.net>
    Re: Splitting Strings (Tad McClellan)
    Re: Stripping carriage returns <bart.lateur@skynet.be>
    Re: Stripping carriage returns (Garry Williams)
    Re: Stripping carriage returns (Tad McClellan)
    Re: Stripping carriage returns <martinheinsdorf@codesign.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 25 Nov 2000 01:13:27 +0200
From: VTK <V@T.K>
Subject: $1 doesn't seem to hold anything after matching
Message-Id: <3A1EF617.A6E0E29D@T.K>


Couldn't find answer to this one from the faq.

I'm trying to catch the output of a C program using the backticks. It
seems to find the correct string (takes the right path, see below), but
the $1 variable is empty. Why ?
The string that I'm looking for is eg. "rev 1.73"


$output_line = `a.out`;

if ( $output_line =~ /rev\s\d+\.\d+/ ) {
	print $1, "\n"; # this prints just a empty line...
} else {
	print "Sorry, didn't find anything \n";
}


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

Date: 24 Nov 2000 17:34:44 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: $1 doesn't seem to hold anything after matching
Message-Id: <87pujlj65n.fsf@limey.hpcc.uh.edu>

>> On Sat, 25 Nov 2000 01:13:27 +0200,
>> VTK <V@T.K> said:

> Couldn't find answer to this one from the faq.

> I'm trying to catch the output of a C program using the
> backticks. It seems to find the correct string (takes
> the right path, see below), but the $1 variable is
> empty. Why ?  The string that I'm looking for is
> eg. "rev 1.73"

> if ( $output_line =~ /rev\s\d+\.\d+/ )

$1 is the first remembered match in the pattern.  But you
aren't remembering anything (...) so it's not doing what
you expect.  Parenthesise the bit of the pattern you want
to save and all will be well.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Fri, 24 Nov 2000 17:46:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: $1 doesn't seem to hold anything after matching
Message-Id: <slrn91trv2.1lr.tadmc@magna.metronet.com>

VTK <V@T.K> wrote:

>the $1 variable is empty. Why ?


Because you do not have any parenthesis in your pattern.


>if ( $output_line =~ /rev\s\d+\.\d+/ ) {
>	print $1, "\n"; # this prints just a empty line...


   if ( $output_line =~ /(rev\s\d+\.\d+)/ ) {


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


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

Date: Fri, 24 Nov 2000 23:54:53 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: $1 doesn't seem to hold anything after matching
Message-Id: <x7y9y9apte.fsf@home.sysarch.com>

>>>>> "V" == VTK  <V@T.K> writes:

  V> I'm trying to catch the output of a C program using the backticks. It
  V> seems to find the correct string (takes the right path, see below), but
  V> the $1 variable is empty. Why ?

  V> $output_line = `a.out`;

please don't link to a.out. name it something useful.

  V> if ( $output_line =~ /rev\s\d+\.\d+/ ) {

$1 and friends are set by using parens to grab matched substrings. you
have no parens in that regex. 

read perlre for more on grabbing.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Fri, 24 Nov 2000 14:14:26 +0500
From: "David Allen" <s2mdalle@titan.vcu.edu>
Subject: Re: $1 doesn't seem to hold anything after matching
Message-Id: <8vn0kc$i5n$2@bob.news.rcn.net>

In article <3A1EF617.A6E0E29D@T.K>, "VTK" <V@t.k> wrote:

> 
> Couldn't find answer to this one from the faq.
> 
> I'm trying to catch the output of a C program using the backticks. It
> seems to find the correct string (takes the right path, see below), but
> the $1 variable is empty. Why ? The string that I'm looking for is eg.
> "rev 1.73"
> 
> 
> $output_line = `a.out`;
> 
> if ( $output_line =~ /rev\s\d+\.\d+/ ) {
> 	print $1, "\n"; # this prints just a empty line...
> } else {
> 	print "Sorry, didn't find anything \n";
> }

Use parens around rev\s\s+\.\d+.

That is called using a backreference.  The first
things you put in parens show up in $1. The second
thing shows up in $2.  Etc.

BTW, start using the -w flag to perl when you run
your programs.  If you had done that, I think perl
would have complained about you using an
uninitialized value.


-- 
David Allen
http://opop.nols.com/
----------------------------------------
"I just went visual on this goofy looking Finn riding on a gnu,
 wielding one pissed off penguin... gah"
 - Bob The Sane


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

Date: Fri, 24 Nov 2000 23:25:52 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Check for integer
Message-Id: <gltt1to5bmv7gf34p4b8ft1a9ct89eo4kg@4ax.com>

Shallowen wrote:

>If I have a number, say 18.88, stored as an element of an array, what is
>the most elegant way to check that that number is:
>exactly divisible by 0.64 after 0.32 has been subtracted from the original
>number.

Danger!

You should be very aware of the fact that numbers like 0.64 do not have
an exact representation in floating point. So, even if it may look like
this number is exactly 18.88, it is not. Ever.

Integers do have an exact representation.

So, what can you do? First, check the string representation of the
number, and see if there are no more than 2 decimals. If that is ok,
multiply it by 100, and take the nearest integer. Now, you can either
subtract 32, and check if the result of this is divisible by 64 (i.e.
($n-32)%64==0 ). Or, check if the number modulo 64 is 32: $n%64==32 .

A possible problem with the modulo operator is that on some platforms it
only works properly for integers that fit into 32 bits. In this case,
this implies that your range is limited to 2**32/100, approximately 43
million; or likely even only half as much.

-- 
	Bart.


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

Date: Fri, 24 Nov 2000 15:47:09 -0800
From: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: Check for integer
Message-Id: <241120001547093309%lincmad001@telecom-digest.zzn.com>

In article <t1snqbraibd523@corp.supernews.com>, Shallowen
<shallow@mail.com> wrote:

> If I have a number, say 18.88, stored as an element of an array, what is
> the most elegant way to check that that number is:
> exactly divisible by 0.64 after 0.32 has been subtracted from the original
> number. I tried using a modular divide, but I reached (and went past) the
> limit of my understanding of maths at that point.
> 
> So something like this (this is pseudo-code, I know it means not much to
> PERL as it is):
> 
> if (((($sample_array[$element])-0.32)/0.64)==an integer) {
>   print "It's divisible!\n";
> } else {
>   print "D'oh! It's not exactly divisible!\n";
> }
> 
> 
> or something like that.
> 
> Any help much appreciated! If there's a function which tests for this,
> sorry for wasting your time, but I looked, and couldn't find it. (Although
> doubtless that means very little =)

if ( (my $x = ($array[$elem] - 0.32)/0.64) , $x == int $x ) { ...

The comma there is a "binary comma operator" because it is in a scalar
context. In other words, it evaluates the expression on the left and
then ignores that value insofar as determining the value of the entire
expression in the outermost parentheses.

Another approach:

if ( ($array[$elem] * 100 - 32) % 64 == 0 ) { ...

Unfortunately, that one DOESN'T WORK! The modulus operator converts its
operands to integers. Thus, for instance, 0.329999999 would test true
in that code fragment.

Lastly,

use POSIX qw(fmod);  # fmod($x, $y) = floating-point version of $x % $y
if ( fmod($array[$elem] - 0.32, 0.64) == 0.00 ) { ...

However, I am told that using the POSIX module comes with a performance
hit, even if you only import one symbol. On the other hand, if you're
looking for "quick and dirty," this may be your best bet.

If your array elements are all >= 0.32, you could simplify the last one
to (fmod($a[$e], 0.64) == 0.32)

Of course, in either case you still have to worry about the issue of
floating-point precision. Do you really want 0.320000001 or 0.319999999
to return false? If not, you might use "sprintf" to round your value
first.


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

Date: Sat, 25 Nov 2000 01:03:59 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Compiling Curses-1.05 Module
Message-Id: <3eET5.58$QX6.170607104@news.frii.net>

In article <vzt3dghtp04.fsf@cs.queensu.ca>,
Eric Rountree  <rountree@cs.queensu.ca> wrote:
>Hello to all.
>
>I'm not sure where to go from here. I don't have a lot of experience
>with includes and libraries. I'm running Solaris 2.6, gcc version
>2.8.1, and Perl, v5.6.0.
>
>Thanks in advance for any suggestions.

You need to be sure that the build process is realy finding ncurses
rather than the BSD or SYSV curses that might be the default.  Look
at the README or install files in the Curses distribution.

chris

-- 
    This space intentionally left blank


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

Date: Fri, 24 Nov 2000 15:57:37 -0800
From: Linc Madison <lincmad001@telecom-digest.zzn.com>
Subject: Re: Counting bits.
Message-Id: <241120001557371075%lincmad001@telecom-digest.zzn.com>

In article <8vlp38$1th@nntpa.cb.lucent.com>, Michael Guenther
<MiGuenther@lucent.com> wrote:

> Hi Michael this is Michael try
> 
> my $str = "100110101";
> my $count = 0;
> 
> while ($str=~/1/g){
>    $count ++;
> }
> print $count;

Simpler:

my $count = $str =~ tr/1/1/;

As to how you view an integer as a string of bits, see pack/unpack.


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

Date: Sat, 25 Nov 2000 11:15:09 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Counting bits.
Message-Id: <slrn91u14d.imr.mgjv@martien.heliotrope.home>

On Fri, 24 Nov 2000 09:32:34 -0500,
	Tad McClellan <tadmc@metronet.com> wrote:
> Wolfgang Hielscher <W.Hielscher@mssys.com> wrote:
>>Michael Guenther wrote:
>>> my $count = 0;
>>> while ($str=~/1/g){
>>>    $count ++;
>>> }
>>
>>Or simply use m//g in a list context:
>>   my $count = @{[$str =~ m/1/g]};
> 
>    my $count = $str =~ tr/1//;

And of course, neither of these answers the question, which was how to
count the numbers of bits set in an integer. Not how to count the
numbers of ones in a string. I'm sure Tad already knows this, and just
forgot to mention it.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | life ain't fair, but the root
Commercial Dynamics Pty. Ltd.   | password helps. -- BOFH
NSW, Australia                  | 


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

Date: Fri, 24 Nov 2000 14:11:04 +0500
From: "David Allen" <s2mdalle@titan.vcu.edu>
Subject: Re: How many free space on my Hd ?
Message-Id: <8vn0e2$i5n$1@bob.news.rcn.net>

In article <8vliq9$r2q@aix4.segi.ulg.ac.be>, "Frederic"
<NonDisponible@not.available.com> wrote:

> I'd like to know how many free space available on my HD ??
> 
> which function ??
> 
> Thks Fred.

This is ugly, and it will fail miserably if you're
not running UNIX.

my $hd_im_checking = "/dev/hda1";
my @lines = grep(/$hd_im_checking/, `df -k`);

map { 
   m/$hd_im_checking\s+\d+\s+\d+\s+(\d+)/;
   my $kb_free = $1;
   print "$kb_free\n" if($kb_free);
} @lines;

Notice that I am "elegantly" assuming that you're
running the same version of df that I'm using.
[x@mothra x]$ df --version
df (GNU fileutils) 4.0.32
Written by Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert.

Copyright (C) 2000 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

-- 
David Allen
http://opop.nols.com/
----------------------------------------
"I just went visual on this goofy looking Finn riding on a gnu,
 wielding one pissed off penguin... gah"
 - Bob The Sane


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

Date: Sat, 25 Nov 2000 01:02:14 GMT
From: fish@7cs.net (Grimpoteuthis)
Subject: newbie problem with win32 activestateperl and apache
Message-Id: <3a1f0c57.413580483@News>

Hello perl community,

I seem to be having a great deal of difficulty getting my perl scripts
to actually execyute inside of my web browser using activestate perl
and apache for win32.There is a lot of documentation around for the
linux version but the win version is kinda slim by comparison. Anyways
after going over the documentation all day and reinstalling everything
twice I'm still getting the same problem. 

Perl runs from DOS, apache runs and serves up web pages, but try to
run perl code from the browser and I get a windows prompt for
save/open file then a blinking DOS prompt for a split second if I
choose to open the file. I'm going to include the instructions I
followed for setting up perl and apache below so that people can take
a look at them. Windows doesn't seem to know what to do with the perl
script. I've checked the file  extensions and there is a pl plx file
type that points to the perl executable. So now I'm quite lost and
looking for help. 

Does the indigoperl built in combo of apache-dynamic perl work any
better?


Instructions I got from 
http://www.egovision.com/htmlresources/articles/apache_win32.html
I tried this after I had failed to get success using the included
documentation with the install.

Step 1 - Getting the software.
At the time of writing Apache for Win32 is on Build 1.3.6 and the
current version of Active Perl fro Win32 is Build 515.
Apache for Win32 can be downloaded from www.apache.org and 
Perl can be obtained from http://www.activestate.com/ActivePerl/ 

Step 2 - Installing Apache for Win32.

The following example illustrates the procedure for installing and
configuring both Apache and Perl onto a hard drive that is totally
empty. I would suggest that you do this for two important reasons....
It makes sense to keep the "server" part of your system separate.
It makes writing (and following) this article easy 
Apache will be installed on drive D: in this example, obviously you
should modify all paths and drive letters accordingly should you
choose to install to a different location.
You will have downloaded an exe file for Apache, run this file to
start the install process.
When prompted, change the install path to D:\apache 
Go for Custom Install and just install the whole lot..... it doesn't
hurt.
Open the file httpd.conf located in d:\apache\conf using Notepad and
use Find to locate the following line......
#ServerName new.host.name 
and remove the # to leave ServerName new.host.name 

Start the Apache console app ether from the Start menu or by opening a
DOS Prompt window and typing D:\apache\Apache.exe -d d:\APACHE -s

Your Win32 Apache server should now be running. To check open your
browser and type http://localhost and you should see the Apache "It's
Worked" page. Hey Presto! one local server.

(Internet Explorer will probably try to establish a connection to the
web, do not hit Cancel just leave the pop-up in the background. If
you're using Netscape there should be no problem but while in use
later you MUST keep an eye on it to see if its just reading from it's
cache when you're modifying files and nothing seems to be happening.)

Close the console app either via the Start menu or by typing

D:\apache\Apache.exe -d d:\APACHE -k shutdown 


Step 3 - Installing Active Perl for Win32

If you get the paths right in all the conf files you can install Perl
anywhere on your system - it really doesn't matter. For what we're
trying to achieve here (a local Web server) we'll install to a
directory path of D:\apache\usr and the cgi-bin directory will be
D:\apache\cgi-bin 

Create a new directory D:\apache\usr

You will have downloaded file APi515e.exe, run this file to start the
install process.

When prompted set the install path to D:\apache\usr and install all
components.

Allow setup to add the path statement to your autoexec.bat file or add

SET PATH=d:\APACHE\USR\BIN;%PATH% 
to this file yourself.


Step 4 - Making Perl work with Apache

Open the file httpd.conf located in d:\apache\conf using Notepad and
use Find to make sure that the following lines read as follows.......

UserDir "d:/apache/usr/"

ScriptAlias /cgi-bin/ "d:/apache/htdocs/cgi-bin/"

<Directory "d:/apache/cgi-bin/">
        AllowOverride None
        Options None
</Directory>

and change #AddHandler cgi-script .cgi to
AddHandler cgi-script .cgi (remove the #)

Now open the file srm.conf located in d:\apache\conf using Notepad and
add.....
ScriptAlias /cgi-bin/ "d:/apache/htdocs/cgi-bin/"
to this file as well

Restart your machine and run the Apache console app again, this time
you will notice that the DOS prompt window has "Perl" in its top name
bar. 
Perl is working!!!!!!!!!!!!!


Step 5 - Making your scripts work on your local drive.

The first line of your scripts calls for the perl interpreter, in
order to run these scripts locally change this call to 

#!d:/apache/usr/bin/perl.exe

Any problems you have should only be the fault of the script, NOT the
server configuration.

Don't forget to change the perl path before you upload your scripts so
that they can find the perl niterpreter on your Web server.

Happy scripting,







Anyways thanks very much if you got this far,

sincerely

greg


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

Date: Sat, 25 Nov 2000 11:25:35 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Perl and JPG
Message-Id: <slrn91u1nv.imr.mgjv@martien.heliotrope.home>

On Fri, 24 Nov 2000 13:12:52 +0100,
	Michael Guenther <MiGuenther@lucent.com> wrote:
> Does any body out there ever used perl to manipulate JPG files?
> 
> What I need is an idea where to start and which module is usable for this.

Image::Magick
Gimp
Maybe Imager
Possibly GD

You have not specified what you need to do in sufficient detail.

> I have a pic of several layers an I want to combine them with perl

That makes no sense, really. You ask for something that can manipulate
JPEG. JPEG has one layer only. Now you say that you have an image with
multiple layers.  If you really do need multiple layers, then the top
two of that list will work, and maybe the third as well.

If you want better advice on what to do and what to use, you should
probably be more verbose in what you want to do, and at least be
consistent in what you ask for,

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | 
Commercial Dynamics Pty. Ltd.   | Curiouser and curiouser, said Alice.
NSW, Australia                  | 


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

Date: Fri, 24 Nov 2000 23:10:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl options
Message-Id: <v3tt1tokkn0b8ok52ndthpb3sm8gcrfc1c@4ax.com>

Flint Slacker wrote:

>I'm just
>wondering if you can improve performance by turning off certain things
>like syntax checking, etc.....

Er... Perl must first understand what your program means before it can
possibly complile it. That implies that it requires that your script has
a valid syntax before it can be compiled. Perl needs to compile a script
before it can run it. Ergo, Perl needs to check your syntax before it
can run it. No way around it.

-- 
	Bart.


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

Date: Sat, 25 Nov 2000 00:35:57 GMT
From: flint@flintslacker.com (Flint Slacker)
Subject: Re: perl options
Message-Id: <3a1f0628.34584396@news.tcn.net>


I'm not new to programming and I still think my question is valid.  If
perl reads in a script, it most likely balances brackets, braces,
looks for barewords, and whatever other tests... and finally runs the
script.  I was just wondering if that step could be skipped, that's
all.  

Flint


On Fri, 24 Nov 2000 14:33:14 -0500, tadmc@metronet.com (Tad McClellan)
wrote:

>
>[ Yet anotherJeopardectomy performed ]
>
>
>Flint Slacker <flint@flintslacker.com> wrote:
>
>>On Fri, 24 Nov 2000 12:20:43 -0500, tadmc@metronet.com (Tad McClellan)
>>wrote:
>>>
>>>[ Jeopardectomy performed ]
>>>
>>>Flint Slacker <flint@flintslacker.com> wrote:
>>>>On Thu, 23 Nov 2000 14:03:44 -0500, tadmc@metronet.com (Tad McClellan)
>>>>wrote:
>>>>
>>>>>Flint Slacker <flint@flintslacker.com> wrote:
>>>>>
>>>>>>can improve performance by turning off certain things
>>>>>                            ^^^^^^^^^^^
>>>>>>like syntax checking
>>>>>      ^^^^^^^^^^^^^^^
>>>>>
>>>>>Is that a joke?
>>>>>
>>>>>(if so, you forgot the smiley. if not, then you have a severe
>>>>> dearth of knowledge about how programming computers works.
>>>>>)
>>>
>>>>No reason to be an asshole Tad!
>>>
>>>I guess then, that I can imply that you did not forget a smiley?
>>>
>>>In that case, we could help you out by describing why "turning
>>>off syntax checking" is an absurd concept.
>>>
>>>But I'm disinclined to help now anyway, you seem determined to
>>>maintain your current level of knowledge. 
>
>>You didn't help Tad, 
>
>
>Well yes. Because I couldn't tell if you were joking or not.
>(and the only other help would have been pointing out
> perlrun.pod, and someone had already done that, so I
> didn't repeat it.
>)
>
>So I asked if you were joking or not.
>
>
>>you tried to make an ass of me
>
>
>No I didn't.
>
>I said that you did not know something (the role of "syntax"
>in computer programming).
>
>Not knowing something does not make you an ass.
>
>Everybody "doesn't know something" when they set out to learn
>something new. It's to be expected. Getting mad when someone
>says that there is something that you don't know about is an
>unproductive attitude.
>
>If, rather than resorting to name calling, you had said:
>
>   so tell me what I don't know about programming computers.
>
>Then I would have explained a programming fundamental that
>you appear unaware of.
>
>But instead you only got killfiled.
>
>Good luck though!



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

Date: Sat, 25 Nov 2000 11:48:12 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: perl options
Message-Id: <slrn91u32c.imr.mgjv@martien.heliotrope.home>

[Please, in the future, post your replay AFTER the suitably trimmed post
you reply to. Tad has already obliquely asked you to do this a few
times. In this newsgroup, and on Usenet in general, that is the accepted
standard way of quoting.]

On Sat, 25 Nov 2000 00:35:57 GMT,
	Flint Slacker <flint@flintslacker.com> wrote:
> 
> I'm not new to programming and I still think my question is valid.  If
> perl reads in a script, it most likely balances brackets, braces,
> looks for barewords, and whatever other tests... and finally runs the
> script.  I was just wondering if that step could be skipped, that's
> all.  

No, it cannot be skipped. Only if perl were stored as bytecode could it
maybe be skipped. Compilers HAVE to do syntax checking. It's their job.
Join the perl porters mailing list and discuss your ideas on ow to skip
syntax checking in perl there. See what they say. Or subscribe to
comp.compilers, and ask there why.

Two people have now told you it isn't going to work, and this is the
third. Please stop arguing this until you have arguments as to why you
think it IS possible. It is ok to argue, but only if you have arguments.
Your question has been answered.

[Enormous snip of out-of-context quote]

Martien
-- 
Martien Verbruggen              | The Second Law of Thermodenial: In
Interactive Media Division      | any closed mind the quantity of
Commercial Dynamics Pty. Ltd.   | ignorance remains constant or
NSW, Australia                  | increases.


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

Date: Fri, 24 Nov 2000 23:34:48 GMT
From: tom.hoffmann@worldnet.att.net (Tom Hoffmann)
Subject: Re: perl sysadmin script
Message-Id: <slrn91tugh.lp.tom.hoffmann@localhost.localdomain>

On Fri, 24 Nov 2000 13:12:19 -0800, Term <razorlines@hotmail.com> wrote:
>request for a script:
>
>I am looking to locate a script that does any of the following things,
>that can be tweaked into doing exactly what I need (of course, the
>less tweaking a stock system needs to run this, the better). I'm
>looking to keep track of things like memory usage, i/o wait, disk
>usage, load average, maybe at some point I'll want to track
>mutex spins, context shifts and such, but not right now. I will then
>be making the script output to a file in comma delimited format. What
>I am seeking,  kind perl gurus, is a script that does any of this,
>that I can have permission to either mess with directly, or just look
>at for inspiration. If anyone would be so kind as to assist me in this
>endeavor, I would be much appreciative.

Assuming you are in a Unix environment, use 'sar' (sa1, sa2) to collect
the system activity data and generate formatted activity report files.
It is a straight-forward programming exercise to create data files from
the formatted sar reports.

You do not need to be a perl guru for this ... I have just written such a
script as my *first* perl program. I do have a fairly extensive
programming background in other languages. The script also invokes
gnuplot to create *.png graphs from the data files for posting to the web.

There is a program called 'sarge' lurking on the web (I forget
where) written by Ed Finch that performs this function for multiple
hosts, and it goes so far as to set up the whole sa1/sa2 processes in
cron automatically.  I chose not to use it because I wanted to learn perl,
and because it did its own graph creation, rather than relying on gnuplot
which has more powerful and flexible plotting capabilities. The code
makes for a good read for a perl newbie, though, if you have done some
preliminary reading and understand some of the perl basics.

Good luck.


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

Date: Fri, 24 Nov 2000 23:13:02 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: perl2exe, does anybody know this software?
Message-Id: <iett1toko35rvaf63a93lka7hdks8offka@4ax.com>

Martien Verbruggen wrote:

>The only excuse that perl2exe had to exist was that
>you only had to ship one binary, and could avoid installing perl on all
>machines. Then they start splitting it up in multiple binaries.
>
>Now where is the use in that?

Even with separate DLL's, this doesn't require certain places for your
files. All it requires is that it is able to find the files. Putting
them all right next to each other is a fine solution. A bunch of files,
but still no need for an installer.

-- 
	Bart.


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

Date: Fri, 24 Nov 2000 19:11:12 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Problem w/ Meta Characters
Message-Id: <Pine.GSO.4.21.0011241906450.714-100000@crusoe.crusoe.net>

[posted & mailed]

On Nov 24, W. Chad Smith said:

>            $accountnoweb = quotemeta $accountnoweb;
>            $laccountno = quotemeta $laccountno;
>            print "'$laccountno' '$accountnoweb'<BR>";
>            if ( $laccountno =~ $accountnoweb ) {

>'99072348895\%Q9F3\+' '99072348895\%Q9F3\+'

Don't quotemeta the $laccountno string.  That's the root of your problem:

  $x = quotemeta "ca+bc";  # ca\+bc
  $y = quotemeta "a+b";    # a\+b
  $x =~ /$y/;

That's try to match the regex /a\+b/ on the string 'a\+b', which will not
match, since the \+ in the regex means "match a literal '+'", and the
string does not have an 'a' followed by a '+', but an 'a' followed by a
'\'.

Better yet, don't use a regex at all, and don't use quotemeta.

  $x = "ca+bc";
  $y = "a+b";
  if (index($x, $y) > -1) { ... }

-- 
Jeff "japhy" Pinyan     japhy@pobox.com    http://www.pobox.com/~japhy/
CPAN - #1 Perl Resource  (my id:  PINYAN)       http://search.cpan.org/
PerlMonks - An Online Perl Community          http://www.perlmonks.com/
The Perl Archive - Articles, Forums, etc.   http://www.perlarchive.com/





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

Date: Sat, 25 Nov 2000 02:03:27 GMT
From: "hokiebear" <ayambema@adelphia.net>
Subject: Re: Retrieving HTML variables (values) in Perl
Message-Id: <P5FT5.2554$tR2.78713@news1.news.adelphia.net>

Sorry for the error, the subject heading should read "Retrieving HTML values
in Perl".

hokiebear <ayambema@adelphia.net> wrote in message
news:F3FT5.2552$tR2.78995@news1.news.adelphia.net...
> A question for the Perl gurus out there. Supposing I have the following
> fragments of Perl code:
>
> #_____________________________________
> print <<EOM;
> <P ALIGN="LEFT">Email:<INPUT TYPE="TEXT" NAME="Email" SIZE="30"></P>
> EOM
> #_____________________________________
>
> I can retrieve the email address entered in the above code fragment using:
> $input{'Email'}
>
> Now, supposing I instead have:
> #_______________________________
>  print &PrintHeader,&HtmlTop("");
>
> print "<P ALIGN=\"LEFT\">Email:<INPUT TYPE=\"TEXT\" NAME=\"Email\"
> SIZE=\"30\"></P>\n";
> #__________________________________
>
> What Perl syntax do I use to retrieve the email address entered?
>
> Thank you.
>
> ---amba---
>
>
>
>




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

Date: Sat, 25 Nov 2000 02:01:09 GMT
From: "hokiebear" <ayambema@adelphia.net>
Subject: Retrieving HTML variables in Perl
Message-Id: <F3FT5.2552$tR2.78995@news1.news.adelphia.net>

A question for the Perl gurus out there. Supposing I have the following
fragments of Perl code:

#_____________________________________
print <<EOM;
<P ALIGN="LEFT">Email:<INPUT TYPE="TEXT" NAME="Email" SIZE="30"></P>
EOM
#_____________________________________

I can retrieve the email address entered in the above code fragment using:
$input{'Email'}

Now, supposing I instead have:
#_______________________________
 print &PrintHeader,&HtmlTop("");

print "<P ALIGN=\"LEFT\">Email:<INPUT TYPE=\"TEXT\" NAME=\"Email\"
SIZE=\"30\"></P>\n";
#__________________________________

What Perl syntax do I use to retrieve the email address entered?

Thank you.

---amba---






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

Date: Fri, 24 Nov 2000 17:25:36 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Splitting Strings
Message-Id: <slrn91tqn0.1j2.tadmc@magna.metronet.com>

Jean <jean.zoch@utoronto.ca> wrote:
>
>Anyone have any ideas on how I can split a string that looks like:
>
>$string = BLAH BLAH <BODY stuff="stuff" foo="bar"> BLAH BLAH ";


That looks like HTML rather than just a string.

"splitting strings" is not the same as "parsing HTML", and
the answer to the question that you didn't ask would have
led to much more robust code.

In other words, use a module that understands HTML to
process HTML. Don't try and do what you are trying to do.
(or do it anyway, but know that you are "being bad" by
 doing it)


>into an array that looks like:
>
>('BLAH BLAH <BODY stuff="stuff" foo="bar">', ' BLAH BLAH ');
>
>I.E. I would like to split the string right after the close of the BODY tag.


   my @array = m/(.*?<body[^>]*>)(.*)/is;

or (probably better)

   my($pre, $post) = m/(.*?<body[^>]*>)(.*)/is;


>Thanks a bunch!

You're welcome.

But do not use the code I showed (it has a bug that I have
not mentioned, think "failed match"). Use an HTML module 
for processing HTML data.


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


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

Date: Fri, 24 Nov 2000 23:27:36 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Stripping carriage returns
Message-Id: <8cut1tkmj9uf3gi417f58ghunckqr0a8r4@4ax.com>

Marcus wrote:

>how would I
>strip carriage returns after a network transfer 

	tr/\r//d;

-- 
	Bart.


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

Date: Fri, 24 Nov 2000 23:32:15 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Stripping carriage returns
Message-Id: <3UCT5.1630$xb1.96474@eagle.america.net>

[ post re-ordered ]

On Fri, 24 Nov 2000 14:47:36 -0800, Marcus
<marcus@allinonemortgage.com> wrote:
>"Mark W. Schumann" <catfood@apk.net> wrote in message
>news:8vmnrd$iq2@junior.apk.net...
>> In article <GmyT5.4462$FO1.145352@brie.direct.ca>,
>> Marcus <marcus@allinonemortgage.com> wrote:
>> >Illegal character \015 (carriage return) at ./Library/web_store.setup.db
>> >line 4.
>> >(Maybe you didn't strip carriage returns after a network transfer?)
>>
>> Well, um, did you strip carriage returns after a network transfer?
>> Perl doesn't like seeing carriagereturn/linefeed at the end of line of
>> code.  Perl wants to see just a linefeed.
>>
>I know it might sound like another stupid question to you but how would I
>strip carriage returns after a network transfer (I have looked for
>documentation on how to do this and can't find any)? I have never run into
>this I write all my perl code in a plain text file and upload using cuteftp.
>I have never had a problem like this before. Thanks in advance.

You probably want to check your FTP client to see how to set it to
tranfer in text mode.  On many, that is simply the `ascii' command
before doing the transfer.  

-- 
Garry Williams


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

Date: Fri, 24 Nov 2000 17:35:43 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Stripping carriage returns
Message-Id: <slrn91tr9v.1j2.tadmc@magna.metronet.com>

[ Please put your comments *following* the quoted text that
  you are commenting on.
]


Marcus <marcus@allinonemortgage.com> wrote:

>I know it might sound like another stupid question to you but how would I
>strip carriage returns after a network transfer 


FTP will automatically do the line ending conversions while 
making the file transfers, then you'll never have this 
kind of problem.

If you use "binary" transfer mode, it does not do the conversions.

If you use "ASCII" (sometimes called "text") mode, then it will
do the conversions for you.

Find out how to do ASCII mode file transfers with your FTP program.


>(I have looked for
>documentation on how to do this and can't find any)? 


Can't find documentation on how to remove a character from
a file? That's kinda hard to believe...


   perl -p -i -e 'tr/\r//d' file1 file2 file3 ...


>I have never run into
>this I write all my perl code in a plain text file and upload using cuteftp.
>I have never had a problem like this before.


Different Operating Systems use different line-ending markers.

You run into this problem only when you write on one OS but
execute on another OS.

But people do that frequently enough that it has been automated
by the tranfer protocol.


[ snip Jeopardy quoted text ]

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


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

Date: Sat, 25 Nov 2000 00:05:09 GMT
From: Martin Heinsdorf <martinheinsdorf@codesign.net>
Subject: Re: Stripping carriage returns
Message-Id: <3A1F020D.BDB1AD66@codesign.net>

The error message you are getting looks pretty explicit to me.
Why not try and remove those extra carriage returns? Since
you're on a Unix system, I assume you have vi (or vim). The
following vi command will search for and delete all them critters.

:1,$s/<control-v><control-m>//g

Persevere.

Martin Heinsdorf

Marcus wrote:

> I am fairly new to perl and I am modifying an exsisting script. It is an
> open source shopping cart found at extropia.com. I had the script up and
> running on my previous server, but it seems to give an error on my new
> server with the same version of perl and both servers are unix based. All
> the permissions have been set correctly and all the files are there. I
> checked the error log and this is the error:
>
> Illegal character \015 (carriage return) at ./Library/web_store.setup.db
> line 4.
> (Maybe you didn't strip carriage returns after a network transfer?)
>
> Here is line 4 in the main script:
>
> &require_supporting_libraries (__FILE__, __LINE__,
>        "./Library/web_store.setup.db");
>
> Does this make any sense to anyone. It is probably something I am
> overlooking. Any help or direction appreciated. If you need more info please
> let me know. Thanks.



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

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


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