[6904] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 529 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 27 23:07:11 1997

Date: Tue, 27 May 97 20:00:26 -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           Tue, 27 May 1997     Volume: 8 Number: 529

Today's topics:
     /x <kshaw@plight.lbin.com>
     Re: ?my($foo)=shift;? (Tushar Samant)
     CGI/WWW & Perl Tutorials (John Donnelly)
     Creating One Image from Two With GD dirk@icon.co.za
     Error checking with name strings <mjlewis@cybersource.com>
     extract character from string array and use as integer (David Dougal)
     extracting columns <vijay.telang@citicorp.com>
     ld problems (./so_locations) while building perl-5.004  (Erez Zadok)
     LWP: can't find DESTROY.al? <chris@ixlabs.com>
     Re: Magical Auto-increment operator <robp@electriciti.com>
     Re: Magical Auto-increment operator <rootbeer@teleport.com>
     MS-DOS port of the Perl programming language (*sdfasdf@jumbo.com
     nslookup's in perl (JPR)
     Re: nslookup's in perl (I R A Aggie)
     Password Protection - NT <editor@primenet.com>
     Re: Perl Packages (Mike Stok)
     Re: Perl Packages <billc@tibinc.com>
     Re: perl5.003_93/BSDI 3.0 with dynamic loading <khera@kciLink.com>
     Re: Problem with <> fawcett.nospam@nynexst.com
     Re: Problem with <> (Jahwan Kim)
     Process Information (Brent Johnson)
     Re: Reading binary files: OK under DEC UNIX, error unde <wm_n00@tarrcity.demon.co.uk>
     Re: regexp solver <rootbeer@teleport.com>
     Re: script optimization of grep -c (Eric Finley)
     Re: Search Pattern Help???? (Tad McClellan)
     Solaris and sockets <randall@grcmc.org>
     tcp socket chase <rferr@voicenet.com>
     Re: types (Tung-chiang Yang)
     using getopt or getopts function (SPrashant)
     Using hash, appending and dbm (Justin B. Harvey)
     Re: Using TAB key position fill-in forms/items (Gerben Vos)
     Re: yet another perl regex Q <vladimir@cs.ualberta.ca>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 27 May 1997 16:22:53 -0700
From: kendall shaw <kshaw@plight.lbin.com>
Subject: /x
Message-Id: <529110ijoy.fsf@plight.lbin.com>

Extended regexps in my perl 5.004 don't seem to woark:

I'm getting results that I don't expect:

This:

$asdf = '<PARA CONTINUE="1" LINE-SPACING="11" PARATYPE="07Body text"  >';

$_ = $asdf;

s/PARA\ CONTINUE=...\ .*?PARATYPE=(\".*?\")\ */
	PARA\ CONTINUE=\"1\"\ PARATYPE=$1/x;
print $_ unless /PARATYPE FONT-FAMILY/;

produces:

<
	PARA CONTINUE="1" PARATYPE="07Body text">

But if I remove the newline and space from the right hand side
(pretend "\ PARATYPE" is joined with the previous line") :

s/PARA\ CONTINUE=...\ .*?PARATYPE=(\".*?\")\ */PARA\ CONTINUE=\"1\"
\ PARATYPE=$1/x;

I get what I want:

<PARA CONTINUE="1" PARATYPE="07Body text">

Is this a bug?


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

Date: 27 May 1997 17:02:53 -0500
From: scribble@shoga.wwa.com (Tushar Samant)
Subject: Re: ?my($foo)=shift;?
Message-Id: <5mflmd$qfi@shoga.wwa.com>

alex  <alex.t.silverstein@bender.com> wrote:
>in perlref I get the following,
>but I can't figure out what the "my $x = shift"
>lines are doing. I know what shift() and my() do. But
>I get the feeling this is s'thing else going on here.
>Many Thanks.
>
>example:
>             sub newprint {
>                 my $x = shift;   #huh?
>                 return sub { my $y = shift; print "$x, $y!\n"; };
>             }
>             $h = newprint("Howdy");
>             $g = newprint("Greetings");

shift is doing exactly what you think it is. newprint is taking an
argument and returning a code reference based on it. $h and $g hold
code references, that's all; there is no need at this stage to know
the actual code they are referring to.

Now if you want to know what they are--they are substantially the
same, but they differ a little.

	$h holds a subroutine whose body is:
	{ my $y = shift; print "Howdy, $y!\n"; }

	$g holds a subroutine whose body is:
	{ my $y = shift; print "Greetings, $y!\n"; }

I.e. the "$x" part got replaced by "Howdy" in one case and "Greetings"
in another. That's because $x was a "my" in the outside block. Perl
will do such a replacement for all that was "my" in an outside block--
this is called making a "closure". Why did it replace $x with "Howdy"
in the first case? Because that was the first argument to newprint.

Basically there is nothing called $x outside of newprint that has
anything to do with the one inside. In fact, in a sense even newprint
doesn't know anything called $x. In short, "my $x = shift;" roughly
means: there might be "holes" in sub{} constructs in this block,
if so they are marked as "$x", and they are to be filled with the 
piece of data given to you by shift.

A few more details and you have the complete story.



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

Date: 27 May 1997 14:55:11 -0600
From: johnd@xor.com (John Donnelly)
Subject: CGI/WWW & Perl Tutorials
Message-Id: <5mfhnf$6qh@xor.com>

	**Upcoming Perl (June '97) Tutorials**
All sessions are held at our training facility in Boulder, CO.
Contact me for further information, registration forms.
--John Donnelly, Training Coordinator
  XOR Network Engineering, Inc.
  http://www.xor.com/  johnd@xor.com  303-448-4816
				*****
                   CGI and WWW Programming in Perl
                   (Two Day Hands-on Lecture/Lab)
                    Tom Christiansen, Consultant
			 June 17-18, 1997
				*****
                     Advanced Perl Programming
                  (Three Day Hands-on Lecture/Lab)
                    Tom Christiansen, Consultant
		Monday - Wednesday, June 23-25, 1997
				*****


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

Date: Tue, 27 May 1997 21:57:03 GMT
From: dirk@icon.co.za
Subject: Creating One Image from Two With GD
Message-Id: <338b5881.587243@news.icon.co.za>

I'm trying to create a "banner" type application in which I randomly 
select images and combine to form one output images to a web browser.

(It's a lost children application and displayes a picture of the child

and a logo at the bottom).

The problem is that the second image seems to use the colour pallete
from 
the first (I think). ie the second images has weird looking colours
and I 
think it's based on the first image pallete.  Is there a way to reset
the 
pallete in between loading the images ?  If anyone else has done this
I 
would really appreciate some help.

Here's my program so far, still in development so may not be the
neatest 
code yet :-)

use GD;
use CGI;
$cgi = new CGI;

MAIN:
{
	print $cgi->header('image/gif');

	# create Main Image File
	$main = new GD::Image(500,500);
	
	# define colours
	$white = $main->colorAllocate(255,255,255);
	$black = $main->colorAllocate(0,0,0); #background color

	&CreateFace;
	&BuildFooter;
	&BuildImage;

	$main->GD::Image::interlaced;	
	print $main->gif;
}

sub CreateFace
{
	# create face image area
	open(FACE,"/usr/local/Data/Community/ChildLink/pic2.gif") || 
die;	
	$face = newFromGif GD::Image(FACE) || die;
	close(FACE);
}

sub BuildFooter
{
	# create footer image area
	open(FOOTER,"/usr/local/Data/Community/ChildLink/bcs.gif") || 
die;	
	$footer = newFromGif GD::Image(FOOTER) || die;
	close(FOOTER);
}
	
sub BuildImage
{		
	@dim = $footer->GD::Image::getBounds;
	$footer->GD::Image::interlaced;
	$main->copy($footer,0,150,0,0,$dim[0],$dim[1]);
	@dim = $face->GD::Image::getBounds;
$main->copyResized($face,0,0,0,0,,$dim[0],$dim[1],,$dim[0],$dim[1]);	
}


Dirk
drheeder@bcs.co.za


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

Date: Tue, 27 May 1997 15:27:01 -0700
From: Michael Lewis <mjlewis@cybersource.com>
Subject: Error checking with name strings
Message-Id: <338B5FB4.1FB00911@cybersource.com>

So I have four strings:

$foo = "Smithington";
$bar = "Smitington";
$baz = "Smithingfton";
$bip = "Smihtington";

What's a good way to determine that each of
the last three string segments are very similar
to the first (within the realm of human bad
typing)?

Speed is important in this case.  Will doing
string comparisons removing one letter at a
time be good enough to find the first two
errors?  Will comparing two-letter strings
be fast enough for the last error?

- Mike



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

Date: 27 May 1997 23:11:25 GMT
From: ddougal@concentric.net (David Dougal)
Subject: extract character from string array and use as integer
Message-Id: <5mfpmt$pch$1@news8.gte.net>

 
@array = ("w0123456789","l0123456787","w0134265879", "t0123456789",
          "w0123456789", "w0123456789");   

How can I extract the third character from one of the string elements and then 
use the character as an integer?



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

Date: Wed, 28 May 1997 10:37:25 +1000
From: Vijay Telang <vijay.telang@citicorp.com>
Subject: extracting columns
Message-Id: <338B7E45.59C8@citicorp.com>

Hi all

Can someone give me some idea about how to cut/change  a column from a
ascii file. I extarct an ASCII file from one of my systems and need to
change dat in specific columns, such as a date field etc.

In shell script I would be using cut to do the job. SO what would be
equevelent to cut.

Thanks in advance

Aswinee

-- 
---------*---------*---------*---------*---------*---------*---------
     vijay.telang@citicorp.com           Do not wish to be anything
     UNIX Systems Manager                but what you are , and try
     Citibank, Sydney, Australia         to   be   that   perfectly
---------*---------*---------*---------*---------*---------*---------


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

Date: 27 May 1997 18:00:31 -0400
From: ezk@news.cs.columbia.edu (Erez Zadok)
Subject: ld problems (./so_locations) while building perl-5.004 on Irix-6.2
Message-Id: <199705272200.SAA08853@shekel.mcl.cs.columbia.edu>


I'm getting linker errors when trying to build perl-5.004 on Irix 6.2.  I
used all of the default options offered by perl's Configure script.  My
$PATH has /usr/bin before /usr/lib (so I get those versions of cc/ld/etc).
The same failures happen when I tried old_ld or uld instead of ld.

This happened to me with 5.003 also, and I assumed then it must have been a
perl build problem, so I waited until 5.004.  Well this more and more
appears to be an Irix 6.2 problem.

Does anyone know how to avoid these problems?  Below is a snippet of the
failure output I get while building perl.

cc -c  -32 -D_BSD_TYPES -D_BSD_TIME -Olimit 3100 -I/usr/local/include
-DLANGUAGE_C -O    -DVERSION=\"1.03\" -DXS_VERSION=\"1.03\" -KPIC -I../..
Fcntl.c
Running Mkbootstrap for Fcntl ()
chmod 644 Fcntl.bs
LD_RUN_PATH="" ld -o ../../lib/auto/Fcntl/Fcntl.none  -shared
-L/usr/local/lib Fcntl.o     
ld: ERROR 48: Cannot access registry file ./so_locations (No locks
available) - ignored.
ld: FATAL 51: Can't assign virtual addresses for
 ../../lib/auto/Fcntl/Fcntl.none within specified range.  Please check your
registry file ./so_locations.
make[1]: *** [../../lib/auto/Fcntl/Fcntl.none] Error 1
make[1]: Leaving directory
`/n/starblazers/src/oss/ezk/perl5/build/irix6-perl5.004/ext/Fcntl'
make: *** [lib/auto/Fcntl/Fcntl.none] Error 2


Thanks,
Erez Zadok.
Mobile Computing Lab.
Columbia University Department of Computer Science.
---
EMail: ezk@cs.columbia.edu
Web:   http://www.cs.columbia.edu/~ezk
Member of the League for Programming Freedom -- write to lpf@uunet.uu.net


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

Date: Tue, 27 May 1997 17:55:45 -0700
From: Chris Schoenfeld <chris@ixlabs.com>
Subject: LWP: can't find DESTROY.al?
Message-Id: <338B8291.6BFA@ixlabs.com>

Hi,

I've got this weird bug, been plugging away, but no sense yet...

I have this simple subroutine I use for LWP HTML get's. Well,
I loaned it to my boss, who plugged it into a large script, and he 
gets the following warning (although everything works):

Can't locate auto/LWP/UserAgent/DESTROY.al in @INC at
/usr/local/lib/perl5/AutoLoader.pm line 26.

I upgraded to perl5.004 / latest CPAN LWP, no joy.
My script works fine standalone.

Let me know if this sounds familiar.

Chris


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

Date: Tue, 27 May 1997 16:04:34 -0700
From: Rob Perelman <robp@electriciti.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Magical Auto-increment operator
Message-Id: <338B6882.5BED@electriciti.com>

Tom Phoenix wrote:
> 
> On Tue, 27 May 1997, Rob Perelman wrote:
> 
> > I am a little confused by Perl's handling of the magical auto-increment
> > operator.  In the second edition of the Camel, it is explained on page
> > 79 that the variable must match the pattern /^[a-zA-Z]*[0-9]*$/ for it
> > to be interpreted as a string.  Why is this?  Shouldn't the ++ operator
> > work as such so that it should test to see if the variable is a number,
> > and if it is not, treat it as a string?
> 
> But if any old character can appear in a string, what do you get by
> incrementing '3/9'? I think you would get '300' - oops! No more magic!
> 
> Unless I've misunderstood your idea... :-)

You did not understand the question, but you may have missed part of my
"standards" in the code I showed.  My proposal was to skip over
non-alphanumeric characters.  So your example of '3/9' would increment
to '4/0', and then '4/1' ... '4/9', '5/0'.  Perl's answer to '3/9' is
4.  I _really_ don't understand that.  Please reference my original
message <338B2BFF.3CDA@electriciti.com> if you want to review the
source.  And thank you for your prompt reply!


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

Date: Tue, 27 May 1997 16:01:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rob Perelman <robp@electriciti.com>
Subject: Re: Magical Auto-increment operator
Message-Id: <Pine.GSO.3.96.970527155137.22110F-100000@kelly.teleport.com>

On Tue, 27 May 1997, Rob Perelman wrote:

> I am a little confused by Perl's handling of the magical auto-increment
> operator.  In the second edition of the Camel, it is explained on page
> 79 that the variable must match the pattern /^[a-zA-Z]*[0-9]*$/ for it
> to be interpreted as a string.  Why is this?  Shouldn't the ++ operator
> work as such so that it should test to see if the variable is a number,
> and if it is not, treat it as a string?

But if any old character can appear in a string, what do you get by
incrementing '3/9'? I think you would get '300' - oops! No more magic!

Unless I've misunderstood your idea... :-)

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/




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

Date: 27 May 1997 22:01:28 -0400
From: (*sdfasdf@jumbo.com
Subject: MS-DOS port of the Perl programming language
Message-Id: <5mg3lo$4n6@orion.jumbo.com>

Get NEW MS-DOS port of the Perl programming language Shareware As It's Written!

The latest and greatest MS-DOS port of the Perl programming language shareware and 
freeware as soon as it's created!   We download new programs DAILY 
(10 a.m. EST) from more than 300 sites all over the world.  

Check out the new programs everyday in the "TODAY'S FREE COMPUTER
PROGRAMS" section on the all new JUMBO! ---  bigger and faster 
than ever with over 200,000 files and programs --- more than 1.8 million 
links --- including a HUGE multimedia section with sounds, graphics, videos,
streaming music, VRML, animations, clip art, icons,
schockwave, screen savers --everything! --- http://www.jumbo.com.

Get the latest at:


http://www.jumbo.com/pages/programming/dos/perl/
http://www.jumbo.com/pages/programming/mac/languages/



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

Date: Tue, 27 May 1997 16:32:55 -0700
From: jon@vcnet.TAKE-OUT-TO-REPLY.com (JPR)
Subject: nslookup's in perl
Message-Id: <jon-ya023480002705971632550001@news.vcnet.com>

After spending hours trying to get gethostbyaddr to return a hostname from
an IP address, I surrender. I've looked through the 2nd edition camel, the
perl.org pages, CPAN, etc. Can somebody give me an example of how to take

192.68.68.1

and get

whatever.domain.com

Help????

TIA,
Jon


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

Date: Tue, 27 May 1997 21:18:15 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: nslookup's in perl
Message-Id: <fl_aggie-ya02408000R2705972118150001@news.fsu.edu>

In article <jon-ya023480002705971632550001@news.vcnet.com>,
jon@vcnet.TAKE-OUT-TO-REPLY.com (JPR) wrote:

+ Can somebody give me an example of how to take
+ 
+ 192.68.68.1
+ 
+ and get
+ 
+ whatever.domain.com

Why certainly. I grabbed this from another post quite a while ago.

James

----slice -n- dice ----

#!/usr/bin/perl

#usage:
#$ address2name 199.232.46.114

$bobo = pack("C4", (shift =~ /(\d+).(\d+).(\d+).(\d+)/));
($name, $aliases, $addrtype, $length, @addrs) = gethostbyaddr($bobo, 2);

print "Name: $name\n";
print "Aliases: $aliases\n";
print "Address type: $addrtype\n";
print "Length: $length\n";
print 'Addresses: ';

foreach (@addrs) { print join('.', unpack('C4', $_)); }
print "\n";

----slice -n- dice ----

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 27 May 1997 18:25:00 -0700
From: "Jay Scherberth" <editor@primenet.com>
Subject: Password Protection - NT
Message-Id: <01bc6b05$e3546a20$e534d4cc@jayscher>

Is is possible to password protect a cgi-bin on an NT server using IIS3.0? 

I have set up a  cgi based discusion group (WEBbbs) that needs restricted
access but have yet to firgure out how this can be accomplished. I have set
up a .asp based login scheme which checks a MS Access database for
authentication so the UserID and Pasword have already been entered. The
user is taken to a "Private area" of the site which is a Active Server Page
with links to the WEBbbs discussion group. There are links to 8 different
discussion groups (www.mydomain.com/cgi-bin/configx.pl) Config.pl is the
executable. I need a way to intercept someone who can simply enter in the
correct URL, thus bypassing the security all together.

Thanks in advance for any help on this!

Jay Scherberth
www.editorsguild.com


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

Date: 27 May 1997 21:13:49 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Perl Packages
Message-Id: <5mfiqd$7a8@news-central.tiac.net>

In article <338B19AD.177E6922@btg.com>, Dave Mead  <dmead@btg.com> wrote:
>Where can I get a list of the various Perl packages' function blurbs?
>For example, are there any documents out there that tell you what the
>arguments, return values ,etc., of all of the functions in the FTP
>package are?  Please respond to both the group and my email address.

Most modern perl modules come with embedded documentation in pod (plain
old documentation) format.  The perldoc program can be used to present the
pod documentation e.g.

$ perldoc Net::FTP


site_perl::Net:User(Contributed Perl Documesiteiperl::Net::FTP(3)


NAME
       Net::FTP - FTP Client class

SYNOPSIS
           use Net::FTP;

           $ftp = Net::FTP->new("some.host.name");
           $ftp->login("anonymous","me@here.there");
           $ftp->cwd("/pub");
           $ftp->get("that.file");
           $ftp->quit;


DESCRIPTION
       Net::FTP is a class implementing a simple FTP client in
       Perl as described in RFC959.  It provides wrappers for a
       subset of the RFC959 commands.

  [...]

You should check the pod subdirectory of a recent (maybe 5.004)
distribution to see various other convertors.

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 27 May 1997 21:15:48 -0400
From: Bill Cowan <billc@tibinc.com>
To: Dave Mead <dmead@btg.com>
Subject: Re: Perl Packages
Message-Id: <338B8744.1758@tibinc.com>

Dave Mead wrote:
> 
> Where can I get a list of the various Perl packages' function blurbs?
> For example, are there any documents out there that tell you what the
> arguments, return values ,etc., of all of the functions in the FTP
> package are?  Please respond to both the group and my email address.
> 
> Thanks in advance,
> 
> Dave Mead
> dmead@btg.com

Usually CPAN and standard modules have documentation embedded in the
source code as Plain Old Documentation (i.e. "POD", which is described
in the perlpod man page). 

You can use the "perldoc" utility to extract/display the embedded POD
from a module.  There are also converters to convert POD into: pod2html
for HTML file, pod2text for plain text, or pod2man for Unix man page.

Bill

========= Extracted from POD in perldoc utility ============
NAME 

perldoc - Look up Perl documentation in pod format. 

SYNOPSIS 

perldoc [ -h ] [ -v ] [ -t ] [ -u ] PageName|ModuleName|ProgramName 

DESCRIPTION 

perldoc looks up a piece of documentation in .pod format that is
embedded in the perl installation tree or in a perl script, and displays
it via pod2man | nroff
-man | $PAGER. This is primarily used for the documentation for the perl
library modules. 

Your system may also have man pages installed for those modules, in
which case you can probably just use the man(1) command. 

OPTIONS 

-h help 
    Prints out a brief help message. 

-v verbose 
    Describes search for the item in detail. 

-t text output 
    Display docs using plain text converter, instead of nroff. This may
be faster, but it won't look as nice. 

-u unformatted 
    Find docs only; skip reformatting by pod2* 

-m module 
    Display the entire module: both code and unformatted pod
documentation. This may be useful if the docs don't explain a function
in the detail you
    need, and you'd like to inspect the code directly; perldoc will find
the file for you and simply hand it off for display. 

PageName|ModuleName|ProgramName 
    The item you want to look up. Nested modules (such as
File::Basename) are specified either as File::Basename or File/Basename.
    You may also give a descriptive name of a page, such as perlfunc.
You make also give a partial or wrong-case name, such as ``basename''
for
    ``File::Basename'', but this will be slower, if there is more then
one page with the same partial name, you will only get the first one.


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

Date: 27 May 1997 11:44:10 -0400
From: Vivek Khera <khera@kciLink.com>
Subject: Re: perl5.003_93/BSDI 3.0 with dynamic loading
Message-Id: <x7vi44sywl.fsf@kci.kciLink.com>

>>>>> "WEH" == William E Hatch <hatch@cais2.cais.com> writes:

WEH> Has anyone compiled the above perl with dynamic loading on BSDI/386 3.0
WEH> I have tried it using shlicc2 (shlicc will not compile the perl source

Build Perl 5.004, which contains the proper BSD/OS 3.0 hints.  You are
not building a shared library to link against other programs so you
don't need to run mkshlib at all; you are building object files which
will be linked dynamically to your perl.  Be sure not to "strip" the
perl binary when installed.


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

Date: 27 May 1997 17:02:20 -0400
From: fawcett.nospam@nynexst.com
Subject: Re: Problem with <>
Message-Id: <8jg1v8ocgz.fsf@nynexst.com>

Bruce Bromberek <bromberek@cems.umn.edu> writes:
> I'm writing a script to process datafiles
> 
> while($filename = <*.dat>) 
> 
> will return every file in the current directly that matches the above
> pattern *.dat
> 
> I tried to be sneaky and make the pattern a command line option
> 
> $pat = $ARGV[0];
> 
> but I found that 
> 
> while($filename = <$pat>)
> 
> will return only the first match.
> 
> What am I missing?


>From the perlop man page:

     If the string inside angle brackets is not a filehandle or a
     scalar variable containing a filehandle name or reference,
     then it is interpreted as a filename pattern to be globbed,

Try:
	while ($filename = glob("*s")) {

-Tom


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

Date: 27 May 1997 23:34:45 GMT
From: jahwan@supernova.math.lsa.umich.edu (Jahwan Kim)
Subject: Re: Problem with <>
Message-Id: <slrn5omrsl.705.jahwan@supernova.math.lsa.umich.edu>

On Tue, 27 May 1997 14:21:17 -0500, 
    Bruce Bromberek <bromberek@cems.umn.edu> wrote:
> I'm writing a script to process datafiles
> while($filename = <*.dat>) 
> will return every file in the current directly that matches the above
> pattern *.dat
> I tried to be sneaky and make the pattern a command line option
> $pat = $ARGV[0];
> but I found that 
> while($filename = <$pat>)
> will return only the first match.
> What am I missing?
> Bruce Bromberek

    This is likely to be a shell problem.  When you type
% your-script-name *.dat
at the shell command prompt, the shell--whatever it is--expand them and the
perl doesn't even see '*' character.  That is '*' is globbed by the shell.
    You can pass '*' to the perl by 
% your-script-name '*.dat'
or you can just go through @ARGV.

Jahwan


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

Date: 27 May 1997 21:19:27 GMT
From: brent@AAC.MsState.Edu (Brent Johnson)
Subject: Process Information
Message-Id: <5mfj4v$cd6$1@NNTP.MsState.Edu>

Is there a module or some Perl code available which can access
process information for Unix machines?  Piping the 'ps' command
tends to be a little slow at times and differs from machine to
machine.

- Brent

---------------------
Brent L. Johnson                                brent@saturn.msstate.edu
System & Networks                               blj1@ra.msstate.edu
http://saturn.msstate.edu/homepages/brent       blj1@cobilan.msstate.edu


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

Date: Tue, 27 May 1997 19:33:21 +0100
From: Wm <wm_n00@tarrcity.demon.co.uk>
Subject: Re: Reading binary files: OK under DEC UNIX, error under Win32
Message-Id: <RSNNUXAxjyizEwnn@tarrcity.demon.co.uk>

Tue, 27 May 1997 13:25:01 <338AC48D.6769@xray.bmc.uu.se>
John Marelius <john@xray.bmc.uu.se> posted...

>Two of my PERL program that read data from binary files (FORTRAN
>unformatted files) work fine with PERL 5.002 under DEC UNIX (2.0 and up)
>but fails under PERL 5.003_07 for Win32 (NT 4.0/Alpha).

>The calls to the read function work normally the first 100-200 bytes but
>after that read fails to read any more.
>
>Has anyone else experience this kind of problem (and found a solution)?
>
<snip>

Try adding the line:

        binmode REIN; # or whatever the file is

immediately after opening the file as you've probably got ctrl-Z's in
it.

-- 
Wm ... did you know?  My spell checker wants tarrcity to be atrocity.


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

Date: Tue, 27 May 1997 15:49:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: kyzer@hotmail.com
Subject: Re: regexp solver
Message-Id: <Pine.GSO.3.96.970527154124.22110E-100000@kelly.teleport.com>

On 27 May 1997, Kyzer wrote:

> I'm wondering, is there a program to solve perl regexps?
> (That is, print out all possible matches, using * to represent 'this could
> match anything, and I'm not going to print that all out)

There are still too many to print; what useful string could this produce?

   /foo...\sbar\b/

But you could make a program which would parse the regexp and come up with
something that is one possible match... But if you write something, make
sure that it can handle this test case in a reasonable amount of time. :-)

   /(?=.*{999}f(oo)).(?!.*{999}\1)/i

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 27 May 1997 21:39:04 GMT
From: ez041407@chip.ucdavis.edu (Eric Finley)
Subject: Re: script optimization of grep -c
Message-Id: <5mfk9o$5dh$1@mark.ucdavis.edu>

Chipmunk (Ronald.J.Kimball@dartmouth.edu) wrote:
: In article <5ltcgi$l3m$1@mark.ucdavis.edu>
: ez041407@chip.ucdavis.edu (Eric Finley) writes:
: 
: > I frequently have to do a "grep -c <word> <file>" on very large (~100Meg)
: > files and wrote this script to hopefully do it faster, grep take >5 min.
: > Is there any way to optimize this code?
: 
: How does your script as it is right now compare to grep in terms of
: speed?
: 
: Chipmunk
After some advice on my regex my code looks like: 
open(FILE, $ARGV[1]) || die "Could not open $ARGV[1]\n$!\n";
$i = 0;
$pattern = $ARGV[0];
while(<FILE>) {
    $i++ if m/$pattern/o
}
print "$ARGV[0] found $i times in $ARGV[1]\n"

and it is slightly slower than grep -c :(

I guess I have to give up
Thanks for all the help
Eric Finley



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

Date: Tue, 27 May 1997 16:42:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Search Pattern Help????
Message-Id: <afkfm5.mh6.ln@localhost>

Daniel Cody (codyd@cc.sdstate.edu) wrote:

: We have been using a REXX script to search our email database for the
: past few years.  I would like to change this to a perl script for
: obvious reasons.  The way the REXX script was written, we added a '>'
: before every name, as that is what the script would look for before a
: name.  The email address was right below, so it looked something like
: this: 
: >Cody, Daniel
: Email: codyd@cc.sdstate.edu

: Is there anyone that could point me in somewhat of the right direction
: on this one?  I am just starting to learn perl and am still trying to
: understand some of its quirks.  Any help would be appreciated :)


while (<>) {
   if (/^>/) {                 # matched > at beginning of line
      $email_adr = <>;         # read the next line
      print "$email_adr\n";
   }
}


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Tue, 27 May 1997 18:52:49 -0400
From: Patrick Randall <randall@grcmc.org>
Subject: Solaris and sockets
Message-Id: <338B65C1.1AC8@grcmc.org>

Does anyone have a cookbook-like script that will let me log things to
syslogd with Perl 5.01 and Solaris 2.4?

The faq merely says that the Solaris sockets are nonstandard but doesn't
give any examples.  I've tried running h2ph, and I've tried Socket.pm,
but I'm not real clear on how to resolve the Solaris differences.

thanks,
Patrick


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

Date: 28 May 1997 01:12:21 GMT
From: "rferr" <rferr@voicenet.com>
Subject: tcp socket chase
Message-Id: <01bc6b04$594b9ca0$878667cf@rferr.voicenet.com>

is there a perl way to track a user that signs on to our intranet server ?
i need to know
when they sign on, how long they are signed on and when they sign off.

if this is a cgi question, let me know a good cgi newsgroup i could post
to.

much thanks.


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

Date: Tue, 27 May 1997 19:56:53 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: types
Message-Id: <tcyangEAuvEu.Ep6@netcom.com>

One more thing.  $a = 'a' can pass the test

   ($a ne '') && ($a eq int($a))

but $a = '0.0' cannot pass that test (the above test will say $a = 'a'
is not an integer but $a = '0.0' is not, either).

=======================================================
Tung-chiang Yang (tcyang@netcom.com) wrote:

: (Code:)

: #!/usr/local/bin/perl

: $a = 'a';
: print "It is an integer\n" if ($a ne '') && ($a == int($a));

: (Output:)
: {netcom10:32} ~/tmp/a
: It is an integer

: Replacing $a above with '0.0', which is an integer by human beings,
: and I can get "It is an integer", though.

: (deleted)

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: 28 May 1997 00:53:39 GMT
From: sprashant@aol.com (SPrashant)
Subject: using getopt or getopts function
Message-Id: <19970528005300.UAA24192@ladder02.news.aol.com>

I am a new user of perl and I am trying to use the library module getopt
in my script. I get "Bus error(core dumped)". Following script is a test
script that produces the above error.

#! /usr/local/bin/perl

use Getopt::Std;
getopt('dV');

I execute the above script as follows : scriptname -d debug.


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

Date: 27 May 1997 23:37:40 GMT
From: jbharvey@gte.net (Justin B. Harvey)
Subject: Using hash, appending and dbm
Message-Id: <5mfr84$cok$1@news10.gte.net>

	I have a problem, I'm reading data from a flatfile and making
a dbm file from it, so like normal I do a dbmopen with my %hash, but
how do I append data to my hash?  I try:

	$var  .= join "#", $date,$status, $user, $sess, $time, $clid;
        	$hash{$ip} = $var;

But it reports this:

	ndbm store returned -1, errno 28, key "199.180.3.29" at roto
line 17, <DETAIL> chunk 118.

When I run it...so what am I doing wrong? It works if I'm not running
dbm.


Justin

--
Justin B. Harvey
jbharvey@gte.net
http://home1.gte.net/jbharvey


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

Date: 27 May 1997 22:30:21 GMT
From: gerben@localhost.cs.vu.nl (Gerben Vos)
Subject: Re: Using TAB key position fill-in forms/items
Message-Id: <5mfn9t$gim@star.cs.vu.nl>

That behaviour depends on which browser you use. PC Netscape can behave
slightly differently from Unix Netscape. For more information, please
ask your question again on comp.infosystems.www.browsers.misc .
(Because your question has nothing at all to do with Perl.)

 . . . . . . . . . . . . . . . . . . . . . . . . . . . G e r b e n   V o s   <><
mailto:gerben@cs.vu.nl                           http://www.cs.vu.nl/%7Egerben/
Misery is much more serious than pleasure, but it is not more important.
                                        -- Herman Finkers


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

Date: 25 May 1997 21:03:53 -0600
From: Vladimir Alexiev <vladimir@cs.ualberta.ca>
To: allen@gateway.grumman.com (John L. Allen)
Subject: Re: yet another perl regex Q
Message-Id: <omoh9z2aue.fsf@tees.cs.ualberta.ca>

In article <5m1nc0$jee@gateway.grumman.com> allen@gateway.grumman.com (John L. Allen) writes:

> Why doesn't either of the following replace the *last* three blanks in $_
> with 'bar'?
> 	perl -e '$_="foo      xxx"; s/ {3}(?=.*)$/bar/; print'
> 	perl -e '$_="foo      xxx"; s/ {3}(?=.*?)$/bar/; print'

Because neither matches. You`re asking for three spaces followed by anything
(BTW this condition is obviously vacuously true), and at the end of the
string. But you got an x and the end of the string, not spaces.

> I expected backtracking to occur from the end of $_ until three blanks
> are found.
No. / {3}(?=.*)$/ is *the same* as / {3}$/ because the assertion is
zero-width. And this asks the spaces to be at the end. 

Try this / {3}(?=[^ ]*$)/ (note that $ is *inside* the assertion).



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

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

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