[7877] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1502 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 18 19:07:20 1997

Date: Thu, 18 Dec 97 16:00:25 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 18 Dec 1997     Volume: 8 Number: 1502

Today's topics:
     Bulding 5.004 for Interactive UNIX <wbloom@anasazi.com>
     DEBUGGER: How see expr result ? <tim@timji.seaslug.org>
     Re: error when using OPEN(FILE...) under ms iis 2.0 <gordon.leslie.mcdorman@sap-ag.de>
     Re: error when using OPEN(FILE...) under ms iis 2.0 <gordon.leslie.mcdorman@sap-ag.de>
     Evaluate blank text? <feckman@albany.net>
     Re: Evaluate blank text? (brian d foy)
     Re: File Creation on Server from Perl Script (Ronald L. Parker)
     Help - opendir() (David J. Boyd)
     Re: How do I create NDBM file from a flat file? <bruno@prior.ftech.co.uk>
     Re: How to load an assoc. array <achoy@us.oracle.com>
     Re: JOKE (was Teaching programing) (Tad McClellan)
     Re: last modification date on files <fnord@panix.com>
     Re: mysterious "Missing $ on loop variable" error (I R A Aggie)
     Need help optiminzing reads <Clinton.Bodine@mci.com>
     Re: Netscape & MIME On Newsgroups (I R A Aggie)
     Re: Newbie can't add the -w flag to perl to get useful  (Tad McClellan)
     Newbie Pattern Matching question <curt@vphos.net>
     Re: Newbie Pattern Matching question <reibert@mystech.com>
     Re: Newbie Pattern Matching question <#@qz.to>
     Re: Newbie Pattern Matching question <Clinton.Bodine@mci.com>
     Re: perl for Win32 question <gordon.leslie.mcdorman@sap-ag.de>
     Perl Journal, special Java issue <fawcett@SPAMLESS.nynexst.com>
     Re: pgp encrypion via perl script (Alan Olsen)
     Problem installing PERL 5.004_04 on Solaris 2.4.1 syste <petersoe@ucs.orst.edu>
     Proposed features in Perl5.005 <achoy@us.oracle.com>
     Re: Source to count downloads on a file... help please (brian d foy)
     Re: Substitute without exceeding a defined string lengt <kassner@intershop.de>
     Re: Teaching programing <rmelson@pswtech.com>
     Whats wrong with this simple code? <ebd@sunline.net>
     Re: Whats wrong with this simple code? (brian d foy)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Dec 1997 16:18:44 -0700
From: William Bloom <wbloom@anasazi.com>
Subject: Bulding 5.004 for Interactive UNIX
Message-Id: <3499AF54.60958ED1@anasazi.com>

I am attempting to build 5.004 on Interactive 3.2.  Once the build
begins executing miniperl on ext/DynaLoader/Makefile.PL, it core
dumps with a floating point exception.

Is this a known problem?  Any suggestions, work around?

Bill
--------------------------------------------------------------------------
William Bloom <wbloom@anasazi.com>
(602) 906-7525
Anasazi, Inc. - 7500 North Dreamy Draw Drive, Suite 120, Phoenix, Az
85020


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

Date: Thu, 18 Dec 1997 14:53:32 +0000
From: Tim Maher <tim@timji.seaslug.org>
Subject: DEBUGGER: How see expr result ?
Message-Id: <349938EB.89BE0BCB@timji.seaslug.org>

I'm looking for an easy way to determine the value of the last
expression evaluated
in Perl's debugging mode.  Like doing the following in shell:
[ $count -lt 16 ]
echo $?    # this shows the result

So in Perl, when the debugger has just evaluated the following:
    s/abc/def/g    # how many subs did it do?
or
    $count <= 16

how can I directly see the result ?  (i.e., without watching the way it
branches to conditionally executed code, etc., which still would not
tell me the value of the result, just its T/F status)

In a similar vein, when it hits a sub return statement, I see the
expression that
calculates the return value, but I don't get to see the return value
itself!  There
must be a way . . .

TIA

tim@consultix.wa.com



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

Date: Thu, 18 Dec 1997 23:13:51 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
To: markus.rietzler@rzf.nrw.de
Subject: Re: error when using OPEN(FILE...) under ms iis 2.0
Message-Id: <un2hy1byo.fsf@sap-ag.de>

>>>>> "mr" == markus rietzler <markus.rietzler@rzf.nrw.de> writes:

mr> CGI-ERROR the cgi-application doesn't write the complete
mr> http-header

mr> when i set comments before the lines in which the ascii-file is
mr> opened, then the script returns a complete html-page as results
mr> (without the found telephone-book-entries of course). when i use
mr> open (FILE, "<$file") ..... close (FILE) then the script crashes.

If you don't find anything in the FAQs, perhaps posting some of your
code would help.

At any rate, I often find that using the following helps debugging:

		use strict;
		use CGI::Carp qw(fatalsToBrowser);
		use CGI qw(:standard :nph);

		...

		open (FILE, "<$file")
		  or die "Could not open $file: $!";

-- 
-------------------------------------------------------------- 
The opinions expressed above are mine, not my employer's.
      
gordon.leslie.mcdorman@sap-ag.de                               


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

Date: Thu, 18 Dec 1997 23:11:28 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
Subject: Re: error when using OPEN(FILE...) under ms iis 2.0
Message-Id: <uoh2e1c2n.fsf@sap-ag.de>

>>>>> "mr" == markus rietzler <markus.rietzler@rzf.nrw.de> writes:

mr> CGI-ERROR the cgi-application doesn't write the complete
mr> http-header

mr> when i set comments before the lines in which the ascii-file is
mr> opened, then the script returns a complete html-page as results
mr> (without the found telephone-book-entries of course). when i use
mr> open (FILE, "<$file") ..... close (FILE) then the script crashes.

If you don't find anything in the FAQs, perhaps posting some of your
code would help.

At any rate, I often find that using the following helps debugging:

		use strict;
		use CGI::Carp qw(fatalsToBrowser);
		use CGI qw(:standard :nph);

		...

		open (FILE, "<$file")
		  or die "Could not open $file: $!";

-- 
-------------------------------------------------------------- 
The opinions expressed above are mine, not my employer's.
      
gordon.leslie.mcdorman@sap-ag.de                               


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

Date: Thu, 18 Dec 1997 16:51:09 -0500
From: "FeckMan" <feckman@albany.net>
Subject: Evaluate blank text?
Message-Id: <67c68g$3rb$1@gamera.albany.net>

Hello!

I'm a perl newbie who is trying to get a script to ensure that all the
required fields of an HTML form have been filled out (simply not left
blank), and, if not, to generate an error page.  The script works great
except for ONE thing -- I can't figure out how to make the script evaluate
whether or not a variable posted to it from a form is blank or not.

Here's a snip from the code.

sub check_form
{
   if (not $firstname > 0) {&incomplete1}
   if (not $lastname > 0) {&incomplete2}
   if (not $agconame > 0) {&incomplete3}
   if (not $address > 0) {&incomplete4}
}

I've also tried using:

if (not $firstname > '') {&incomplete1}

and

if ($firstname eq '') {&incomplete1}

and

if ($firstname eq ' ') {&incomplete1}

Any ideas would be GREATLY appreciated.  Thanks!

--Jim.




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

Date: Thu, 18 Dec 1997 17:42:02 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Evaluate blank text?
Message-Id: <comdog-ya02408000R1812971742020001@news.panix.com>

In article <67c68g$3rb$1@gamera.albany.net>, "FeckMan" <feckman@albany.net> wrote:

>I'm a perl newbie who is trying to get a script to ensure that all the
>required fields of an HTML form have been filled out (simply not left
>blank), and, if not, to generate an error page.  The script works great
>except for ONE thing -- I can't figure out how to make the script evaluate
>whether or not a variable posted to it from a form is blank or not.

>if ($firstname eq '') {&incomplete1}

are you sure that one didn't work?  it looks okay.

how are you parsing the data?  maybe there are other problems that mask
you success with this one :)

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Thu, 18 Dec 1997 22:04:48 GMT
From: ron@farmworks.com (Ronald L. Parker)
Subject: Re: File Creation on Server from Perl Script
Message-Id: <34999d3e.13994162@10.0.2.33>

On Thu, 18 Dec 1997 13:29:13 -0800, "Henry Wolff" <admin@hatsoft.com>
wrote:

>So the question is, how can I check if a file is on the server, create it if
>it not, and then set the permissions?

Assuming you're wanting to do this by FTP, look into the Net::FTP
module, available from finer CPAN sites everywhere, or, since you're
apparently using Windows, included with the official Win32 Perl binary
distribution from Gurusamy Sarathy, also on finer CPAN sites
everywhere.  Accept no subsitutes.




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

Date: Thu, 18 Dec 1997 22:50:35 GMT
From: djboyd@nospam.sam.on-net.net (David J. Boyd)
Subject: Help - opendir()
Message-Id: <3499a755.33137935@news.on-net.net>

I am trying to find out if opendir has a time out period with it.   

The reason I am asking is that I have a perl script which is kicked off from
dos.  This script then kicks off six other scripts, all of the processes.  (I
now have 7 process running).  Each of these scripts make use of the same common
file which has a mission of opening up each dir on a server, reading and then
creating a file listing, then does the samething to a target server.  When done
a diff program is run and a difference file is created.  

I am able to attach to the server and do a dir from the command line.  At times
the perl scripts work, but for some reason it is not able to open some of the
directories on attached servers.   I am running WinNT 4.0 with Novel 3.1.1
client.  The other problem is that some times it can not attach to every server.
So along with this, for my create process call, I have the process create a new
console, should I changed this?
 ....
If you need more info, or want to look at the code please email at
djboyd@sam.on-net.net.
 ...
TIA
To reply, remove nospam from the address: djboyd@sam.on-net.net


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

Date: 18 Dec 1997 21:58:42 GMT
From: "Bruno Prior" <bruno@prior.ftech.co.uk>
Subject: Re: How do I create NDBM file from a flat file?
Message-Id: <01bd0c00$3e824520$0201a8c0@prior.ftech.co.uk>

Chris Lee <chrislee@med.unc.edu> wrote in article
<349941C7.E397C1C@med.unc.edu>...
> Howdy All,
> 
> I'm running into problems in creating a NDBM file from a flat file
>
> (snipped)
>
> for (@foo) { $bar .= $_;}

That should be a "foreach", not a "for". Same applies to the following
occurence.

> for (@entries) {
>    local($key, $val) = split(/-=-/);
>    $foo{$key} = $val;
> }
> $filename = "students99";
> use Fcntl;
> use AnyDBM_File;
> tie (%db, "NDBM_File", $filename, O_RDWR|O_CREAT, 0664);
> $db{$foo{'key'}} = $foo{'val'};

You are assigning one spurious key/value pair to %db. Why create %foo? Why
not just assign to %db?
i.e.

tie (%db, "NDBM_File", $filename, O_RDWR|O_CREAT, 0664);
foreach (@entries) {
    ($key, $val) = split(/-=-/);
    $db{$key} = $val;
}


Cheers,

Bruno Prior			bruno@prior.ftech.co.uk


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

Date: Thu, 18 Dec 1997 14:12:00 -0800
From: Allen Choy <achoy@us.oracle.com>
Subject: Re: How to load an assoc. array
Message-Id: <34999FAF.2FAF09D2@us.oracle.com>




> >change this:
> >
> >  %assocarry = ( $userid, $org,);
> >
> >to this:
> >
> >  $assocarry{'$userid'} = $org;

I think there's a typo here; there shouldn't be single quotes around $userid.

--allen



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

Date: Thu, 18 Dec 1997 15:14:28 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: JOKE (was Teaching programing)
Message-Id: <kn3c76.6u2.ln@localhost>

Anthony David (adavid@netinfo.com.au) wrote:


: Janos Blazi wrote:

: > I have to teach programing to 15-years old pupils. Is PERL a good language
: > to start with? Our "authorities" seem to prefer PASCAL, but PASCAL seems to
: > be absolutely dead and the first steps in PERL are perhaps easier than the
: > first steps in C. Or should I take BASIC (oh horror!)?
: >

: The following points are dug up (and filtered through time and flights of
: hubris) frommy first steps in programming:-


Sorry, the attributions for the below were lost somewhere on its
way to me. Seems applicable to this thread though...


-----------------------------------------------------------
Task is to write a program that prints "Hello World" on the
screen...make sure you see the last few attempts (Dilbert).

High School/Jr.High
==================

10 PRINT "HELLO WORLD"
20 END

First year in College
====================
program Hello(input, output)
begin
writeln('Hello World')
end.

Senior year in College
=====================
(defun hello
(print
(cons 'Hello (list 'World))))

New professional
===============
#include <stdio.h>

void main(void)
{
char *message[] = {"Hello ", "World"};
int i;

for(i = 0; i < 2; ++i)
printf("%s", message[i]);
printf("\n");
}

Seasoned professional
====================
#include <iostream.h>
#include <string.h>

class string
{
private:
int size;
char *ptr;

public:
string() : size(0), ptr(new char('\0')) {}

string(const string &s) : size(s.size)
{
ptr = new char[size + 1];
strcpy(ptr, s.ptr);
}

~string()
{
delete [] ptr;
}

friend ostream &operator <<(ostream &, const string &);

string &operator=(const char *);
};

ostream &operator<<(ostream &stream, const string &s)
{
return(stream << s.ptr);
}

string &string::operator=(const char *chrs)
{
if (this != &chrs)
{
delete [] ptr;
size = strlen(chrs);
ptr = new char[size + 1];
strcpy(ptr, chrs);
}
return(*this);
}

int main()
{
string str;

str = "Hello World";
cout << str << endl;

return(0);
}

Master Programmer :-))
================
[
uuid(2573F8F4-CFEE-101A-9A9F-00AA00342820)
]

library LHello
{
// bring in the master library
importlib("actimp.tlb");
importlib("actexp.tlb");

// bring in my interfaces
#include "pshlo.idl"

[
uuid(2573F8F5-CFEE-101A-9A9F-00AA00342820)
]
cotype THello
{
interface IHello;
interface IPersistFile;
};
};

[
exe,
uuid(2573F890-CFEE-101A-9A9F-00AA00342820)
]
module CHelloLib
{
// some code related header files
importheader(<windows.h>);
importheader(<ole2.h> );
importheader(<except.hxx>);
importheader("pshlo.h");
importheader("shlo.hxx");
importheader("mycls.hxx");

// needed typelibs
importlib("actimp.tlb");
importlib("actexp.tlb");
importlib("thlo.tlb");

[
uuid(2573F891-CFEE-101A-9A9F-00AA00342820),
aggregatable
]
coclass CHello
{
cotype THello;
};
};

#include "ipfix.hxx"

extern HANDLE hEvent;

class CHello : public CHelloBase
{
public:
IPFIX(CLSID_CHello);

CHello(IUnknown *pUnk);
~CHello();

HRESULT __stdcall PrintSz(LPWSTR pwszString);

private:
static int cObjRef;
};

#include <windows.h>
#include <ole2.h>
#include <stdio.h>
#include <stdlib.h>
#include "thlo.h"
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

int CHello::cObjRef = 0;

CHello::CHello(IUnknown *pUnk) : CHelloBase(pUnk)
{
cObjRef++;
return;
}

HRESULT __stdcall CHello::PrintSz(LPWSTR pwszString)
{
printf("%ws\n", pwszString);
return(ResultFromScode(S_OK));
}

CHello::~CHello(void)
{
// when the object count goes to zero, stop the server
cObjRef--;
if( cObjRef == 0 )
PulseEvent(hEvent);

return;
}

#include <windows.h>
#include <ole2.h>
#include "pshlo.h"
#include "shlo.hxx"
#include "mycls.hxx"

HANDLE hEvent;

int _cdecl main( int argc, char * argv[])
{
ULONG ulRef;
DWORD dwRegistration;
CHelloCF *pCF = new CHelloCF();

hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

// Initialize the OLE libraries
CoInitializeEx(NULL, COINIT_MULTITHREADED);
CoRegisterClassObject(CLSID_CHello, pCF, CLSCTX_LOCAL_SERVER,
REGCLS_MULTIPLEUSE, &dwRegistration);

// wait on an event to stop
WaitForSingleObject(hEvent, INFINITE);

// revoke and release the class object
CoRevokeClassObject(dwRegistration);
ulRef = pCF-Release();

// Tell OLE we are going away.
CoUninitialize();

return(0);
}

extern CLSID CLSID_CHello;
extern UUID LIBID_CHelloLib;

CLSID CLSID_CHello = { /* 2573F891-CFEE-101A-9A9F-00AA00342820 */
0x2573F891,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

UUID LIBID_CHelloLib = { /* 2573F890-CFEE-101A-9A9F-00AA00342820 */
0x2573F890,
0xCFEE,
0x101A,
{ 0x9A, 0x9F, 0x00, 0xAA, 0x00, 0x34, 0x28, 0x20 }
};

#include <windows.h>
#include <ole2.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "pshlo.h"
#include "shlo.hxx"
#include "clsid.h"

int _cdecl main( int argc, char * argv[])
{
HRESULT hRslt;
IHello *pHello;
ULONG ulCnt;
IMoniker * pmk;
WCHAR wcsT[_MAX_PATH];
WCHAR wcsPath[2 * _MAX_PATH];

// get object path
wcsPath[0] = '\0';
wcsT[0] = '\0';
if( argc 1) {
mbstowcs(wcsPath, argv[1], strlen(argv[1]) + 1);
wcsupr(wcsPath);
}
else {
fprintf(stderr, "Object path must be specified\n");
return(1);
}

// get print string
if(argc 2)
mbstowcs(wcsT, argv[2], strlen(argv[2]) + 1);
else
wcscpy(wcsT, L"Hello World");

printf("Linking to object %ws\n", wcsPath);
printf("Text String %ws\n", wcsT);

// Initialize the OLE libraries
hRslt = CoInitializeEx(NULL, COINIT_MULTITHREADED);
if(SUCCEEDED(hRslt)) {
hRslt = CreateFileMoniker(wcsPath, &pmk);
if(SUCCEEDED(hRslt)
hRslt = BindMoniker(pmk, 0, IID_IHello, (void **)&pHello);
if(SUCCEEDED(hRslt)) {
// print a string out
pHello- PrintSz(wcsT);

Sleep(2000);
ulCnt = pHello- Release();
}
else
printf("Failure to connect, status: %lx", hRslt);
// Tell OLE we are going away.
CoUninitialize();
}

return(0);
}

Apprentice Hacker
==================
#!/usr/local/bin/perl
$msg="Hello, world.\n";
if ($#ARGV = 0) {
while(defined($arg=shift(@ARGV))) {
$outfilename = $arg;
open(FILE, " " . $outfilename) || die "Can't write $arg: $!\n";
print (FILE $msg);
close(FILE) || die "Can't close $arg: $!\n";
}
} else {
print ($msg);
}
1;

Experienced Hacker
==================
#include <stdio.h>
#define S "Hello, World\n"
main(){exit(printf(S) == strlen(S) ? 0 : 1);}

Seasoned Hacker
==================
% cc -o a.out ~/src/misc/hw/hw.c
% a.out

Guru Hacker
==================
% cat
Hello, world.
^^D

New Manager
==================
10 PRINT "HELLO WORLD"
20 END

Middle Manager
==================
mail -s "Hello, world." bob@b12
Bob, could you please write me a program that prints "Hello,
world."?
I need it by tomorrow.
^^D

Senior Manager
==================
% zmail jim
I need a "Hello, world." program by this afternoon.

Chief Executive
==================
% letter
letter: Command not found.
% mail
To: ^^X ^^F ^^C
% help mail
help: Command not found.
% damn!
!: Event unrecognized
% logout



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


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

Date: 18 Dec 1997 17:27:47 -0500
From: "Cliff Heller" <fnord@panix.com>
Subject: Re: last modification date on files
Message-Id: <upbtyel21y.fsf@panix3.panix.com>

psullivan@stlnet.com (psullivan) writes:

> I am trying to find out the last time a file was modified on unix, and so I 
> figure that i'd just use the -M file tester built into perl. But this gives me 
> time in days since last modification, and so i was wondering how I can convert 
> this to a date field (mm/dd/yy), or if you know of another way to find 
> this out. Thanks.

stat



-- 
    / \      Left Reverend Nigh Invulnerable            fnord@panix.com
   /<0>\     Church of the Subverted Paradigm
  /     \                                               God Plays Dice!
 /_______\    --> FIVE TONS OF FLAX <--          Death To All Fanatics! 


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

Date: Thu, 18 Dec 1997 16:56:30 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: mysterious "Missing $ on loop variable" error
Message-Id: <-1812971656300001@aggie.coaps.fsu.edu>

In article <882480075.86704138@dejanews.com>, web@calarts.edu wrote:

+         foreach my $key ( keys %{$hashref} ) {

+ Can anyone tell me what I'm doing wrong?

Earlier versions of perl 5 (pre-v5.004, I think) seem to object to the
'my $variable' syntax in a foreach loop.

'perl -v' will tell you the version of your perl.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Thu, 18 Dec 1997 22:50:22 GMT
From: Clinton Bodine <Clinton.Bodine@mci.com>
Subject: Need help optiminzing reads
Message-Id: <3499A8A1.213F5F11@mci.com>

I routinely process multi-Gigibyte files containing several million
records per file.  Right now, I read in one record at a time, process
it, and go on to the next using :

while (read(FILE,$record,512)) {...} # Yes, a record is right around
512                                      #  bytes.

I want a speed increase and was thinking that maybe I should read in
1 MB of records at a time and process all of the records in memory.

My first thought was to trick read() into reading from memory (I don't
know how, if it is possible), then I thought about using unpack or
something like that.

If anyone has had experience with this kind of thing, please let me
know.  I'd like to use something that will automatically move through
the file (and memory) like read does so I can shove it into my while
loop.

Clinton


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

Date: Thu, 18 Dec 1997 16:53:33 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Netscape & MIME On Newsgroups
Message-Id: <-1812971653330001@aggie.coaps.fsu.edu>

In article <3499520E.59E2@bell-labs.com>, Stephan Vladimir Bugaj
<bugaj@bell-labs.com> wrote:

+ whatever)?  (Heh, how about Net::NNTP::StripMIMECrap)

Shouldn't be too hard, if they stick with "Content Type: whatever/multipart"

James - I used 'whatever' 'cause I can't remember if its text/multipart or
        not...

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Thu, 18 Dec 1997 15:03:04 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Newbie can't add the -w flag to perl to get useful warnings
Message-Id: <823c76.4s2.ln@localhost>

Dave Reed (daveSTOP*SPAMreed@webshowplace.com) wrote:
: I've been told to "add the -w flag to perl to get useful warnings."

: Not having the slightest idea how to do that, I turned to LEARNING PERL by
: Schwartz & Christiansen, only to be told to "turn on the -w option from
: the command line, which you should always do for safety's sake."

: How?  Type "perl -w" before the filename, like when using "perl -c"?


That will do it.

Most people just put it on the "shebang" line though (if their system
supports shebang lines):

#!/usr/bin/perl -w


: Help?


Seek help in the hundreds of pages of documentation that are shipped
with the perl distribution itself.

The 'perlrun' man page describes how to run perl (who'd a thunk it?   ;-)

It describes a bunch of slick command line switches (including -w)
that you can use to get things done.


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


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

Date: Thu, 18 Dec 1997 13:56:35 -0800
From: Curt Cranfield <curt@vphos.net>
Subject: Newbie Pattern Matching question
Message-Id: <34999C12.4E78@vphos.net>

Hi,

I am having trouble doing a certain pattern match.  What I am trying to
do is figure out how I can do a pattern match on '(xac)'.  For example
if the string was:

the dog (big) ran home

I want to get the pattern that is between the ().  Of course not knowing
before hand what the pattern between the () would be .. ie. it could be
anything between brackets.  I also don't want anything else from the
line.

Any help would be appreciated.

Thanks,

Curt


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

Date: Thu, 18 Dec 1997 16:13:21 -0700
From: "Mark S. Reibert" <reibert@mystech.com>
Subject: Re: Newbie Pattern Matching question
Message-Id: <3499AE11.291E29BB@mystech.com>

Curt Cranfield wrote:

> Hi,
>
> I am having trouble doing a certain pattern match.  What I am trying to
> do is figure out how I can do a pattern match on '(xac)'.  For example
> if the string was:
>
> the dog (big) ran home
>
> I want to get the pattern that is between the ().  Of course not knowing
> before hand what the pattern between the () would be .. ie. it could be
> anything between brackets.  I also don't want anything else from the
> line.

This should do it:

$line = "the dog (big) ran home";
$line =~ /\(([^)]*)/;
$line = $1;

At this point $line will have whatever was between the parenthesis.

HTH
-----------------------------
   Mark S. Reibert, Ph.D.

  Mystech Associates, Inc.
  3233 East Brookwood Court
   Phoenix, Arizona 85044

    Tel: (602) 732-3752
    Fax: (602) 706-5120
 E-mail: reibert@mystech.com
-----------------------------




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

Date: 18 Dec 1997 23:40:52 GMT
From: Eli the Bearded <#@qz.to>
Subject: Re: Newbie Pattern Matching question
Message-Id: <eli$9712181835@qz.little-neck.ny.us>
Keywords: sponsored by the letter M

Curt Cranfield  <curt@vphos.net> wrote:
> I am having trouble doing a certain pattern match.  What I am trying to
> do is figure out how I can do a pattern match on '(xac)'.  For example
> if the string was:

Well, m/.*/s will match most patterns.

> the dog (big) ran home
> 
> I want to get the pattern that is between the ().  Of course not knowing
> before hand what the pattern between the () would be .. ie. it could be
> anything between brackets.  I also don't want anything else from the
> line.

So you just want that stuff, huh? What have you tried? I'd probably use:

	/		# start search
	 \(		# open paren
	   (		# start capture
	    [^)]	# not a close paren
		*	# zero or more of the above
	   )		# end capture
	 \)		# close paren
	/;		# end search

Then the stuff in the parens will be in $1, if the match succeeded.

Elijah
------
nice symmetry in that one


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

Date: Thu, 18 Dec 1997 23:46:41 GMT
From: Clinton Bodine <Clinton.Bodine@mci.com>
Subject: Re: Newbie Pattern Matching question
Message-Id: <3499B5D3.59D03B5@mci.com>

Or how about??

$line = "the dog (big) ran home";
$line =~ /\((.*?)\)/;
$line = $1;


Mark S. Reibert wrote:
> 
> Curt Cranfield wrote:
> 
> > Hi,
> >
> > I am having trouble doing a certain pattern match.  What I am trying to
> > do is figure out how I can do a pattern match on '(xac)'.  For example
> > if the string was:
> >
> > the dog (big) ran home
> >
> > I want to get the pattern that is between the ().  Of course not knowing
> > before hand what the pattern between the () would be .. ie. it could be
> > anything between brackets.  I also don't want anything else from the
> > line.
> 
> This should do it:
> 
> $line = "the dog (big) ran home";
> $line =~ /\(([^)]*)/;
> $line = $1;
> 
> At this point $line will have whatever was between the parenthesis.
> 
> HTH


-- 
Clinton Bodine
Phone: (303) 390-6735
Vnet: 636-6735
Email: Clinton.Bodine@mci.com


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

Date: Thu, 18 Dec 1997 21:52:27 GMT
From: Gordon McDorman <gordon.leslie.mcdorman@sap-ag.de>
Subject: Re: perl for Win32 question
Message-Id: <upvmu1fqc.fsf@sap-ag.de>

>>>>> "KB" == SasEz! Publications and Design <sase@sasezdesyn.com> writes:

KB> My question is: If I use the perl for win32
KB> offline to compile and debug scripts, will they work on the Unix
KB> system also? 

My experience has been, that if one codes carefully, and avoids system
specific commands, that Perl scripts can be easily portable.

This means sticking with standard modules (CGI.pm, File::Find, etc),
avoiding backticks and similar shell commands, and being aware of
other system discrepancies (e.g., case sensitivity, file name
conventions).

-- 
-------------------------------------------------------------- 
The opinions expressed above are mine, not my employer's.
      
gordon.leslie.mcdorman@sap-ag.de                               


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

Date: 18 Dec 1997 16:56:26 -0500
From: Tom Fawcett <fawcett@SPAMLESS.nynexst.com>
Subject: Perl Journal, special Java issue
Message-Id: <8jyb1ib9it.fsf@SPAMLESS.nynexst.com>


Congratulations to whoever conceived and photographed the cover photo!
I laughed out loud.

Good to the last drop,
-Tom


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

Date: 18 Dec 97 23:40:36 GMT
From: alano@ncd.com (Alan Olsen)
Subject: Re: pgp encrypion via perl script
Message-Id: <3499b474.0@union>

In article <comdog-ya02408000R1212971449370001@news.panix.com>, 
comdog@computerdog.com says...

>instead, consider using IPC::Open3 and writing directly to standard input
>of the pgp program.  `/path/to/pgp -feat` will read from standard input
>rather than a file.  your data doesn't have to touch disk (although we're
>not considering paging, which is a different story).                  

Open3 tends to lock up on many (most) versions of PGP.  (At least all the ones 
I have tried under BSD.)  Two way piping and some programs do not mix.  Of 
course, piping the data to pgp and having the encrypted file show up in a temp 
file should work.

I have not tested the PGP 5.x code on Open3 though...



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

Date: Thu, 18 Dec 1997 15:28:42 -0800
From: "Eric T. Peterson" <petersoe@ucs.orst.edu>
Subject: Problem installing PERL 5.004_04 on Solaris 2.4.1 system
Message-Id: <3499B1AA.23A6A2EC@ucs.orst.edu>

Hello,

While running the 'make' for the latest releast (Perl 5.004_04) I crash
out with the following problem:

make: Warning: Both `makefile' and `Makefile' exist
cc   -o miniperl miniperlmain.o libperl.a
Undefined                       first referenced
 symbol                             in file
log                                 libperl.a(pp.o)
pow                                 libperl.a(pp.o)
sqrt                                libperl.a(pp.o)
floor                               libperl.a(pp.o)
atan2                               libperl.a(pp.o)
exp                                 libperl.a(pp.o)
sin                                 libperl.a(pp.o)
cos                                 libperl.a(pp.o)
ld: fatal: Symbol referencing errors. No output written to miniperl
*** Error code 1
make: Fatal error: Command failed for target `miniperl'

Can anyone suggest a solution?  I have both 'cc' and 'gcc' on the
system, but know very little about the compilers and associated
libraries.  

I am installing the latest release in order to use CGI.pm (we have
perl5.0 on the machine currently, and I get an Undefined subroutine
&main::WriteMakefile called at Makefile.PL line 4 error when I try and
install CGI.pm with this release...)

Any help will be most appreciated...

Eric T. Peterson
petersoe@ucs.orst.edu


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

Date: Thu, 18 Dec 1997 14:16:10 -0800
From: Allen Choy <achoy@us.oracle.com>
Subject: Proposed features in Perl5.005
Message-Id: <3499A0AA.88D279F2@us.oracle.com>

Does anyone know what's on the pipeline for 5.005?

Just wondering,

Allen



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

Date: Thu, 18 Dec 1997 17:15:21 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Source to count downloads on a file... help please
Message-Id: <comdog-ya02408000R1812971715210001@news.panix.com>

In article <01bd0bc7$39c1c6c0$2a5108d0@ralphk>, "Ralph Krausse" <ralphk@netpro.com> wrote:

>        I am looking for some perl source that will allow
>me to count the number of downloads from my site.

although Perl is overkill, you could:

[5]% perl -e '$x = shift; print `/bin/grep $x access_log | wc -l`' Meta
      47

 are there other requirements that might change the specification?

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Thu, 18 Dec 1997 23:57:33 +0100
From: Dirk Kassner <kassner@intershop.de>
Subject: Re: Substitute without exceeding a defined string length
Message-Id: <3499AA5D.2C73@intershop.de>

Honza Pazdziora wrote:
> 
> Dirk Kassner <kassner@intershop.de> writes:
> 
> > Salute
> >
> > I want to quote some sql wildcards in a string for a sql query:
> >
> >     my ($SqlParameter) = 'Roedel_Doedel%';
> >
> >     $SqlParameter =~ s/([_%\^\[\]])/[$1]/g;  # results in
> > 'Roedel[_]Doedel[%]'
> >
> > But the result of this substitution should not exceed a defined length,
> > that means, I want do all possible replacement and interrupt if the
> > length is reached
> > (to leave more wildcards unquoted):
> >
> >     1 while (length($SqlParameter) < $LENGTH and s/([_%\^\[\]])/[$1]/);
> >     # don't work but make clearer what I mean may be
> >     # (because the chars are still in the string and would be replaced
> > again and again)
> >
> > The resulting string than could look like: 'Roedel[_]Doedel%' if the
> > last wildcard
> > couldn't be substituted.
> 
> How about
> 
> my ($SqlParameter) = 'Roedel_Doedel%';
> $SqlParameter =~ s/([_%\^\[\]])/length $` > 8 ? $1 : "[$1]"/ge;
> print "$SqlParameter\n";
> __END__
> 
> Hope this is what you need,
> 
> --

Sorry, but this doesn't works for me (the string grows over the limit).
I tryed this (and this doesn't work too):

my ($SqlParameter) = 'Roedel_Doed_el';  # length = 14 (+ one replacement
= 16)
# should replace only the first '_' ??? :
$SqlParameter =~ s/([_%\^\[\]])/(length($`) + length($4) > 16 - 3) ? $&
: "[$&]"/ge;

print "$SqlParameter\n";
Roedel[_]Doed[_]el  (18 characters :-(

Any Ideas ?
Thanks.

Dirk


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

Date: Thu, 18 Dec 1997 08:22:25 -0600
From: Robert Melson <rmelson@pswtech.com>
Subject: Re: Teaching programing
Message-Id: <349931A1.6DE9@pswtech.com>

Jack H. Ostroff wrote:
> 
[---snip---]
>
[---snip---] 
<
> teaching.  The point is not teaching any particular language - it is
> teaching
> how to choose a language for a particular task, and how to best use
> whatever
> language is chosen, even if it is not the best.  Data structures and
> control
> structures are far more important than what type of brackets or whether
> the
> "if" goes before or after.  It is essential to understand what you are
> doing,
> and the various possible ways of doing it.
[---snip---]
> what s/he is really trying to do.  Perhaps you can even include a taste
> of several
> languages in the course, just to give a hint of what's in the real
> world.
> 
> Good luck, and do let us know what you finally decide.
> 
> Jack (jack_h_ostroff@groton.pfizer.com)

--
One of the most successful courses I took concentrated, as suggested
above, on algorithms and used an English-Pascal-like language to express
the design.  Any programs submitted could be in any language available
to the student ... would you believe a Pascal parser written in C-Basic?

Anyway, my point is that the comments above are most appropriate:  it's
not important what language is taught but, rather, that the content
emphasize data structures and algorithms and their importance in program
design. 
______________________________________________________________________
Bob Melson			The right to be heard does not include
PSW Technologies, Inc.		   the right to be taken seriously.
Austin, TX                      Hubert Humphrey
512-342-3511	rmelson@pswtech.com	bmelson@swbell.net


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

Date: Thu, 18 Dec 1997 15:50:17 -0500
From: "E. Brian Depenbrock" <ebd@sunline.net>
Subject: Whats wrong with this simple code?
Message-Id: <67c273$hp5@snews1.zippo.com>

The following code works, but it does not exit out to a prompt when it
reaches the end of file.
I have another script almost identical that does work.
Thanks:


$line = <>;
while ($line ne "") {
die("\n") if ($line eq "");
    $mls = substr($line,18,6);
    $line = <>;
    print("$mls");
    print("\n");
    $line = <>;
}





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

Date: Thu, 18 Dec 1997 17:39:20 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Whats wrong with this simple code?
Message-Id: <comdog-ya02408000R1812971739200001@news.panix.com>

In article <67c273$hp5@snews1.zippo.com>, "E. Brian Depenbrock" <ebd@sunline.net> wrote:

>The following code works, but it does not exit out to a prompt when it
>reaches the end of file.

>$line = <>;
>while ($line ne "") {
>die("\n") if ($line eq "");
>    $mls = substr($line,18,6);
>    $line = <>;
>    print("$mls");
>    print("\n");
>    $line = <>;
>}


perhaps you wanted something simple like:

   #!/usr/bin/perl

   while( $line = <> )
        {
        print $line;
        }

   __END__

-- 
brian d foy                                  <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)*  <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 1502
**************************************

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