[9318] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2913 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 19 15:07:23 1998

Date: Fri, 19 Jun 98 12:00:27 -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           Fri, 19 Jun 1998     Volume: 8 Number: 2913

Today's topics:
    Re: ^I <psdspss@execpc.com>
        Abigail's Line [Was: regex terminator not allowed in co <John.Adams@BentonvilleAR.ncr.com>
    Re: Appending one file to another <rootbeer@teleport.com>
    Re: Appending one file to another <psdspss@execpc.com>
    Re: Checking for timeouts when using IO:Socket::INET <jay@rgrs.com>
    Re: first language <psdspss@execpc.com>
    Re: first language <chris@nemonet.com>
    Re: first language <ajohnson@gpu.srv.ualberta.ca>
    Re: Flames.... (Michael J Gebis)
    Re: help with string comparisons (Larry Rosler)
    Re: How do you pre-append using "open" (Earl Hood)
    Re: How to scrub Ctl-Z? <gacarey@domain.com>
    Re: javascript and perl <syzygy@seanet.com>
    Re: modperl on NT <rootbeer@teleport.com>
    Re: Newbie question (Andre L.)
        NT performance info (perflib) <asmenon@rahul.net>
    Re: Problem with references (Mark-Jason Dominus)
    Re: Q: Trouble with a perl script that downloads a file <rootbeer@teleport.com>
    Re: redirecting stdout in WinNT cbason@yahoo.com
    Re: Regular Expression Question <*@qz.to>
    Re: Regular Expression Question <tkil@scrye.com>
    Re: Script for changing password <rootbeer@teleport.com>
        String Puzzle. <rjcst26@pitt.edu>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 19 Jun 1998 12:50:03 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: ^I
Message-Id: <358AA4CB.43EEE9FF@execpc.com>



Atul R Ankola wrote:

> Can anyone tell me what the ^I sequence in PERL does?  I've heard that
> it can do 4-5 steps in one.  Can anyone refer me to a site that has this
> handy?  Thanks.
>
> --
> ---Atul
> --

   This is an inplace editing.
Look at
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html#How_do_I_change_one_line_in_a_fi

hope this helps

Deva



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

Date: Fri, 19 Jun 1998 13:19:01 -0500
From: John Adams <John.Adams@BentonvilleAR.ncr.com>
Subject: Abigail's Line [Was: regex terminator not allowed in comment in extended regex?]
Message-Id: <358AAB95.7E09@BentonvilleAR.ncr.com>

Abigail wrote:

> perl -wle 'print "Prime" if ("m" x shift) !~ m m^\m?$|^(\m\m+?)\1+$mm'

I'm getting this message when I try this at home (well, not at my
_dwelling_, but at my location described in "Hey, kids! Don't try this
at home!"):

Use of uninitialized value at -e line 1.

What's the deal? And why am I unable to figure this out myself? (Well, I
might be able to answer _that_ question...)

	John A


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

Date: Fri, 19 Jun 1998 18:27:22 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Appending one file to another
Message-Id: <Pine.GSO.3.96.980619112141.15366E-100000@user2.teleport.com>

On Fri, 19 Jun 1998, Deva Seetharam wrote:

> print HEAD <TAIL>;
> 
> <TAIL> returns all the records pointed by TAIL file handle.

While that works, it may be significant that it will read all of the
(remaining) lines from TAIL before it starts printing - in other words, it
temporarily loads all of the file into memory. It's generally more
memory-efficient to print just one line at a time in a loop. (Whether it's
faster or slower depends upon many factors, including how rapidly your
system can allocate memory. If speed is a major concern, though, I'd use
read() with a buffer of 8192 instead of the line input operator.)

    print HEAD while <TAIL>;

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 19 Jun 1998 13:36:11 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: Appending one file to another
Message-Id: <358AAF9B.CD3DA760@execpc.com>



Tom Phoenix wrote:

> On Fri, 19 Jun 1998, Deva Seetharam wrote:
>
> > print HEAD <TAIL>;
> >
> > <TAIL> returns all the records pointed by TAIL file handle.
>
> While that works, it may be significant that it will read all of the
> (remaining) lines from TAIL before it starts printing - in other words, it
> temporarily loads all of the file into memory. It's generally more
> memory-efficient to print just one line at a time in a loop. (Whether it's
> faster or slower depends upon many factors, including how rapidly your
> system can allocate memory. If speed is a major concern, though, I'd use
> read() with a buffer of 8192 instead of the line input operator.)
>
>     print HEAD while <TAIL>;
>
> Cheers!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/

  Thanks for pointing out.
I apologize, if my solution had created any inconvenience to
Bryan Camp. (one who asked this question.)

Deva



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

Date: 19 Jun 1998 14:26:06 -0400
From: Jay Rogers <jay@rgrs.com>
To: phoenixl@aol.com (Phoenixl)
Subject: Re: Checking for timeouts when using IO:Socket::INET
Message-Id: <82emwlfdtt.fsf@shell2.shore.net>

phoenixl@aol.com (Phoenixl) writes:
> I've got this example working with no problem, but I'm not sure what
> code need to add to see if there was a timeout while reading.  Can
> someone give me a suggestion?

The module Net::Telnet supports timing-out while reading or writing.
It's easy to install as it doesn't require any other modules that
don't already come with a standard distribution of perl.

    use Net::Telnet ();
    $t = new Net::Telnet (Timeout  => 10);
    
    $t->open(Host => "www.aol.com",
             Port => 80);
    $t->print("GET / HTTP/1.0\n");
    
    $t->input_record_separator("\n\n");
    $header = $t->getline;
    
    while (! $t->eof) {
        $content .= $t->get;
    }

Since your example connects to an http server, you should also look at
the libwww-perl collection of modules.

> use IO::Socket;
> 
> $socket = IO::Socket::INET->new(PeerAddr => 'www.aol.com',
>                                  PeerPort => 'http(80)',
>                                  Proto    => 'tcp',
>                                 Timeout => 120);
> 
> if( ! defined $socket)
> {
>    print "Bad address\n";
>    exit;
> }
> 
> 
> #  set for no buffering
> 
> $old_fn = select($socket);
> $| = 1;
> select($old_fn);
> 
> 
> #  turn off character mapping
> 
> binmode($socket);
> 
> print $socket "GET / HTTP/1.0\n\n";
> 
>  while(<$socket>)
>  {
>       print $_;
>  }

--
Jay Rogers
jay@rgrs.com


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

Date: Fri, 19 Jun 1998 12:40:28 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: first language
Message-Id: <358AA28C.1882F4F9@execpc.com>



Abigail wrote:

> Randal Schwartz (merlyn@stonehenge.com) wrote on MDCCLIII September
> MCMXCIII in <URL: news:8cbtrpbgn2.fsf@gadget.cscaper.com>:
> ++ >>>>> "Dan" == Dan Nguyen <nguyend7@egr.msu.edu> writes:
> ++
> ++ Dan> The person needs to be a "natural" programmer.  Generally I feel that
> ++ Dan> most people have hard time not with the language but with the process
> ++ Dan> of programming.  A person could learn Perl as a first language very
> ++ Dan> easily and have no problems, while others could become stuck on the
> ++ Dan> syntax of the language.
> ++
> ++ I'll second this.  I see far too many people *attempting* programming
> ++ that would probably have a better time being firefighters or line
> ++ chefs or congressmen or something.  Sure, maybe nearly anyone with
> ++ enough effort can hack out a VB script to automate a repeated task,
> ++ but programming *well* seems to require a twisted aptitude only some
> ++ small percentage of the population seems to have.  I think I was lucky
> ++ to be born with it, given the time at which I was born. :-) No
> ++ ordinary amount of education can seem to teach people how to "think"
> ++ like a progammer.  ("You have these seven transformations possible and
> ++ this problem requires converting Q to W... go!")
> ++
> ++ I suppose it would be too much to ask that if you're not a natural
> ++ programmer, either stay out of the business, or flag your work
> ++ properly so that we cleanup people know what to throw out first. :-)
>
> That sounds as if programming would be an art. I disagree with that.
> I believe that most people can be able to learn how to program. Just
> like most people could learn how to become a car mechanic.
>
> Whether everyone has the motivation to learn is a different issue.
>

"programming" and "Programming" are not the same.
Point is not whether somebody can learn to write a few lines of code;
But whether he/she can use the programming lang. to solve a real world problem
efficiently, elegantly and **effectively**.

Programming is undoubtedly an art.
It requires a brilliant mind to understand the problem domain, conceptualize
a suitable data structure and employ an efficient algorithm to produce
an elegant solution.

(:-) != (MonaLisa)

Deva




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

Date: Fri, 19 Jun 1998 01:34:22 -0500
From: "Chris" <chris@nemonet.com>
Subject: Re: first language
Message-Id: <6meb0q$k97$1@news4.ispnews.com>


Randal Schwartz wrote in message <8c7m2dbgim.fsf@gadget.cscaper.com>...
>>>>>> "Dan" == Dan Nguyen <nguyend7@egr.msu.edu> writes:
>
> To master structured programming, learn Pascal *first*.
> To master object-oriented programing, learn Smalltalk *first*.
>
>There's no excuse for not knowing Pascal and Smalltalk given the free
>implementations out there.
>


I actually suggest to people who want to learn programming that they should
get source code for the same type of program in two different languages, and
compare and contrast.

As for early learning of langugaes, Forth is a perfectly good language to
learn early on,
though I'd not list it as a good First language. I'd also say that Scheme is
a great
early language, and may even work well as a first lamguage. ABC sems a good
choice too, although its historical ties to BASIC make many cringe, I'm
sure.

Really, though, I wouldn't teach programming in any of these languages to
beginners.
If I were actually teaching a course, I'd lean towards Lisp, Perl, or
Pascal,
because these languages each present a strong model of what is going on in
the
code. Pascal has very simple text manipulation, Perl has very strong
searching and
replacing methods - rivaling ome of the best libraries for a few other
languages - and
Lisp has a very good model of type and precedence, although the
type-by-structure idea is foreign to many of us.

Right now, I think Perl should take a front seat because of its use for CGI.
If a first
language has one most important feature, it's availability of examples. This
shows the
person learning that there are real-world applications for the language,
gives them source code to modify, and lets them begin working without
writing from scratch.
Programming from scratch requires knowledge of the syntax, when learning a
language should be about semantics first. Modifying other people's source
gives
this advantage, and much source is available in Perl lately.


=================================================================
Chris Stith
Asst. Network Administrator
DataStream Networks, Inc.
chris@nemonet.com
-----------------------------------------------------------------
"Every program should do as much as is necessary, but much less
than what is possible." -- Anonymous




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

Date: Fri, 19 Jun 1998 13:28:08 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: first language
Message-Id: <358AADB8.40C7F8ED@gpu.srv.ualberta.ca>

Abigail wrote:
> 
[snip]

> ++ I suppose it would be too much to ask that if you're not a natural
> ++ programmer, either stay out of the business, or flag your work
> ++ properly so that we cleanup people know what to throw out first. :-)
> 
> That sounds as if programming would be an art. I disagree with that.
> I believe that most people can be able to learn how to program. Just
> like most people could learn how to become a car mechanic.

Indeed, I agree --- I think of programming as a craft, like 
writing or blacksmithing... not every writer creates literary
masterpieces, and not every blacksmith  becomes an artisan...
 
> Whether everyone has the motivation to learn is a different issue.

or to put in the effort to continually hone their craft.

regards
andrew


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

Date: 19 Jun 1998 18:01:43 GMT
From: gebis@albrecht.ecn.purdue.edu (Michael J Gebis)
Subject: Re: Flames....
Message-Id: <6me927$hrl@mozo.cc.purdue.edu>

John Call <johnc@interactive.ibm.com> writes:

}I agree that many newbies don't know about faqs. They know about newsgroups.
}They search. Find perl.misc. They submit. They get barked at but hopefully
}the bark contains a pointing to the faq. Hopefully they learn and next time
}they go to the faq to begin with. The real solution is pointing them to the
}faq to begin with if possible. I just don't know how that could be
}done.......

The faq is big.  The docset for perl is big.  This is a good thing,
but it is not without problems.  It's hard to find stuff if you lack
context.  Dejanews is worse -- if you don't have some good keywords,
you'll end up finding 200,000 seemingly random results.

I try to remember this and at least provide some context, keywords, or
location hints when I do end up telling someone to "FAQ off."  

-- 
Mike Gebis  gebis@ecn.purdue.edu  mgebis@eternal.net


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

Date: Fri, 19 Jun 1998 10:51:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: help with string comparisons
Message-Id: <MPG.ff4450fbec0cd389896a7@nntp.hpl.hp.com>

In article <6me16o$dgr$1@nnrp1.dejanews.com>, jay_st_louis@my-
dejanews.com <jay_st_louis@my-dejanews.com> says...
> I was wondering if there is a way to compare a specific number of characters
> in a string in Perl, like using strncmp in C. for example, if I wanted to
> compare just the first five characters of 2 strings that were 20 characters
> long. can this be done?
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading

Whoops -- two of the identical posts were *you*, within 11 minutes of 
each other, with slightly different wording.  What's *that* all about???

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 19 Jun 1998 18:09:09 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: How do you pre-append using "open"
Message-Id: <6me9g5$k8m@news.service.uci.edu>

In article <Pine.GSO.3.96.980618195259.17544J-100000@user2.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
>On Fri, 19 Jun 1998, Nick Forte wrote:
>
>> I'm trying to pre-append a record to a flat file. I want the record to
>> be inserted on the first line everytime instead of appending it to the
>> end. Can someone help me?
>
>Section five of the FAQ has an entry on this oxymoronic notion of
>"appending to the beginning" of a file. Hope this helps! 

Actually, it is not oxymoronic.  "append" means to attach or affix.
There is no notion of location.  So making the statement, "append to
the beginning" is okay since it explicitly states where the data
should be attached.

	--ewh
-- 
             Earl Hood              | University of California: Irvine
      ehood@medusa.acs.uci.edu      |      Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


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

Date: Fri, 19 Jun 1998 11:29:23 -0700
From: Greg Carey <gacarey@domain.com>
Subject: Re: How to scrub Ctl-Z?
Message-Id: <358AAE03.A26FB963@domain.com>

Of course you're right!  I want to replace it with a space.

>>Try using binmode() to get into binary-read mode.  After that, you should
>>slurp the entire file as a single operation into a scalar (undef $/) and
>>operate on that.

I hate to trouble you, but I cannot get the syntax correct for the above.
I've never used Perl before and it's a bit unlike my other languages.  I need
to open a filename that's passed in (it's different every day & about 20MB),
scrub it, and save it to another filename, also passed in.  I'm using NT 3.51.

I'm willing to work at this, but don't want to go to school too much as I
don't anticipate using Perl again for awhile.  The Perl docs seem to assume I
come from a C environment and provide definition, but little instruction. Any
advice you provide would be helpfull.



Craig Berry wrote:

> Do you really want to replace ctrl-Z with a doublequote character, a
> space, and another doublequote character?  That's what this would do.
> What you probably mean is
>
>   s/\x1A/ /g
> or
>   s/\cZ/ /g
> or even
>   tr/\cZ/ /
>
> As for Perl seeing it as an eof, I presume you're on a DOS-based system.
> Try using binmode() to get into binary-read mode.  After that, you should
> slurp the entire file as a single operation into a scalar (undef $/) and
> operate on that.
>
> ---------------------------------------------------------------------
>    |   Craig Berry - cberry@cinenet.net
>  --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
>    |      Member of The HTML Writers Guild: http://www.hwg.org/
>        "Every man and every woman is a star."





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

Date: Fri, 19 Jun 1998 11:43:42 -0700
From: "Stuart Updegrave" <syzygy@seanet.com>
Subject: Re: javascript and perl
Message-Id: <6mebhg$pta@news.microsoft.com>

David Turley wrote in message <6me121$iab$1@oksennus.binary.net>...
>In comp.lang.perl.misc Jim Bowlin <bowlin@sirius.com> wrote:
>> Inge Soetens wrote:
>> >
>> > Hi,
>> >
>> > Can anyone tell me....
>> > Is it possible to call a perl procedure from a javascript function ?
>> >
>> > Thanks
>
>> No.  -- Jim Bowlin
>
>Why not?
>
>In the function:
>document.location="../cgi-bin/myscript.pl";


this is not a javascript function. you're changing the value of a property
(location) of the document object.

the original question appears to have been seeking something along the lines
of this:

function myJSfunction(){
    execute_perl;
}

while I won't say this is not possible, it's definitely different than what
you asserted.

~stuart





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

Date: Fri, 19 Jun 1998 18:17:55 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: modperl on NT
Message-Id: <Pine.GSO.3.96.980619111607.15366D-100000@user2.teleport.com>

On Fri, 19 Jun 1998 rwvtveer@my-dejanews.com wrote:

> Date: Fri, 19 Jun 1998 11:20:49 GMT
> From: rwvtveer@my-dejanews.com
> Newsgroups: comp.lang.perl.misc
> Subject: modperl on NT

Did you realize that you posted this message four times? If you're having
trouble with your Usenet software, you should generally check with your
news admin before you post again to a non-test newsgroup. 

> is it possible to setup a server without rebuilding any of the required
> software from the source? 

This sounds like a question about servers. Perhaps the docs, FAQs, and
newsgroups about servers can be of some assistance to you. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Tue, 16 Jun 1998 14:17:10 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Newbie question
Message-Id: <alecler-1606981417100001@dialup-627.hip.cam.org>

In article <3586821C.4A9350B3@globalscape.net>, Thomas Resing
<tresing@globalscape.net> wrote:

> 
> How about something like this?
> 
>  #!/usr/bin/perl
> 
> $imagedir = "your/directory";
> $myurl = "http://www.someurl.com/your/directory/";
> 
> print "Content-type: text/html\n\n";
> opendir(IDIR,"$imagedir") || die "Cannot open $cbdir:$!";
> print "<html><body>\n";
> 
> foreach $file (sort readdir(IDIR)) {
>   print "<img src=",$myurl.$file,"><br>\n" if $file =~ /gif/;
>   print "<img src=",$myurl.$file,"><br>\n" if $file =~ /jpg/;
> }
> closedir(IDIR);
> print "</body></html>\n";


What if the directory contains a file named "gifford.html" or "IMAGE.JPG"?
Also, JPEG images may have the extension .jpg, .jpeg or .jpe. You might
want to change the match for something like this:

foreach (sort readdir(IDIR)) {
   print "<img src=\"$myurl$file\"><br>\n" 
      if -f && /\.gif$|\.jp(?:e|g|eg)$/i;
}                                                   

A.L.


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

Date: 19 Jun 1998 18:47:19 GMT
From: AS Menon <asmenon@rahul.net>
Subject: NT performance info (perflib)
Message-Id: <6mebnn$bij$1@samba.rahul.net>


Hi,

I have been unsuccessful in using the Win32::PerfLib
module to keep track of the performance data on
NT machines, using the latest version of Gurusamy 
Sarathy's binary distribution.

Even a simple piece of code:

use Win32::PerfLib;
Win32::PerfLib::GetCounterName($server, \%counter);
print join ' ', keys %counter;
exit

 ..exit with an error that says "parse exception"

If there are kind souls out there who have 
successfully used hives in HKEY_PERFORMANCE_DATA and
HKEY_PERFORMANCE_TEXT on Windows NT registry
please let me know. If you have some working code
to that effect, it will be better.

Goal: My actual goal is to keep track of CPU
loads and related performance stuff on a network
of NT boxes.

Thanks

-Menon






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

Date: 19 Jun 1998 14:25:10 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Problem with references
Message-Id: <6meae6$lcm$1@monet.op.net>


In article <6me6i3$ijt$2@client3.news.psi.net>,
Abigail <abigail@fnx.com> wrote:
>Mark-Jason Dominus (mjd@op.net) wrote on MDCCLIII September MCMXCIII in
>++ I imagined a thousand people each saying `hash' five or ten times a
>++ day.
>True, but I seldom speak about Perl. 

Well, you weren't one of the thousand people I imagined.


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

Date: Fri, 19 Jun 1998 18:10:07 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Q: Trouble with a perl script that downloads a file for web user...
Message-Id: <Pine.GSO.3.96.980619110738.15366A-100000@user2.teleport.com>

On Fri, 19 Jun 1998 GustavoCollazo@hotmail.com wrote:

> open(LOG,">>$logfile");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

> open(STDOUT);

I'm not certain that this is doing what you may think it is doing.

> The problem comes in when the user clicks the link that calls the script.
> The browser brings up the "Save As" dialog for the user with the name of the
> PERL script file, instead of the file I'm trying to download.

That sounds like a browser problem. The docs, FAQs, and newsgroups about
browsers (and the protocol you're using) may be of some help. Good luck!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/




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

Date: Fri, 19 Jun 1998 18:32:20 GMT
From: cbason@yahoo.com
Subject: Re: redirecting stdout in WinNT
Message-Id: <6meark$1es$1@nnrp1.dejanews.com>

I'm having the same problem.  If anyone has any suggestions, I'd love to hear
them.

Clem


In article <35897606.3E2C@apicom.com>,
  Yary <yary@apicom.com> wrote:
>
> Here's an odd one, using G.S's precompiled Win32 distribution:
>
> D:>echo print "Hello" > bat.pl
>
> D:>bat.pl
> Hello
> D:>bat.pl > bat.txt
>
> D:>type bat.txt
>
> (bat.txt is empty)
> Why can I redirect the output of echo, but not bat.pl?
>
> -yary
>
> D:>perl -V
> Summary of my perl5 (5.0 patchlevel 4 subversion 02) configuration:
>   Platform:
>     osname=MSWin32, osvers=4.0, archname=MSWin32
>     uname=''
>     hint=recommended, useposix=true, d_sigaction=undef
>     bincompat3=undef useperlio=undef d_sfio=undef
>   Compiler:
>     cc='cl', optimize='-O', gccversion=
>     cppflags='-DWIN32'
>     ccflags ='-MD -DWIN32'
>     stdchar='unsigned char', d_stdstdio=define, usevfork=false
>     voidflags=15, castflags=0, d_casti32=define, d_castneg=define
>     intsize=4, alignbytes=8, usemymalloc=n, randbits=15
>   Linker and Libraries:
>     ld='link', ldflags ='-nologo -subsystem:windows'
>     libpth=d:\msdev\lib
>     libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib
> comdlg32.li
> b advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib
> wsock32.
> lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib
>     libc=msvcrt.lib, so=dll
>     useshrplib=undef, libperl=undef
>   Dynamic Linking:
>     dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
>     cccdlflags='', lddlflags='-dll'
>
> Characteristics of this binary (from libperl):
>   Compile-time options: DEBUGGING
>   Built under MSWin32
>   Compiled at Aug  9 1997 21:42:37
>   %ENV:
>     PERL5LIB="d:\QFS\BIN\perllib;d:\QFS\BIN\perllib\site;"
>   @INC:
>     d:\QFS\BIN\perllib
>     d:\QFS\BIN\perllib\site
>     d:\QFS\lib\site
>     d:\QFS\lib
>     c:\perl\lib
>     c:\perl\lib\site
>     c:\perl\lib\site
>     .
>


-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: 19 Jun 1998 18:09:22 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Regular Expression Question
Message-Id: <eli$9806191350@qz.little-neck.ny.us>

In comp.lang.perl.misc, Laura Morgan  <laura.morgan@itron.com> wrote:
> I have input parameters that can be file.name, *.ext, file.* or *.*

Those look a lot like globs.

> I'm parsing through a file trying to match on this input and perform a
> function (i.e. if the user types in *.c, I want to match all files with
> a .c extension, etc).

That sounds a lot like a glob.

> With the input variable name being $file, and the match against variable
> named $matchfile, is there a way I can make a comparison that will match
> $file with $matchfile, using the wildcard scenerio mentioned above?

For perl on Unix, you might want to use <*.c> type constructs to do
globbing, but perl won't let you put a variable in there, so you have
to use eval. And this is implemented by forking csh, so it is 
*really* slow.

> Still learning how regular expressions work...

You can transform globs to REs using this crude method:

	s/^/^/;
	s/$/$/;
	s/[.]/\\./g;
	s/[*]/.*/g;
	s/[?]/./g;

Then throw in a grep readdir and things should be dandy. This will
even allow [] constructs, but you might want to use an eval to
catch badly formed ones.

Elijah
------
and a lot faster than forking csh


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

Date: 19 Jun 1998 12:13:15 -0600
From: Tkil <tkil@scrye.com>
Subject: Re: Regular Expression Question
Message-Id: <glnqtgszo.fsf@scrye.com>

[posted and cc'd]

>>>>> "Laura" == Laura Morgan <laura.morgan@itron.com> writes:

Laura> I have input parameters that can be file.name, *.ext, file.* or
Laura> *.* I'm parsing through a file trying to match on this input
Laura> and perform a function (i.e. if the user types in *.c, I want
Laura> to match all files with a .c extension, etc).

i'm not sure i understand your structure, but this might help.  shells 
use wildcards to do "globbing".  while some of the globbing characters 
come from regular expressions, they usually have different meanings.

a short translation table:

	GLOB		Perl RE
	----		-------
	*		.*
	?		.
	.		\.
	[a-z]		[a-z]

thus, a glob pattern of "*.c" would turn into the perl regexp of
m/.*\.c/, possibly anchored with ^ and $  (e.g. m/^.*\.c$/).  watch
out for case, if you're hitting windows filesystems.  some more
translations:

	GLOB		Perl RE
	----		-------
	file.name	^file\.name$
	*.ext		\.ext$
	file.*		^file\.
	*.*		\.

[notice various shortcuts for leading/trailing "*" in the glob
pattern.]

take a look at the perlre man page, the 'glob' function in perlfunc,
and play around with the shell (to get a better feel for globbing, if
you need it) and a little script like this to get a feel for the
equivalences:

   opendir DIR, "." or die "couldn't open dir: $!";
   my @matches = grep { m/^.*\.c$/ } readdir DIR;
   closedir DIR or die "couldn't close dir: $!";
   print "matches: @matches\n";

or something like that.

t.

p.s. fish:  http://www.scrye.com/~tkil/glob_to_re.pl
-- 
Tkil * <URL: http://www.scrye.com/~tkil> * hopelessly hopeless romantic.
  "So amplify this little one 	|   She hears as much as she can see
   She's a volume freak       	|   And what she sees, she can't believe."
        -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"


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

Date: Fri, 19 Jun 1998 18:15:26 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Script for changing password
Message-Id: <Pine.GSO.3.96.980619111404.15366C-100000@user2.teleport.com>

On 19 Jun 1998 radhikary@hotmail.com wrote:

> Is there a script available for changing Unix system password from a
> HTML page. 

If you're merely looking to _find_ (as opposed to write) programs, this
newsgroup may not be the best resource for you. There are many free
software archives which you can find by searching Yahoo or a similar
service. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 19 Jun 1998 13:36:40 -0400
From: John Campos <rjcst26@pitt.edu>
Subject: String Puzzle.
Message-Id: <358AA1A7.33D30B31@pitt.edu>

Anyone,

I'm currently revising a perl script that reads an html document into a
variable and then split it up into 31k increments and then record each
piece to my database.  For example if the length of the document is 70k,
I would have 3 pieces (1st piece = 31k, 2nd piece = 31k, 3rd piece =
8k).  Making sure that each piece does not exceed 31k in length.

Problem:  I have to make sure that before I create a piece that I do not
split up a particular
                tag over two records.  It has to be whole.  The tag is
<a .....> .... </a>

I suspect I would create a loop that would append a piece at a time to a
variable until I reach my 31k limit and than save that last piece to the
database.  And then pick up where I left off and continue through the
rest of the document.

So when I find the first "<a" I would immediately look for the "a>" and
save it to a varible.
after each append I guess I would check the length and continue through
if < 31k?

I am new to the perl language.  Can anyone help me along with some of
the ways I would do this in perl.

Thank you in advance for you help

Ps. If you need more information, I will gladly provide it.



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

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

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