[7942] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1567 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jan 2 10:10:09 1998

Date: Fri, 2 Jan 98 07:00:31 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 2 Jan 1998     Volume: 8 Number: 1567

Today's topics:
     Re: 'flock'ing <sbekman@iil.intel.com>
     Re: Benchmarking (Tad McClellan)
     Re: bulk mail (Michael Budash)
     Re: bulk mail (Tad McClellan)
     Re: File test operators (Tad McClellan)
     forking in perl mjforder@hotmail.com
     Re: i am a newbie (Michael Budash)
     Re: misterious context <joseph@5sigma.com>
     Re: need help with pattern match <*@qz.to>
     Re: Need script to preview form data prior to submittin (Michael Budash)
     Re: Need script to preview form data prior to submittin (brian d foy)
     Re: newbie: what am i doing wrong? (Tad McClellan)
     Re: Okay, I should know this, but its about reading inf (Tad McClellan)
     Re: perl is c worsened (was: Re: word wrap routine) (brian d foy)
     Perl Script <AndieC@msn.com>
     Re: Perl Trick? (brian d foy)
     Re: PERLIPC - FIFO: parent, child, stalled! (Lutz Albers)
     pipeing problem. <sa@hogia.net>
     Pipes in Perl5 on Windows NT <jola@hem.passagen.se>
     Re: running perl on iis <knut@webcom.no>
     Re: running perl on iis <pjach@erac.com>
     Re: Script calls embedded in web pages <scott_clark@merck.com>
     send mail <hebert19@nwlink.com>
     Re: Simple(!) regular expression problem (Tad McClellan)
     Re: sockets (Clay Irving)
     soriting a file <ramonb@data.net.mx>
     Re: soriting a file (brian d foy)
     Re: system command (Tad McClellan)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 02 Jan 1998 14:47:28 +0200
From: Bekman Stanislav <sbekman@iil.intel.com>
To: Ernie Johnson <tcm@tcmd.com>
Subject: Re: 'flock'ing
Message-Id: <34ACE1E0.167E@iil.intel.com>

> I've read some past posts on file locking and the general suggestion seems
> to be utilize flock if its available... (our program is running on a linux
> system - yes its a web app - and the server is apache)
> 
> after following some flock implemenations I set it into use, but within a
> few hours, had erased data...
> 
> my code follows this pattern:
> 
> open file
> read data
> close file
> 
> do other stuff here
> 
> open the file
> flock handle,2
> write new data
> close file
> 
 
The best is to open only once see:
 my $file = "filename";       # specify the filename to open
  open FH, "+>>$file" or die "Cannot open $file: $!";
  flock FH, 2;                 # wait for exclusive lock
  ## from here to the close FH, we have critical region
  ## be sure to minimize this time

  ## get current content
  seek FH, 0, 0;               # rewind to beginning
  my @content = <FH>;          # get current content

  <Change your @content lines here>

  ## write new list, and release file
  seek FH, 0, 0;               # rewind again
  truncate $file, 0;           # empty the file
  print FH @content;           # print the new content

  ## release file
  close FH;

  # Note that close frees flock as well !

  If you need to append do 

  open FH, "+>>$file" or die "Cannot open $file: $!";
  flock FH, 2;                 # wait for exclusive lock

  seek FH, 0, 2;                # end of file
  print FH "Anything you want to append";
  close FH;

I think I have found it on Randal's wonderfull WebTechniques Pages
http://www.stonehenge.com/merlyn/WebTechniques/


Hope this helps


______________________________________________________________________
Stas Bekman     mailto:sbekman@iil.intel.com [just another webmaster]
Home Page:      http://www.eprotect.com/stas
A must visit: 	http://www.eprotect.com/stas/TULARC (Java,CGI,PC,Linux)
Linux-il Home:  http://www.linux.org.il/


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

Date: Thu, 1 Jan 1998 21:03:22 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Benchmarking
Message-Id: <qdlh86.1h3.ln@localhost>

Mike (mhanson@arrowweb.com) wrote:
: What code do you use to make it so that you can see how much cpu usage
: and additional stuff that your perl program is taking up. 


Perl FAQ, part 3:

   "How do I profile my Perl programs?"


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


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

Date: Fri, 02 Jan 1998 01:10:05 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: bulk mail
Message-Id: <mbudash-0201980110060001@d91.pm2.sonic.net>

In article <comdog-ya02408000R0201980123100001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:

>> In article <mbudash-0101981657100001@d67.pm9.sonic.net>,
mbudash@sonic.net (Michael Budash) wrote:
>> 
>> >In article <68fd2s$3g8@bgtnsc02.worldnet.att.net>, comdog@computerdog.com
>> >(brian d foy) wrote:
>> >
>> >>> 
>> >>> sendmail questions are best asked in alt.fan.e-t-b
>> >>> 
>> >
>> >interesting...eli has his own newsgroup? guess i'll subscribe and check it
>> >out...thanks! (don't worry, brian, i'll lurk a _long_ time before i post!)
>> 
>> not only does the newsgroup exist, but it's the best place to ask
>> really sticky regular expression questions.  no need to lurk :)
>> 

see you there!

-- 
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736


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

Date: Thu, 1 Jan 1998 20:54:52 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: bulk mail
Message-Id: <stkh86.1h3.ln@localhost>

Mike (mhanson@arrowweb.com) wrote:
: If i am writing a program to send bulk email, is using sleep 1 enough
: time to make it so that i don't overload the sendmail program?


No.


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


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

Date: Thu, 1 Jan 1998 14:29:17 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: File test operators
Message-Id: <taug86.f32.ln@localhost>

Sefi Kraemer (skraemer@iil.intel.com) wrote:

: I am trying to search for files with the * operator, but am unable to do
                                           ^^^^^^^^^^

In Perl, that is the "Dereference-address operator" (described in
'perlfunc'), so I don't think you mean Perl's * operator.

I expect you mean shell filename globbing instead.

Globbing in perl is described in the 'perlop' man page that came
with your perl distribution, under the heading "I/O Operators".

'perlfunc' also describes the glob() function.



: so.
: Here is what I tried:

: push @host_list,$host if (-e "$DB_Path/$server*");


The file test operators take a filename, not a filename glob.


: I attempted to search for files just as I would with :
: ls  sun*
: So files like: sun, sun.sf, sun.ppd will show up.
: In the perl program I wish to check if such files exist.

: How can I do it?


   print "$DB_Path/$server* exists\n" if <$DB_Path/$server*>;

or, more clearly:

   print "$DB_Path/$server* exists\n" if glob("$DB_Path/$server*");


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


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

Date: Fri, 02 Jan 1998 04:21:32 -0600
From: mjforder@hotmail.com
Subject: forking in perl
Message-Id: <883735918.572325899@dejanews.com>

Can anybody tell me where I can find a nice gentle introduction to
writing perl script which use fork, wait etc. I've read some sections in
the programming perl book, and the perl reference, but I'm little foggy
on some of the concepts.

What I am trying to achieve is a perl script that will read a certain
directory every n minutes, detect any files in the dir., and then fork a
process for each file that will fax the file (via system calls to 3rd
party software). I'm assuming (perhaps foolishly) that it would be
quicker and general more efficent to do it this way, especially if there
are a lot a faxes as each fax can take up to 3-4 minutes to send
(depending on size).

Any help anyone can provide would greatly be appreciated.

Matthew Forder  -  Unix SysOp
Seagate Technology Int'l
------------------------------------------------------------------------
"You can make it foolproof, but can you make it damn foolproof?"

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Fri, 02 Jan 1998 01:11:42 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: i am a newbie
Message-Id: <mbudash-0201980111430001@d91.pm2.sonic.net>

In article <comdog-ya02408000R0201980157030001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:

>> In article <34AC8D15.3AD4@sonic.net>, star@sonic.net wrote:
>> 
>> >Could anyone explain how to make an html doc (a page on www) work with a
>> >simple program i made with perl:
>> 
>>  
>> >#!/usr/bin/perl -w
>> 
>> use CGI;
>> 
>> $input = new CGI;
>> $name = $input->param('name');
>> 
>> #>print "Hi!,what is your name?";
>> #>$name = <stdin>;
>> #>chomp $name;
>> 
>> print "Content-type: text/plain\n\n"
>> 
>> >if ($name eq "lisa"){
>> >print  "hello lisa i love you\n";
>> >} else {
>> >print "hello, $name!\n";
>> >}
>> 
>> 
>> it's that easy.  good luck :)
>> 

you just gotta love CGI.pm!

-- 
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736


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

Date: Wed, 31 Dec 1997 23:10:37 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: misterious context
Message-Id: <34AB334A.BF8EA9B7@5sigma.com>

Context is not all that complicated.  It seems like it, but it's
not.  As far as assignment statements go, the right hand side of
an assignment TO A SCALAR is a SCALAR context, and the right
hand side of an assignment TO AN ARRAY is a LIST (or ARRAY, same
thing) context.

each only returns a list in a list context.  $k = each %foo is a
scalar context.

	-joseph
	 http://www.effectiveperl.com

Cho SangWook wrote:
> 
> Hi, all!
> I'm rather new to Perl.
> The scalar and list context are somewhat confusing to me.
> I thought that I understood each context, but I failed to
> understand the following code. It originated from page 116 from
> Programming Perl book.
> 
> Suppose
> %foo = (f => 1, g => 'abc', h => 3, i => '21a');
> while ($k = each %foo) {
>     print "key = $k\n";
> }
> 
> I thought that above code had to print 1, abc, 3, 21a in random
> order. But I was wrong.
> It printed keys instead.
> "each" returns two elements list consisting of key and value pairs.
[...]


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

Date: 2 Jan 1998 09:29:49 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: need help with pattern match
Message-Id: <qz$9801020405@qz.little-neck.ny.us>

Dave Neuer  <smoothie@spiritone.com> wrote:
> to modify it so that it checks to see if the email address and homepage
> URL the user entered appear to be valid so that I don't end up with

<fx>
great big red flashing lights appear out of the ceiling and 150dB
sirens start wailing
</fx>

> broken links on my page.  The email portion works great, but so far the

I'm posting from a valid address. Checking email addresses is tricky.

> URL portion doesn't work at all.

That's also tricky.

> if ($email =~ m/.+@.+\..{2,3}/) {

You need anchoring for that to be reasonable, and it fails for .arpa
addresses (I see a bunch of those in my web logs FWIW). I saw a guy
named Pir speculate how much fun it would be to get the MX record for
the top level Iranian domain so that he could get mail at <p@ir>.
No technical reason why he couldn't do that.

>  $name_address = '<a href="mailto:' . $email . '">' . $name . '</a>';

That might not produce valid html. <fred&barney@redcat.com> comes to
mind as an address that will likely get mangled. (It's real, BTW.)

> #test to see if $page appears to be a valid URL,
> #set $page_link accordingly DOESN'T WORK YET
> 
> if ($page !~ m!^[(http://.+) | (www.*)]\..+\..{2,3}\/.+!) {
                  ^                     ^

You do not want a character class there. You meant to have:

  if ($page !~ m!^((http://.+)|(www.*))\..+\..{2,3}\/.+!) {

Again, there is no technical reason why "http://ir/" couldn't
bring up a web page denouncing American Santas or something.
Here you have the advantage over email addresses that you can
actually try it out and have a good chance of figuring out quickly
if it works or doesn't work. "http://127.1/index.html" wouldn't
pass your check (only one char after the last ".") but would
probably empirically test as true to your CGI script.

Elijah
------
<URL:http://www.qz.to/~eli/faqs/addressing.html#verify> on verifying addresses


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

Date: Fri, 02 Jan 1998 01:07:46 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Need script to preview form data prior to submitting
Message-Id: <mbudash-0201980107460001@d91.pm2.sonic.net>

In article <comdog-ya02408000R0201980121100001@news.panix.com>,
comdog@computerdog.com (brian d foy) wrote:

>> >part 2 (optional)
>> >------
>> >validate input if "confirm" or "ok" have been passed in, noting any
>> >errors. (more on these two values later)
>> 
>> this part is a really bad idea.  the user can change the data
>> in the HTML file and submit anything he likes in the field.  i don't
>> like to give the user that much flexibility.  i suggest a string of
>> CGI scripts:

i don't follow you, brian. there _is_ no "HTML file"...

-- 
Michael Budash, Owner * Michael Budash Consulting
mbudash@sonic.net * http://www.sonic.net/~mbudash
707-255-5371 * 707-258-7800 x7736


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

Date: Fri, 02 Jan 1998 05:11:17 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Need script to preview form data prior to submitting
Message-Id: <comdog-ya02408000R0201980511170001@news.panix.com>
Keywords: from just another new york perl hacker

In article <mbudash-0201980107460001@d91.pm2.sonic.net>, mbudash@sonic.net (Michael Budash) posted:

>In article <comdog-ya02408000R0201980121100001@news.panix.com>,
>comdog@computerdog.com (brian d foy) wrote:
>
>>> >part 2 (optional)
>>> >------
>>> >validate input if "confirm" or "ok" have been passed in, noting any
>>> >errors. (more on these two values later)
>>> 
>>> this part is a really bad idea.  the user can change the data
>>> in the HTML file and submit anything he likes in the field.  i don't
>>> like to give the user that much flexibility.  i suggest a string of
>>> CGI scripts:
>
>i don't follow you, brian. there _is_ no "HTML file"...


from where is the form data coming?

-- 
brian d foy                                  <comdog@computerdog.com>
Institute For the Organically-Challenged
   <URL:http://computerdog.com/brian/Institute.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Thu, 1 Jan 1998 21:19:13 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: newbie: what am i doing wrong?
Message-Id: <hbmh86.5k3.ln@localhost>

Jim Barcelona (barce@slip.net) wrote:
: jay wrote in message <34aac7f4.2255509@nntp.best.com>...

: >        if ($stat = 0) {
: Use "if($stat == 0) {".

: A common mistake that I'll often make is to take the assignment operator (in
: this case the "=") to be a logical operator like ==. To avoid this mistake,


I just use perl's -w switch so that perl will tell me when I mess up...


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


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

Date: Thu, 1 Jan 1998 20:58:38 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Okay, I should know this, but its about reading info from a file
Message-Id: <u4lh86.1h3.ln@localhost>

William Byrd (wcb4@erols.com) wrote:
: In every perl script I have written to date, I have had to read
: through an entire file for information and process it. Now I need to
: open a file and read only the second line of the file to see if it has
: the information I need, and if not, close it.

: I don't know the perl syntax, but I want to
: open (file,"<$filename");

: read $line;		# this gets discarded
: read $line;		# this is the line I readlly want

: the I check to see if my info is on that line and if not close(file)


You must always check the return value from open() calls. They may
fail to open the file you know.

   open(FILE, $filename) || die "could not open '$filename'  $!";

   <FILE>;          # read and discard one line
   $line = <FILE>;  # get the second line


: Any help would be appreciated. Please reply via e-mail as well, as I
: do not know when I will get back to this newsgroup.


I do not know when you will get the answer to your question.


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


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

Date: Fri, 02 Jan 1998 04:39:51 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl is c worsened (was: Re: word wrap routine)
Message-Id: <comdog-ya02408000R0201980439510001@news.panix.com>
Keywords: from just another new york perl hacker

In article <qz$9801020242@qz.little-neck.ny.us>, Eli the Bearded <*@qz.to> posted:


>Perl has many similar features to C, but also a syntax that is at
>once denser and more obfuscatory. There is parsing behavior in perl
>that very few people will ever master. Offhand, I suspect Randal
>himself might not know gut-feeling the output of this simple sequence:
>
>        #!/usr/bin/perl -w
>        $_ = qq ' fun \n' ;
>        s #\w+# NY PM # && s
>        / \w+ / just some new york perl hackers /xg ;
>        print ;
>        __END__

and if one thinks one knows that one, try

   #!/usr/bin/perl -w
   $_ = qq ' fun \n' ;
   s#\w+# NY PM # && s
   / \w+ / just some new york perl hackers /xg ;
   print ;
    __END__

of course, i'm assuming Elijah hasn't used control characters as
delimiters, but i could be wrong on that.  hopefully this special
case breaks syntax highlighters all over the world :)

-- 
brian d foy                                  <comdog@computerdog.com>
Institute For the Organically-Challenged
   <URL:http://computerdog.com/brian/Institute.html>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: Fri, 2 Jan 1998 10:23:45 -0000
From: "Andie Crossland" <AndieC@msn.com>
Subject: Perl Script
Message-Id: <e3DfSj2F9GA.282@upnetnews02.moswest.msn.net>

I have downloaded the PerlScript extensions to HTML pages, ran the
installation scripts and tried to go through the AspExamples without
success.

I have looked through the Perl for Win32 FAQ and have not found anything
relevant to getting PerlScript pages to run. Does anyone know where I can
get help on this?

Incidentally, I have manage to get perl scripts running as a cgi-bin.

Thanks,

Andie.




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

Date: Fri, 02 Jan 1998 04:20:33 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl Trick?
Message-Id: <comdog-ya02408000R0201980420330001@news.panix.com>
Keywords: from just another new york perl hacker

In article <34AC935B.E2E575CD@NOSPAMMING.cs.odu.edu>, Eddie Brown <eddie@NOSPAMMING.cs.odu.edu> posted:

>Besides having a java program execute a perl prog: does anyone know
>of a way of having a perl program execute as soon as a page is accessed?

depends on what a page is...

but it likely has nothing to do with Perl.  it's probably the same
answer as getting anything to execute at the right time.  there is 
probably a better newsgroup for this question. :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>


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

Date: 2 Jan 1998 11:27:32 GMT
From: lutz@tavari.muc.de (Lutz Albers)
Subject: Re: PERLIPC - FIFO: parent, child, stalled!
Message-Id: <68iiv4$6bf@morranon.tavari.muc.de>

In article <34AC7901.AD5FFF7E@highsynth.com>,
	Jihad Battikha <jbattikha@highsynth.com> writes:
> Tom Phoenix wrote:
> 
> As far as using strict, how would this help me in this script?  I'm
> using symbolic references in some variables (I have to) and 'strict'
> will choke on this.  Perhaps I'm wrong, but that's what happens when I
> 'use strict'.

You might want to use "use strict 'vars','subs'" then. It will choke on
all undeclared variables and bareword sub's which aren't declared.

ciao
  lutz
--
Lutz Albers, lutz@muc.de         
Do not take life too seriously, you will never get out of it alive.


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

Date: Fri, 02 Jan 1998 15:15:03 +0100
From: Sebastian Andersson <sa@hogia.net>
Subject: pipeing problem.
Message-Id: <34ACF667.F7F881D1@hogia.net>

I'm not a good perl programmer so I think I better ask the experts; How
do I do this in a portable way?
open(FD, "command </proc/$$/fd/0 |");

The above runs command with the same STDIN as the main perl program but
it only works under linux and only if you have the proc fs mounted under
/proc. Under other unixen you'll have to change the path some and under
some unixen there isn't a way for a child process to open the same file
descriptor as the parent via the filesystem. Non-unix systems is of no
importance in this application.

What I want is to process parts of STDIN from a perl script and then
process the rest of it via a another program (metamail) and use the
result in the perlscript.

Sebastian Andersson


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

Date: Fri, 02 Jan 1998 14:59:21 +0100
From: Jo La <jola@hem.passagen.se>
Subject: Pipes in Perl5 on Windows NT
Message-Id: <34ACF2B9.1E6E81CC@hem.passagen.se>

Hi!

I have a problem with "Pipes" in Perl5 on Windows NT 4.0 (SP3).

Examples:
This works:            echo hello | perl.exe myprog.pl
This doesn't work:     echo hello | myprog.pl
In the second example, myprog.pl is started but the 'hello' never gets
to the program.
The same goes for "myprog.pl <mytextfile.txt" which also doesn't work.

The myprog.pl program:
$myin = <STDIN>;
print $myin . "\n";

My current filetype association for Perl:
 .pl=plfile
plfile="e:\winprog\Perl\bin\perl.exe" "%1" %*

I hope this is only a problem with a setting somewhere (it works on any
of my Unix machines...)

Many thanks in advance!
Jonas.


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

Date: Fri, 02 Jan 1998 10:03:01 +0100
From: Knut Brobakken <knut@webcom.no>
Subject: Re: running perl on iis
Message-Id: <34ACAD45.88344508@webcom.no>

Check out www.activestate.com

Knut Brobakken
(knut@webcom.no)

Josh Hebert wrote:
> 
> I want to run perl on my iis3 where can I get info on how to acquire a
> version of perl for NT, an interpreter, and install info.  Thanks


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

Date: Fri, 2 Jan 1998 08:19:12 -0600
From: "Phil Jach" <pjach@erac.com>
Subject: Re: running perl on iis
Message-Id: <34acf766.0@news1.ibm.net>

Check out www.activestate.com.  They port PERL to Win32.

Josh Hebert wrote in message <01bd1717$a24724a0$928614d1@nwlink.com>...
>I want to run perl on my iis3 where can I get info on how to acquire a
>version of perl for NT, an interpreter, and install info.  Thanks
>




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

Date: Fri, 02 Jan 1998 09:06:51 -0800
From: Scott Clark <scott_clark@merck.com>
Subject: Re: Script calls embedded in web pages
Message-Id: <34AD1EAB.4B6C@merck.com>

brian d foy wrote:
> 
> In article <34AAE14C.461@merck.com>, scott_clark@merck.com posted:
> 
> > Or how about Server Side Includes (SSI) that will execute
> > /cgi-bin/scriptname.pl with the following HTML tag.  Note: Server Side
> > Includes must be configured on your webserver...
> >
> > <!-- #exec cgi"/cgi-bin/scriptname.pl" -->
> 
> does that really work?  i think you meant
> 
>    <!--#exec cgi="/cgi-bin/scriptname.pl" -->
> 
> --
> brian d foy                                 <http://computerdog.com>
> CGI_MetaFAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>

Yes I did!
<!--#exec cgi="/cgi-bin/scriptname.pl" -->
it is...
Thanks,
scottyc


       The contents of this message express only the sender's opinion.
       This message does not necessarily reflect the policy or views of
       my employer, Merck & Co., Inc.  All responsibility for the statements
       made in this Usenet posting resides solely and completely with the
       sender.


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

Date: 2 Jan 1998 03:48:28 GMT
From: "Josh Hebert" <hebert19@nwlink.com>
Subject: send mail
Message-Id: <01bd1730$d134a800$9d8614d1@nwlink.com>

I am looking for a good way to use the mail functions on an NT server
my &send_mail from the mail-lib.pl is not working.  any thoughts.



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

Date: Thu, 1 Jan 1998 21:16:20 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Simple(!) regular expression problem
Message-Id: <46mh86.5k3.ln@localhost>

Laurel Shimer (autopen@autopen.com) wrote:
: I am very embarassed that I just don't get how to do regular expressions yet...
:  Have been staring at the Camel, the Llama book and the Perl Reference
: Guidetrying to figure out how to make the following two variables match

: $reqinput ="360-WG-002 ";
: $reqmatch =" 360-WG-002";


What do you mean "make them match"?

They *don't* match. The characters are in a different order.


: I have tried both 
: if ($reqinput=~ /\b$reqmatch\b/) {print "matched\n";}
: else {print "no match\n";}
:             And
: if (/\b$reqinput\b/ =~ /\b$reqmatch\b/) {print "matched\n";}
: else {print "no match\n";}


: Obviously I really have the wrong idea here.


I'm sure I have no clue as to what it is you want to do, but I'm not
going to let a little cluelessness get in my way  ;-)

Maybe you wanted to ask: "How can I match while ignoring leading and
trailing whitespace?"

??

   if ($reqinput=~ /\s*360-WG-002\s*/) {print "matched\n";}
   else {print "no match\n";}

Or maybe you didn't want to put that leading space in $reqmatch?

Or maybe you wanted to remove any leading spaces from $reqmatch
before trying to match?

   $reqmatch =~ s/^\s+//;  # remove leading whitespace


: Pointers are much appreciated.

A description of what you want to do would be appreciated ;-)


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


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

Date: 2 Jan 1998 08:31:51 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: sockets
Message-Id: <68iq87$bkp@panix.com>

In <34ab06ff.62379399@news.mindspring.com> agsec@linenoise.org (w1re) writes:

>does anyone know where i can either find a good tutorial on sockets in
>perl (or c) or the source to an ip to ip chat or any ip to ip program?

Perl Reference: Communications
http://reference.perl.com/query.cgi?communications

-- 
Clay Irving <clay@panix.com>                  I think, therefore I am. I think? 
http://www.panix.com/~clay/


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

Date: Thu, 01 Jan 1998 15:21:46 -0600
From: "Ramon B." <ramonb@data.net.mx>
Subject: soriting a file
Message-Id: <34AC08EA.2C96ED99@data.net.mx>

Hi!!

I have a file like this:

name: xxxx
Lastname:xxxx
phone: xxx-xx
Zip: xxx

**********************
name: xxxx
Lastname:xxxx
phone: xxx-xx
Zip: xxx

********

And i need to sort it by lastname, but keeping the other records, in the
same part, the information of each person is divided by the ********

i put the info on an array, and is diveded by the *****, but i dont have
a clue, on how to sort them by lastname, and keep the other information
in the same block.

Any idea?

Thanks in advance!!

R.B.




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

Date: Fri, 02 Jan 1998 09:04:47 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: soriting a file
Message-Id: <comdog-ya02408000R0201980904470001@news.panix.com>
Keywords: from just another new york perl hacker

In article <34AC08EA.2C96ED99@data.net.mx>, ramon.b@pemail.net posted:

>I have a file like this:
>
>name: xxxx
>Lastname:xxxx
>phone: xxx-xx
>Zip: xxx

>And i need to sort it by lastname, but keeping the other records, in the
>same part, the information of each person is divided by the ********
>
>i put the info on an array, and is diveded by the *****, but i dont have
>a clue, on how to sort them by lastname, and keep the other information
>in the same block.

SHORT ANSWER:

see the wisdom in the perlfaq about sorting an array by anything. 
that answer has many good references on the subject.

LONG ANSWER:

this is probably more work than you want to do, but i would reformat the
file so that you get rid of the redundant info (the field names) and so
that all the fields for one record are on one "line" (in sed's idea of
a line at least).  the resulting record looks something like:

   fred|flinstone|555-1234|90875-1234

not only have you reduced your file size tremendously, but it's easy
to access the records, and trivial to sort from the command line if
you are so inclined.

how do you get this far?  define $/, also known as 
$INPUT_RECORD_SEPARATOR if you are using the English module,
so that you can read in a record at a time from a file (this is
often called paragraph mode or some such).  in this case 
it looks like your record separator is "\n**********************\n", 
so

   $/ = "\n**********************\n";

once you've done that, you can get records from the file:

   open FILE, "$data_file_name" or die "$!";

   while( $record = <FILE> ) #reads the entire record into $record
      {
      #do stuff with each record to extract the bits

how you choose to store the bits is up to you.  see the perldsc
for all sorts of ways.  in this example let's assume we've done
some pattern matching and captured the results in $1, $2, $3, and
$4.  instead of creating an object at this stage, let's just write
it to another file (which we already opened but i didn't show) in the 
new format:

      print OUTFILE "$1|$2|$3|$4\n";
      }

i've chosen a pipe to delimit the data, but you'll have to look at
your data requirements to see if this makes sense for you.  i like
to use a rarely used character, then disallow that character in
the data (replacing occurances as necessary.  remember to be a data
fascist!).  if the character does exist in the data, you'll need
to do something like escaping, replacing, or simply removing it.

now you should have an easily managed file which is almost
trivial to sort.  in fact, i think there is an example very
similar to this in one of the beginning chapters of the Lorises 
book [1].

of course, i would go on to create a module to interface with my
new database format.  once you have an object that represents a 
record, it's easy for you to use Perl to sort it - just compare
whichever instance variables you would like to sort on.  of
course, a nicely written SQL query would reduce your coding time
to something that allows for football games this weekend. :)

good luck :)  

[1]
sed & awk
Dale Dougherty & Arnold Robbins
ISBN: 1-56592-225-5
<URL:http://www.oreilly.com>

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
having fun with sed lately doing the same thing to databases created
by persons who passed themselves off as CGI programmers.


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

Date: Thu, 1 Jan 1998 20:31:06 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: system command
Message-Id: <ahjh86.bd3.ln@localhost>

Bigfoot Schweiz (info@bigfoot.ch) wrote:

: I actually have serious problems with Perl at the moment. Does anybody
: have an idea how I can fetch the output of a system command?


The Perl FAQ, part 8 does:

   "Why can't I get the output of a command with system()?"


: Or does anybody know how I can look( certainly with Perl) how big a file
: is?


-s file test operator is documented in the 'perlfunc' man page.

so is the stat() function.


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


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

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

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