[12414] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6014 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 16 10:07:18 1999

Date: Wed, 16 Jun 99 07:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 16 Jun 1999     Volume: 8 Number: 6014

Today's topics:
    Re: 'and' problem (Bart Lateur)
        @INC question <bbgraph@mail2.ee.net>
    Re: @INC question <gellyfish@gellyfish.com>
    Re: @INC question (Tad McClellan)
    Re: @INC question (Bart Lateur)
        binary file transfer on Win32 <rosso@uni-paderborn.de>
    Re: Can anyone explain this behavior? (Larry Rosler)
    Re: Can anyone explain this behavior? <simon@profero.com>
    Re: Errors attempting to use ftp.pl package <gellyfish@gellyfish.com>
    Re: FEAR FAD (Larry Rosler)
    Re: File Processing (Tad McClellan)
    Re: How to communicate with Serial port??? <gellyfish@gellyfish.com>
    Re: How to scan a directory and put all the files and t <dazimi@yahoo.com>
    Re: INI files: is there a ksh shell script to parse the (Marcel Grunauer)
    Re: Location (Bart Lateur)
        LWP (Jonathan Chum)
    Re: LWP <gellyfish@gellyfish.com>
    Re: LWP (Marcel Grunauer)
    Re: Multi line match help (Tad McClellan)
    Re: Multi line match help <gellyfish@gellyfish.com>
    Re: param($variable) <gellyfish@gellyfish.com>
    Re: Regex question (Larry Rosler)
        Searching for file types on a web site mmclaug@my-deja.com
    Re: Stopping the input...????? Me don't want buffer ove <gellyfish@gellyfish.com>
    Re: subroutines <frog@ateb.com>
        Surprise with .. operator in list context (Anno Siegel)
    Re: Unix carriage returns? (Bart Lateur)
    Re: Unix carriage returns? (Tad McClellan)
    Re: using strict... (Tad McClellan)
    Re: What is functional difference between .pm and .pl? (Bart Lateur)
    Re: What is functional difference between .pm and .pl? (Bart Lateur)
    Re: Win32 select() donath@my-deja.com
        Win32::NetAdmin <chirstius@mediaone.net>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 16 Jun 1999 11:53:20 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: 'and' problem
Message-Id: <37708f9e.14360690@news.skynet.be>

Steven Filipowicz wrote:

>I was wondering if there is a different way of writing this code
>something like :
>---------------------------------------
>if (length ($form_data{'name'}) == 0 )  and (length
>($form_data{'more_info'}) == 0 )
>   {
>   &error_html_query_form;
>   exit;
>   }

Yes. But fix your parentheses. There should be parentheses around the
WHOLE condition, even if it's a combined of other conditions, using
'and' (or '&&').

	if (length ($form_data{'name'}) == 0 and 
	    length($form_data{'more_info'}) == 0 ) { ... }

	Bart.


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

Date: Wed, 16 Jun 1999 08:40:38 -0400
From: "Bob Stickel" <bbgraph@mail2.ee.net>
Subject: @INC question
Message-Id: <7k86f1$av2$1@news2.ee.net>

I'm just getting started with Perl and I'm not sure what the @INC does.
Occasionally, a routine will fail with the @INC being referenced to not
found in c:\perl\lib, c:\perl\site\lib....

Just wondering what it is and what I should do to fix it when I get these
errors.

Thanks

Bob




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

Date: 16 Jun 1999 14:39:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: @INC question
Message-Id: <3767a905@newsread3.dircon.co.uk>

Bob Stickel <bbgraph@mail2.ee.net> wrote:
> I'm just getting started with Perl and I'm not sure what the @INC does.
> Occasionally, a routine will fail with the @INC being referenced to not
> found in c:\perl\lib, c:\perl\site\lib....
> 
> Just wondering what it is and what I should do to fix it when I get these
> errors.

You should look up the messsage in the perldiag manpage - this is available
at the command line via the perldoc utility or as HTML through the 
Active Perl link in your start menu.

/J\
-- 
"The teenage masturbators of today are the television executives of
tomorrow" - Melissa Cabriolet, Drop the Dead Donkey


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

Date: Wed, 16 Jun 1999 04:45:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: @INC question
Message-Id: <e7o7k7.v6g.ln@magna.metronet.com>

Bob Stickel (bbgraph@mail2.ee.net) wrote:

: I'm just getting started with Perl and I'm not sure what the @INC does.


   It tells perl where to look for files that you have "require"d
   or "use"d.


: Occasionally, a routine will fail with the @INC being referenced to not
: found in c:\perl\lib, c:\perl\site\lib....


   It is not @INC that is not being found. It is a file that you
   asked to be "pulled in", but perl cannot find the file in any
   of the dirs listed in @INC.


: Just wondering what it is and what I should do to fix it when I get these
: errors.


   use lib '/path/to/modules/dir';


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


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

Date: Wed, 16 Jun 1999 13:50:46 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: @INC question
Message-Id: <376aab4e.21448651@news.skynet.be>

Bob Stickel wrote:

>I'm just getting started with Perl and I'm not sure what the @INC does.

It's a list of directories that Perl searches when looking for library
files. It is comparable to the PATH environmental variable on DOS. See
"perldoc perlvar" (run on command line) or the file perlvar.pod /
perlvar.htm(l) for some more info.

>Just wondering what it is and what I should do to fix it when I get these
>errors.

It means that a paricular library file or module isn't found. The file
probably isn't on your system. If it is, but it still isn't found, you
may temporarily extend @INC in one of various ways, including the
possibility of using an environment variable PERL5LIB set to the root of
your library tree (see also perlrun(.pod|.html(l))). This means that to
be able to do

	use Some::Libfile;

You need to put a directory "Some" in that library root, which in turn
contains the file "Libfile.pm".


	Bart.


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

Date: Wed, 16 Jun 1999 15:49:44 +0200
From: Andreas Geesen <rosso@uni-paderborn.de>
Subject: binary file transfer on Win32
Message-Id: <Pine.GSO.4.10.9906161539001.14533-100000@aragorn>

Hi folks out there,

i'm using a PERL script to upload database changes to my webserver(s) and
for as long as these Servers were LINUX based no problems at all.
Now i have to update a Database running on a NT Server machine and my
common program fails to do the work. I already found the troublemaker but
i can't find a way around the odd CR/LF conversion.
I added the essential parts of the source with a little commenting of the
problem. Maybe someone of you knows how to handle it.
Please reply to this newsgroup and my email.

Snippets from my Program:
#!/usr/bin/perl -w
# Startup

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

### Some lines left out here

sub uploadUpdateFile {

	undef $fh;
	undef $Buffer;
	undef $BytesRead;

	$fh = $query->param('upload');

# Seems that $query->upload('upload'); won't work 
# though suggested to use in CGI.pm docs

	if (!open(OUTFILE, ">$SAVE_DIR\/$Filename")) {
		print "Content-type: text/plain\n\n";
		print "-------------------------\n";
		print "Error:\n";
		print "-------------------------\n";
		print "File: $Filename\n";
		print "-------------------------\n";
		print "There was an error opening the Output File\n";
		print "for Writing.\n\n";
		print "Make sure that the directory:\n";
		print "$SAVE_DIR\n";
		print "has been chmodded with the permissions '777'.\n\n";
		print "Error: $!\n";
		print $query->end_html ;
		exit;
	}

# Following commented part creates a zero byte file
#	open ( INFILE, "<$fh" );
#	binmode ( INFILE );
#	while ($Bytes = read(INFILE,$Buffer,1024)) {
#		$BytesRead += $Bytes;
#		print OUTFILE $Buffer;
#	}	
#	close ( INFILE );

# This part creates a corupted binary file (LF -> CR/LF substitution)
# even if i try to force $fh into binmode as you can see.

	binmode( $fh );
	while ($Bytes = read( $fh,$Buffer,1024)) {
		$BytesRead += $Bytes;
		print OUTFILE $Buffer;
	}

# Funny thing is: $BytesRead is the correct size of the source file
# but the transferred file is about 1300 bytes bigger than that.
# I even tried to binmode ($Buffer) but without luck.

	push(@Files_Written, "$SAVE_DIR\/$Filename");
	$TOTAL_BYTES += $BytesRead;
	$Confirmation{$fh} = $BytesRead;

        close($fh);
	close(OUTFILE);

        chmod (0766, "$SAVE_DIR\/$Filename");

	print <<__END_OF_HTML_CODE__;
	<BLOCKQUOTE>
	<FONT FACE="Arial, Helv, sans-serif">
	<p><B><FONT SIZE="+1">Upload fertiggestellt</FONT></B></p>
	<P><FONT SIZE="-1">Die Datei <B>$Filename</B> [$TOTAL_BYTES Bytes]
	wurde erfolgreich kopiert.</FONT></P>

__END_OF_HTML_CODE__

} # sub uploadUpdateFile

-------------------------------------------------------------------------------
     Andreas Geesen                             Uni/GH Paderborn
     rosso@uni-paderborn.de                     IRC: Titus (#Paderborn)
     http://titus.home.pages.de/                Phone/SMS: 0177 703 3683
     Key fingerprint = 65 4A 96 3E 21 FF FF 33  33 B2 96 AF 52 EE 7E C6
-------------------------------------------------------------------------------



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

Date: Wed, 16 Jun 1999 06:31:58 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Can anyone explain this behavior?
Message-Id: <MPG.11d1471dfba4bce8989bf1@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <3767556B.3763A5E0@nidlink.com> on Wed, 16 Jun 1999 00:42:36 
-0700, Bob Minnick <bobmin@nidlink.com> says...
> I've run across something interesting concerning split and am wondering
> if anyone can explain this behavior.
> 
> Consider the following;
> 
> ($var1, $var2)=split(/ /,$arrary[$index],2);
 ... 
>  I'd appreciate an email if someone can explain this.
>     Bob Minnick, Northern Webs

The other guys explained it, but they didn't give you the simplest 
solution -- change the 2 to 3.
 
> --
> Bob Minnick, President of Northern Webs
> Northern Webs, North Idaho's Web Design Studio/Presence Provider
> MEMBER OF THE INTERNET DEVELOPERS ASSOCIATION & IWA
> -------------------------------------------------------------------
> Our Homepage
> http://www.northernwebs.com/
> The Search Engine Tutorial
> http://www.northernwebs.com/set/
> Meta Medic, the oldest free online Meta Tag Validator on the net.
> (Over 4 Million urls tested)
> http://www.northernwebs.com/set/setsimjr.html

This .sig is three times longer than appropriate according to Usenet 
etiquette.  Also, put an invisible magic space character after the two 
hyphens, so the newsreaders won't include it in the responses.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 16 Jun 1999 14:57:01 +0100
From: Simon Wistow <simon@profero.com>
Subject: Re: Can anyone explain this behavior?
Message-Id: <3767AD2D.F5F38DB7@profero.com>




> The other guys explained it, but they didn't give you the simplest
> solution -- change the 2 to 3.

or even just



$line = 'Some Space       ';

($var1,$var2) = split (/ /,$line);

$var1 would be 'Some'
$var2 would be 'Space'

or

$line = 'Some Space and other things      ';
$line =~ s/[\s]*$//;

($var1,$var2) = split (/ /,$line,2);
$var1 would be 'Some'
$var2 would be 'Space and other things'




-- 

Simon Wistow                      Developement
simon@profero.com                  Profero Ltd
Phone:0171 700 9960        Fax:  0171 700 9961


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

Date: 16 Jun 1999 13:43:29 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Errors attempting to use ftp.pl package
Message-Id: <37679bf1@newsread3.dircon.co.uk>

In comp.lang.perl.misc TerryP <no-spam-texpilot@yahoo.com> wrote:
> 
> Running on a Sun E3500 with Solaris 2.6.  Downloaded Perl 5.005_2 package
> from Sunfreeware.com and (the Unix sa) installed using pkgadd.
> 
> But I cannot use the ftp.pl package.  The sa ran the h2ph script to generate
> the header files, but even still, we get the error:
> 

Does what it says in perlfaq8:

=head2 Why doesn't my sockets program work under System V (Solaris)? 
       What does the error message "Protocol not supported" mean?

describe your problem (I havent got a Solaris machine to play with at the
moment) ?

If you want to do FTP in a Perl program then you are probably better off
using the Module Net::FTP which is part of the libnet bundle available
from CPAN.  Most recent programs use the Socket module (part of the standard
distribution) which defines the various constants used by the networking
routines.

/J\
-- 
"What is the future for beef? Curtains?" - Graham Norton


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

Date: Wed, 16 Jun 1999 06:23:12 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: FEAR FAD
Message-Id: <MPG.11d14519e500526b989bf0@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <37677e63@newsread3.dircon.co.uk> on 16 Jun 1999 11:37:23 
+0100, Jonathan Stowe <gellyfish@gellyfish.com> says...

> /J\
> --
> "I sign my paintings Vincent because people can't pronounce Van Gough"
> - Vincent Van Gough

Evidently people can't spell it correctly, either.  Or is that part of 
the joke?

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 16 Jun 1999 03:50:47 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: File Processing
Message-Id: <n0l7k7.0kf.ln@magna.metronet.com>

ericho@sehk.com.hk wrote:
: In article <7k4qro$drq$1@nnrp1.deja.com>,
:   chumho@my-deja.com wrote:


: What puzzled me is the difference between

: local($r) = <f>;


   list context


: and
: local($r);
: $r = <f>;


   scalar context


: I'm pondering Bart's reply.


   See also the "Context" section in perldata.pod

   Understanding scalar vs. list context is important to
   using Perl effectively.


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


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

Date: 16 Jun 1999 14:24:44 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: How to communicate with Serial port???
Message-Id: <3767a59c@newsread3.dircon.co.uk>

Greg Bacon <gbacon@itsc.uah.edu> wrote:
> grep, grep, grep the FAQ
> to get your answers fast.
> When you have a decent OS
> isn't this a blast?

;-}

Actually the paucity of useable tools on a given platform is no longer
an excuse :

C:\Perl\lib\Pod>grep -i serial perlfaq*
perlfaq.pod:=item * How do I read and write the serial port?
perlfaq5.pod:are often buffered with a buffer size between 1/2 and 2k. 
perlfaq8.pod:=head2 How do I read and write the serial port?
perlfaq8.pod:the case of Unix, the serial ports will be accessible 

/J\
-- 
"Tony Blair is reported to be detained indefinitely under plans unveiled
by the Home Secretary" - Corrupt Teletext Page


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

Date: Wed, 16 Jun 1999 09:18:42 -0400
From: "Dariush_news" <dazimi@yahoo.com>
Subject: Re: How to scan a directory and put all the files and their size to a text file
Message-Id: <7k88c0$3s2$1@clio.net.metrotor.on.ca>

First of all Thank you all for the support.
This is what I have so far, which list all the files in the current
directory.
However I need to have the size of the files also, because I have to put the
file names with the coresponding size in to a spreadsheet.
Basically This program should monitor the directory for the files with thier
size. If a size of file is zero or less than 10K, then I like to be notifed.

So, please help if you can.

Thank you
# Auto1.pl

# This program will list all the files in the current directory.
# June 15/1999
# Teamlinux@hotmail.com
# Dariush_Azimi@mta1.metrodesk.metrotor.on.ca


opendir(CURDIR, ".")|| die("Can not open the directory");
@files=readdir(CURDIR);

@sorted_files=sort(@files);
print " the content of this directory is \n";

for $file(@sorted_files)
{
 print "$file\n";
}
closedir(CURDIR);

Greg Bacon <gbacon@itsc.uah.edu> wrote in message
news:<7k6d12$645$2@info2.uah.edu>...
> In article <7k6c2q$c1r$1@clio.net.metrotor.on.ca>,
>  "Dariush_news" <dazimi@yahoo.com> writes:
> : I need to scan a directory and input all the file namse in to a text
file
> : with thier respecitve size.
>
> Maybe it would help if you showed us what you've tried so far.
>
> Greg
> --
> Cop:     I can put you in Queens on the night of the hijacking.
> Hockney: Really?  I live in Queens.  Did you put that together yourself?




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

Date: Wed, 16 Jun 1999 12:55:47 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: INI files: is there a ksh shell script to parse them (like iniconf)?
Message-Id: <37689d3f.14288836@enews.newsguy.com>

On Wed, 16 Jun 1999 00:33:00 GMT, jonathan_wheelhouse@amp.com.au
wrote:

>Does anybody have a shell script (ksh, preferably) that reads ini or
>configuration files of the form:
>[section]
>Parameter=Value
>Parameter=<<EOT
>value/line 1
>value/line 2
>EOT
>
>The perl module, iniconf, is great for doing this; unfortunately I
>can't use it in this situation; I just need a ksh script that returns
>the value(s) given the section and parameter as input.

Why can't you use IniConf? You could write your own Perl program, but
if you can do that, you can also use IniConf. Or is the format of your
 .ini file non-standard?

But if you're looking for a ksh script, this isn't the place.

HTH

Marcel



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

Date: Wed, 16 Jun 1999 12:14:58 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Location
Message-Id: <3774949c.15637916@news.skynet.be>

Tim wrote:

>if ($page = "one") {
>GO RIGHT TO PAGE ONE
>}

You probably meant

	if (page eq "one") { ... }

just to bring this back on topic for a Perl newsgroup. :-)

Try the "Location: http://your.server.com/your/pageone.htm\n\n" header,
INSTEAD OF the content-type header.

But you may just as well spit out all the HTML in your script (preceded
by the content-type header).

	Bart.


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

Date: Wed, 16 Jun 1999 12:17:58 GMT
From: jchum@jps.net (Jonathan Chum)
Subject: LWP
Message-Id: <37679442.3373223@news.jps.net>

I am not exactly familiar with CGI programming. I just started to
learn developing full scripts now. Before, I just install scripts and
modified them. 

There a site, http://www.opensourceit.com/tutorials/990517perl.html,
that has tricks to get content from a site query. I downloaded the
source and tried installing them on the server. Still, it doesn't
work. Am I missing something? Does it require a get form on a html
page pointing directly to the script or what? Thanks for any help you
all can give me.


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

Date: 16 Jun 1999 14:09:45 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: LWP
Message-Id: <3767a219@newsread3.dircon.co.uk>

Jonathan Chum <jchum@jps.net> wrote:
> 
> There a site, http://www.opensourceit.com/tutorials/990517perl.html,
> that has tricks to get content from a site query. I downloaded the
> source and tried installing them on the server. Still, it doesn't
> work. Am I missing something? Does it require a get form on a html
> page pointing directly to the script or what? Thanks for any help you
> all can give me.

Er ... You do realize that these scripts are supposed to be run from
the command line ?  You also need to have the LWP::* modules installed.

If you want to use these examples in a CGI environment then you will
have to modify them to do the right thing, emit the correct headers and
so forth ...

/J\
-- 
"I managed to take her completely by surprise" - Prince Edward


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

Date: Wed, 16 Jun 1999 13:06:37 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: LWP
Message-Id: <3769a051.15074536@enews.newsguy.com>

On Wed, 16 Jun 1999 12:17:58 GMT, jchum@jps.net (Jonathan Chum) wrote:

>I am not exactly familiar with CGI programming. I just started to
>learn developing full scripts now. Before, I just install scripts and
>modified them. 
>
>There a site, http://www.opensourceit.com/tutorials/990517perl.html,
>that has tricks to get content from a site query. I downloaded the
>source and tried installing them on the server. Still, it doesn't
>work. Am I missing something? Does it require a get form on a html
>page pointing directly to the script or what? Thanks for any help you
>all can give me.

As far as I can see, this is the same (or related to the ) article
that appeared in The Perl Journal. The sample scripts there already
point you in the right direction, namely using LWP. But you also need
to understand what the programs do if you want to make them work for
you. Are the LWP modules on the server as well? What do you mean by
"it doesn't work"? How can we determine what's wrong if we don't know
what you did? Post some sample code of what you think is causing you
problems (but please keep it under 40 lines or so), along with other
relevant information, and we can see.

But to understand LWP you should read the documentation that comes
with the modules.

HTH

Marcel



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

Date: Wed, 16 Jun 1999 04:13:12 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Multi line match help
Message-Id: <oam7k7.0kf.ln@magna.metronet.com>

Narasimha G. Pai (pai@cadence.com) wrote:

: I have a file in the following format :

: 12:12:96 : Updated test1 . Writing test2.
: 01:10:97 : test2 done . Started test3.
:                 test4 PLANNED .

: Now I have to get the date for which test4 was planned .
: I suppose this requires a multiline match .

: so what I am doing is setting $/ to nothing . 


   Perl does not define "nothing".

   setting $/ to undef puts you in "slurp mode".

   setting $/ to the empty string puts you in "para mode".

   I dunno what setting $/ to nothing is...


: I read the entire file
: in $_ and then try to do a match .


   Oh. Sounds like you have set $/ to undef, not "nothing".


: I tried :

: if(/([0-9][0-9]).*PLANNED) /) and guess what it gave me :


   First it gave you a syntax error because the parenthesis
   don't match up.

   Then after fixing that, it matches only if there are
   2 digits and the word "PLANNED" on the *same* line.

   Then after fixing that, it matches only the "12" because
   your pattern only allows 2 digits in the parens.


: 12:12 in $1 .


   So I don't know where the hell that came from.

   The code you have is not the code we have.

   Try posting again, and this time post your real code
   (use cut/paste, don't try to type it in)


: Now what i need is 01:10.

: Any ideas on how I can reduce my search to the last possible
: match and not the first possible .


      print "$1\n" if( /.*(\d{2}:\d{2}):\d{2}.*PLANNED /s );


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


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

Date: 16 Jun 1999 14:29:49 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Multi line match help
Message-Id: <3767a6cd@newsread3.dircon.co.uk>

Tad McClellan <tadmc@metronet.com> wrote:
> Narasimha G. Pai (pai@cadence.com) wrote:
> 
> : I have a file in the following format :
> 
> : 12:12:96 : Updated test1 . Writing test2.
> : 01:10:97 : test2 done . Started test3.
> :                 test4 PLANNED .
> 
> : Now I have to get the date for which test4 was planned .
> : I suppose this requires a multiline match .
> 
> : so what I am doing is setting $/ to nothing . 
> 
> 
>    Perl does not define "nothing".
> 
>    setting $/ to undef puts you in "slurp mode".
> 
>    setting $/ to the empty string puts you in "para mode".
> 
>    I dunno what setting $/ to nothing is...
> 

$/ = 'nothing';
$file = <FILE>;

That'll slurp the whole file (as long as it doesnt contain nothing :)

/J\
-- 
"What is the future for beef? Curtains?" - Graham Norton


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

Date: 16 Jun 1999 13:08:46 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: param($variable)
Message-Id: <376793ce@newsread3.dircon.co.uk>

James Stewart <james@britlinks.co.uk> wrote:
> Hi,
> 
> I'm trying to read a list of fields from a form using CGI.pm. The fields
> are named
> 
> NDD1, NDD2 ... NDD10 etc. and I want to make it easy to develop my code
> as the page grows.
> 


You might consider using soething like the following to get at all of
your NDD parameters :

foreach (grep /^NDD/,param())
{
  push @NWONE,param($_);
} 

/J\
-- 
"Of course I smoke pot, but I'm not in favour of legalizing it. The
working classes do little enough as it is..." - Jonathan Aitken


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

Date: Wed, 16 Jun 1999 06:04:34 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Regex question
Message-Id: <MPG.11d140a6edb19584989bef@nntp.hpl.hp.com>

In article <7k7irk$n7l$1@plonk.apk.net> on Wed, 16 Jun 1999 03:43:57 -
0400, Jody Fedor <JFedor@datacom-css.com> says...
> 
> Larry Rosler wrote in message ...
> 
> >I wouldn't even bother with a regex.
> >
> >substr($date, 10, 9) = ',';
> >
> I think Larry wins for simplicity on this one.  I didn't know that $date
> would be a constant length until I checked it.  I thought that when it was
> the 1st through 9th that there would be 1 less character in $date and I
> wouldn't be able to have such an elegant and simple fix.
> 
> Thanks Larry....  your simplicity is dazzling!  :-)

<blush>  Aw, shucks!  Me and Forrest Gump.  <blush>


This constant-width behavior is documented in the ANSI/ISO C Standard, 
but not in the Perl localtime function except by reference to ctime(3).  
The following is an online excerpt, not guaranteed because the Standard 
itself isn't online.


"Ctime converts a long integer, pointed to by clock, representing the 
time in seconds since 00:00:00 UTC, January 1, 1970, and returns a 
pointer to a 26-character string of the form 

    Thu Nov 24 18:22:48 1986\n\0

All the fields have constant width. ..."


Perl wisely dispenses with the last two characters, so the result of

    perl -e "print length localtime"

is always 24.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 16 Jun 1999 11:35:12 GMT
From: mmclaug@my-deja.com
Subject: Searching for file types on a web site
Message-Id: <7k825g$htl$1@nnrp1.deja.com>

I want to write a Perl script that does the following:

* Visits a web site and tracks down all the files with a given extension
(say, .pdf)
* Writes the file name and path name to a file, so I will have:

test1.pdf http://www.abc.com/test1.pdf
test2.pdf http://www.abc.com/docs/test2.pdf  etc...

I have been trying out get($URL)

can I do get(*.pdf) or something?

Any pointers to sample code welcomed. I am of beginning/intermediate
standard in Perl, using Redhat5.2.

Thanks
Michael


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 16 Jun 1999 13:29:26 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Stopping the input...????? Me don't want buffer overflow...
Message-Id: <376798a6@newsread3.dircon.co.uk>

Mitch <portboy@home.com> wrote:
> 
> Well, the problem is that the user can type for forever.  NOT A GOOD
> THING!!!  So, my question is, how can I setup a bounds of say 20
> characters where the cursor stops and no longer takes anymore input?
> 

You might try out the Module Term::ReadKey that will enable you to get
one keystroke at a time and thus count the input - you will however
have to handle all of the backspace,delete and whatever other keys
the user might press yourself.

/J\
-- 
"How much fun can a girl have with a rabbit?" - Channel 4 Continuity
Announcer


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

Date: Wed, 16 Jun 1999 09:49:05 -0400
From: Emily Latham <frog@ateb.com>
Subject: Re: subroutines
Message-Id: <3767AB51.A293F45A@ateb.com>

Sorry, I missed these replies.  I apologize for not including code
pieces, the segment was just very big.  I figured out that I should have
used system() instead of exec() because it automatically exited.

Hasanuddin Tamir wrote:
> 
> On Sun, 06 Jun 1999 13:07:57 -0400,
> Emily Brock Latham <eblatham@unity.ncsu.edu> wrote:
> >
> > Whenever I call a subroutine based on a menu selection, after the
> > subroutine is called, my program exits.  What am I doing wrong?
> 
> Nothing, err...., maybe until you post some piece of your code.
> 
> -hasan-
> uhm, no more sig(h)


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

Date: 16 Jun 1999 13:36:40 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Surprise with .. operator in list context
Message-Id: <7k8998$8te$1@lublin.zrz.tu-berlin.de>

Why does 

( chr( 0) .. chr( 26) )

produce a list of length 1, only containing chr( 0)?  Probably the
++ operator is a work behind the scenes, which doesn't work for
non-alphanumerics.  Would someone know for sure?

Anno

-- 
$_ = lc 'Trojan slut? Heck, rape her!'; tr/ .,;:'"?!()//d;
print +( ' ', sort split '')
[9,21,18,19,0,1,12,13,20,7,4,15,0,14,5,16,11,0,8,2,3,10,6,17], "\n";



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

Date: Wed, 16 Jun 1999 12:11:39 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Unix carriage returns?
Message-Id: <3773940d.15495221@news.skynet.be>

David Bown wrote:

>Do perl scripts need unix carriage returns to function properly.

You mean "linefeeds"? On Unix, yes. But the basic rule is: you need the
file to be in native text file format. On a Mac, you need only CR's, on
PC, either Unix (only LF) or PC (CR+LF) may work. It does on DJGPP DOS
Perl.

	Bart.


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

Date: Wed, 16 Jun 1999 04:03:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Unix carriage returns?
Message-Id: <gol7k7.0kf.ln@magna.metronet.com>

David Bown (nospam-dbown@sequent.com) wrote:

: Do perl scripts need unix carriage returns to function properly.
                            ^^^^^^^^^^^^^^^^
   (I assume you really meant "line ending sequence" there)


   Sometimes (or usually) if on Unix.

   If not on Unix, then not.

   :-)


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


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

Date: Wed, 16 Jun 1999 03:59:19 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: using strict...
Message-Id: <ngl7k7.0kf.ln@magna.metronet.com>

joeyandsherry@mindspring.com wrote:

: So, here I go...I just read a newspost recommending the use of strict, so I
: go to one of my properly running scripts and insert:

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

: When I call my script I get an Internal Server Error,so I ventured to a
: utlilty that my virtual host provides, to check for common errors in perl
: scripts. This is what I get:

: TEST 4: perl syntax
:    Can't locate strict.pm in @INC (@INC contains:
: /usr/lib/perl5/i686-linux/5.00404 /usr/lib/perl5
: /usr/lib/perl5/site_perl/i686-linux /usr/lib/perl5/site_perl .) at
: feature.pl line 2.
:    BEGIN failed--compilation aborted at feature.pl line 2.

: So, do I just find this module on the net and upload it to the appropriate
: directory, chmod it and try it again?


   strict.pm is part of a standard perl installation.

   Your ISP's perl is not configured correctly.

   Send them email every 30 minutes (get all of your friends to do
   so also) until it is fixed.


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


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

Date: Wed, 16 Jun 1999 11:56:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: What is functional difference between .pm and .pl?
Message-Id: <37719065.14559793@news.skynet.be>

Neil wrote:

> I understand that
>foo.pm is a "perl module" but what distinguishes this from
>a "perl script"?

It's "required" before the rest of the script is run, and

It MAY contain a sub import(), which is run too, just after the file is
required.

What I don't understand, is why "import" is in lower case. Probably old
age, but as far I I understand, any user code that is automatically
invoked by perl should be all uppercase. That's the convention, anyway.

	Bart.


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

Date: Wed, 16 Jun 1999 11:58:56 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: What is functional difference between .pm and .pl?
Message-Id: <37729134.14765927@news.skynet.be>

Abigail wrote:

>I use .pl because that makes my editor jump into the appropriate mode. :)

Give us back our own Abigail! ;-)

You did write, some while ago, that you "refused to program a christmas
tree" (my paraphrase), didn't you?

	Bart.


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

Date: Wed, 16 Jun 1999 12:40:37 GMT
From: donath@my-deja.com
Subject: Re: Win32 select()
Message-Id: <7k8603$j2s$1@nnrp1.deja.com>

Indeed, ^Z does terminate STDIN.  I had tried every Ctrl-character but
nothing worked.  I never assumed a carriage return was needed after the
^Z to actually terminate.  ^D is the term. char in Unix, and doesn't
require CR.  Thank you very much.

I still would like to know if there's a way to tell if there's any data
waiting on an input handle.  That is, to know if there is data waiting
to be read without actually reading the input.

For example, if I write this in a Perl script:

@lst = <STDIN>

The script will hang until the user enters data and closes the stream
with ^Z.  I'd like a way to determine IF there is any data waiting on
STDIN, and if there isn't, to continue the script without hanging
there.  In Unix Perl, select() is the function you use, but it DOESN'T
work in Win32.

Thank you,
Clarence Donath
mrdo@mrdo.com


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Wed, 16 Jun 1999 08:21:06 -0500
From: "Chuck Hirstius" <chirstius@mediaone.net>
Subject: Win32::NetAdmin
Message-Id: <uwN93.8411$s%1.19341271@rmnws01.ce.mediaone.net>

I know WinNT is the lessor OS around here, but maybe someone can offer some
help.  I work in a mixed OS environment with users who are idiots and can't
remember more than one password.  So my latest project has me looking for a
way to allow a user to update their password on an NT Workstation, and have
it do a mass update of passwords for them across the environment(even after
informing them how VERY VERY secure this is...<sigh>).  I'm using a Tk front
end, and so far updating their password on the Unix servers was the easy
part, the hard part has been adding error checking, password validation, and
updating the password locally on the NT Workstation.  I am using the
Win32::NetAdmin module for a few of these things.

First I use UsersExist()  to make sure the username typed in is valid on
that workstation, which works fine.  The problem is with
UserGetAttributes(), I am using it as follows:

use Win32::NetAdmin;
Win32::NetAdmin::UserGetAttributes("", $UserID(this is where the user name
entered in from Tk is stored), $password, $passwordage, $priv, $homedir,
$comment, $flags, $scriptpath) ;

What I want is to verify the "Old" password typed in matches the current
password before I let them update it with a new password (novel idea, I
know)  The problem is that when I print $password, it is blank, in fact
every variable is blank.  This follows with the example from the gecko book
on page 176 or 167, the books at work : ( but trying that example turned out
no better.  The docs just give the function names and a breif description of
what they do, but no examples, has anyone used NetAdmin that can tell me
what I'm doing wrong?  Can you get ANY users attributes with this?  As
that's how I'll need it to work.  Regardless of who is logged in any user
should be able to walk up, fire off the password script and update THEIR
passwords.  Is that impossible?  Is there a substitue module that will do
what I need?  I'll also be using UserSetAttributes()  to change the
password, are there the same gotcha's with that?

I'm perfectly aware that I'm an idiot as well, and feel free to tell me so,
just include an answer to my question with the insult, so that next time I
will be LESS of an idiot.  : )

Thanks,

Chuck




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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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