[8655] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2272 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 7 23:07:15 1998

Date: Tue, 7 Apr 98 20:00:29 -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, 7 Apr 1998     Volume: 8 Number: 2272

Today's topics:
    Re: $value=~ s/"/\*/gi;   to translate " to * <lr@hpl.hp.com>
    Re: $value=~ s/"/\*/gi;   to translate " to * (Jason Gloudon)
        $value=~ s/\"/\*/gi;    # translate " to * doesn't work <INFO@ARKSON.COM>
    Re: $value=~ s/\"/\*/gi;    # translate " to * doesn't  <lr@hpl.hp.com>
    Re: CGI.pm passing variables into param? (Jason Gloudon)
        Easy Search Engine...? <jlovette@mhv.net>
    Re: Explicit file handling: Cannot update file (Perl fo <rootbeer@teleport.com>
    Re: File Bug in Perl of Sun-Solaris` (Martien Verbruggen)
    Re: fork() and exec() example needed please... <justin@nectar.com.au>
    Re: fork() and exec() example needed please... (Jason Gloudon)
        getpeername when invoked by inetd -- how? (Rob Tanner)
    Re: getpeername when invoked by inetd -- how? (John Stanley)
    Re: getpeername when invoked by inetd -- how? (Jason Gloudon)
    Re: Getting the subroutine name from within a sub (Martien Verbruggen)
    Re: Help! How do you use DBM Hashes in Win32? <sowmaster@juicepigs.com>
    Re: Help! How do you use DBM Hashes in Win32? <sowmaster@juicepigs.com>
    Re: Help: Sending a command to another command... <justin@nectar.com.au>
    Re: Help: Sending a command to another command... (Jason Gloudon)
        How to find modules in WinNT mitchmcc@concentric.net
    Re: MKDIR problem <rootbeer@teleport.com>
    Re: need help with references problem (Charles DeRykus)
    Re: Need help with simple for loop <rootbeer@teleport.com>
    Re: Parsing the command line <justin@nectar.com.au>
    Re: Parsing the command line (Jason Gloudon)
    Re: Parsing the command line <metcher@spider.herston.uq.edu.au>
    Re: Perl in Visual Studio <webmaster@mvrs.com>
    Re: Perl in Visual Studio <webmaster@mvrs.com>
    Re: Post - is lwp the only answer? (Michael Stillwell)
    Re: reading file permissions (Martien Verbruggen)
    Re: RMS should be invited to O'Reilly's "Free Software  <atai@zizkov.ucsd.edu>
    Re: Simple Unix Question,  ( Simple for you maybe ) <a-namsuk@microsoft.com>
        Tail-like functionality (Kees Hendrikse)
    Re: Trying to Match two lists (Tad McClellan)
    Re: Why a FAQ is irritating (was Re: How do I strip new <metcher@spider.herston.uq.edu.au>
        why does this work ???? <justin@nectar.com.au>
    Re: Win::ODBC, Using "GROUP BY" SQL to output <metcher@spider.herston.uq.edu.au>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 07 Apr 1998 17:07:40 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Matt Pryor <matt@whiterabbit.co.uk>
Subject: Re: $value=~ s/"/\*/gi;   to translate " to *
Message-Id: <352ABFCC.60E5C1A5@hpl.hp.com>

Matt Pryor wrote:
> 
> You're going to kick yourself...
> 
> Try escaping the " character with \"
> 
> That should do it.. you don't need to worry about the /i argument either
> as you're not comparing alphas.
> 
> Hope it works!
> 
> Matt
> 
> >       $value=~ s/"/\*/gi;              # translate " to *
> 
> --
> http://www.whiterabbit.co.uk/design

Huh???

I try this and have no problems whatsoever:

!#/usr/local/bin/perl -w
use strict;
use diagnostics;

my $value = 'a"b"c';

$value =~ s/"/*/g;

print $value, "\n";
__END__

and get a*b*c as expected.  One could also (better) use

$value =~ y/"/*/;

There is nothing magic about either double-quote or asterisk in those
particular contexts.  No escapes needed.

Is it possible the double-quotes aren't really in the string being
modified?

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 08 Apr 1998 02:37:08 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: $value=~ s/"/\*/gi;   to translate " to *
Message-Id: <slrn6ilohj.b65.jgloudon@manitoba.bbn.com>

Brendan Murphy <INFO@ARKSON.COM> wrote:
>Hello!
>
>I am trying to replace " by a * so that it would not mess up a form where I
>use the data ..... for some reason I cannot replace it.... I have tried
>everything except of course the right thing...
>
>      $value=~ s/"/\*/gi;              # translate " to *

This works for replacing normal quotes with *'s.
This sounds more like a misunderstanding of CGI than of perl perhaps asking
on a CGI related newsgroups would be more beneficial.

If you want to represent quotes in HTML you can use the representation
``&quot;`` as in 

 &quot;start of quote, end of quote&quot;
 to get "start of quote,end of quote"

-- 
Jason Gloudon


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

Date: Wed, 08 Apr 1998 00:42:00 GMT
From: "Brendan Murphy" <INFO@ARKSON.COM>
Subject: $value=~ s/\"/\*/gi;    # translate " to * doesn't work either
Message-Id: <sJzW.806$8%2.4223577@news.inreach.com>

Hello! Again!

I am trying to replace " by a * so that it would not mess up a form where I
use the data ..... for some reason I cannot replace it.... I have tried
everything except of course the right thing...

      $value=~ s/"/\*/gi;              # translate " to *  but doens't work
      $value=~ s/\"/\*/gi;              # translate " to *  but doens't work

Please help!

Brendan.





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

Date: Tue, 07 Apr 1998 18:06:29 -0700
From: Larry Rosler <lr@hpl.hp.com>
To: Brendan Murphy <INFO@ARKSON.COM>
Subject: Re: $value=~ s/\"/\*/gi;    # translate " to * doesn't work either
Message-Id: <352ACD95.F7CFFC9F@hpl.hp.com>

Brendan Murphy wrote:
> 
> Hello! Again!
> 
> I am trying to replace " by a * so that it would not mess up a form where I
> use the data ..... for some reason I cannot replace it.... I have tried
> everything except of course the right thing...
> 
>       $value=~ s/"/\*/gi;              # translate " to *  but doens't work
>       $value=~ s/\"/\*/gi;              # translate " to *  but doens't work
> 
> Please help!
> 
> Brendan.

Each of your tries works fine, as do each of the following cleaner ways:

$value =~ s/"/*/g;

$value =~ y/"/*/;

Unless you show more of the code that makes you think they fail, no one
will be able to help you.

Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Wed, 08 Apr 1998 02:07:32 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: CGI.pm passing variables into param?
Message-Id: <slrn6ilmq1.b65.jgloudon@manitoba.bbn.com>

ahayes@ingenia.com <ahayes@ingenia.com> wrote:
>Hi. I'm trying to get someone elses old script to make use of CGI.pm instead

Have you read the documentation within the module ?
try 'perldoc CGI.pm'. It contains examples like this.

     FETCHING THE VALUE OR VALUES OF A SINGLE NAMED PARAMETER:

         @values = $query->param('foo');

                   -or-

         $value = $query->param('foo');

-- 
Jason Gloudon


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

Date: Tue, 07 Apr 1998 20:46:37 -0400
From: Lovette <jlovette@mhv.net>
Subject: Easy Search Engine...?
Message-Id: <352AC8ED.3520@mhv.net>

What would be the best way to make a search engine?  I am working for a
local hospital and they would like me to build a search engine that
locates and highlites the text, but this is beyond my abilities.  Please
reply via e-mail


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

Date: Tue, 7 Apr 1998 17:47:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Oliver Heidelbach <oheiabbd@zedat.fu-berlin.de>
Subject: Re: Explicit file handling: Cannot update file (Perl for OS/2)
Message-Id: <Pine.GSO.3.96.980407174452.1034W-100000@user2.teleport.com>

On 7 Apr 1998, Oliver Heidelbach wrote:

>     open(LOG1, "+<$patchlog");

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.

>     while (<LOG1>) {
>        s/diffs/diff/;
>        print LOG1;            # no effect here!

Check out the FAQ's info on updating text files. Also, on many systems,
you must seek() when switching from read to write, or vice versa, even if
you're already in the right place.

Hope this helps!

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



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

Date: 8 Apr 1998 01:51:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: File Bug in Perl of Sun-Solaris`
Message-Id: <6gel6l$85k$1@comdyn.comdyn.com.au>

In article <352A44B5.5DB84B38@fastparts.com>,
	Ben Schmitz <ben@fastparts.com> writes:

> Does anyone know of a file bug for Perl 5.004_004 on Sun Solaris. 
> Basically, when i run stat on a file, i get no information from certain
> files.  None.

# perl -v
This is perl, version 5.004_04 built for sun4-solaris
# perl -e 'stat(".login") || die "Could not stat: $!"'
# perl -e 'stat("bogus") || die "Could not stat: $!"'
Could not stat: No such file or directory at -e line 1.

Did you check the return value of stat? Does the file you stat exist?
As you can see, stat() works fine on my 5.004_04 on solaris 2.5.1

Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: Wed, 08 Apr 1998 11:33:42 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: fork() and exec() example needed please...
Message-Id: <352AD3F6.C327ED81@nectar.com.au>

Michael Shavel wrote:

> Mike Shavel
>
> Ps. this is the code I am starting with, but all it seems to do is execute the
> sqr statment twice without returning the PID into $pid.
>
> $c="sqr trsdmp.sqt test/test -RT -F/export/transfer/trsdmp.lis 03/03/1998";
>
> $pid = fork();
> print "PID num id $pid \n";
> exec($c);



never do it like that, what if the fork fails ???

do something like this



if($pid=fork())
{
    exec($c);
}
wait;






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

Date: Wed, 08 Apr 1998 02:24:54 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: fork() and exec() example needed please...
Message-Id: <slrn6ilnqj.b65.jgloudon@manitoba.bbn.com>

Michael Shavel <mshavel@erols.com> wrote:
 .
 .
>Ps. this is the code I am starting with, but all it seems to do is execute the
>sqr statment twice without returning the PID into $pid. 
>
>
>$c="sqr trsdmp.sqt test/test -RT -F/export/transfer/trsdmp.lis 03/03/1998";
>
>$pid = fork();

After fork(), there are two copies of your script running, this is why you
get the output duplicated. As the manpage says, in the parent process the
return value is the PID of the child.

if($pid = fork){
   # The parent (original process) does this
   print "PID num id $pid \n";
	waitpid($pid,0);
else { 
   # The child does the exec
   exec($c) or die "Exec Failed:$!";
}

-- 
Jason Gloudon


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

Date: Tue, 07 Apr 1998 17:01:12 -0700
From: rtanner@linfield.edu (Rob Tanner)
Subject: getpeername when invoked by inetd -- how?
Message-Id: <rtanner-0704981701120001@wildflower.linfield.edu>

When writing in C, getting the peer name for the other end of a socket,
even though my program is invoked by inetd, is fairly straight forward.

In Perl, getpeername(0) returns a zero length result.  Is this, for some
reason not doable from within Perl?  Or am I missing somethin obvious?

-- Rob

      _ _ _ _           _    _ _ _ _ _    
     /\_\_\_\_\        /\_\ /\_\_\_\_\_\  
    /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
   /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
  /\/_/_/_/_/ /\_\  /\/_/    /\/_/             
 /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
 \/_/  \/_/  \/_/_/_/_/     \/_/              sounds profound)

 Rob Tanner
 Manager of Systems and Communications
 Linfield College, McMinnville, OR
 (503) 434-2558 <rtanner@linfield.edu> _____________________________________________________________________


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

Date: 8 Apr 1998 02:07:12 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: getpeername when invoked by inetd -- how?
Message-Id: <6gem4g$g25$1@news.orst.edu>

In article <rtanner-0704981701120001@wildflower.linfield.edu>,
Rob Tanner <rtanner@linfield.edu> wrote:
>In Perl, getpeername(0) returns a zero length result.  Is this, for some
>reason not doable from within Perl?  Or am I missing somethin obvious?

Something obvious. What filehandle is connected to the remote system
when running a daemon under inetd? Hint: it may be the SAME as zero by
convention under C, but C isn't perl.



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

Date: Wed, 08 Apr 1998 02:42:32 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: getpeername when invoked by inetd -- how?
Message-Id: <slrn6iloro.b65.jgloudon@manitoba.bbn.com>

Rob Tanner <rtanner@linfield.edu> wrote:
>When writing in C, getting the peer name for the other end of a socket,
>even though my program is invoked by inetd, is fairly straight forward.
>
>In Perl, getpeername(0) returns a zero length result.  Is this, for some
>reason not doable from within Perl?  Or am I missing somethin obvious?

getpeername in perl wants a socket filehandle, not the UNIX filehandle.
Try getpeername(STDIN);

-- 
Jason Gloudon


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

Date: 8 Apr 1998 01:24:23 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Getting the subroutine name from within a sub
Message-Id: <6gejk7$7v3$2@comdyn.comdyn.com.au>

In article <352A838F.AEABD242@healthpartners.com>,
	"Scott L. Erickson" <Scott.L.Erickson@HealthPartners.com> writes:
> Hello,
> 
> Is it possible for a subroutine to get its name? If so, how is this

perldoc -f caller

try something like:

#!/usr/local/bin/perl -w

use strict;

blabla();

sub blabla
{
	print STDOUT (caller(0))[3], "\n";
}

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: Tue, 07 Apr 1998 20:14:30 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: ifcl@mssite01.ion.chevron.com
Subject: Re: Help! How do you use DBM Hashes in Win32?
Message-Id: <352AC166.3ECE@juicepigs.com>

Ian Clark wrote:
> 
> How do you use DBM Hashes in Win32?
> 
> I have coded a reference as follows:
> 
> #
> # hash
> #
> dbmopen(%DDA,"ddafile",0644);
> $DDA{"ifcl"} = "Ian Clark";
> dbmclose(%DDA);
> 
> and when I run it, I get:
> 
> "Can't locate AnyDBM_File.pm at has.pl line 4."
> 
> My reference is chapter 17 of "Learning Perl on Win32 Systems" - what am
> I missing here?


It's in the FAQs.
You want to use SDBM_File and tie the hash to it.


HTH

-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: Tue, 07 Apr 1998 20:54:16 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
Subject: Re: Help! How do you use DBM Hashes in Win32?
Message-Id: <352ACAB8.688F@juicepigs.com>

Oopsm this is not in the standard PERLFAQs but explained in one of the
perl32 FAQs located at:

http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html



Bob Trieger wrote:
> 
> Ian Clark wrote:
> >
> > How do you use DBM Hashes in Win32?
> >
> > I have coded a reference as follows:
> >
> > #
> > # hash
> > #
> > dbmopen(%DDA,"ddafile",0644);
> > $DDA{"ifcl"} = "Ian Clark";
> > dbmclose(%DDA);
> >
> > and when I run it, I get:
> >
> > "Can't locate AnyDBM_File.pm at has.pl line 4."
> >
> > My reference is chapter 17 of "Learning Perl on Win32 Systems" - what am
> > I missing here?
> 
> It's in the FAQs.
> You want to use SDBM_File and tie the hash to it.
> 
> HTH
> 
> --
> Bob Trieger               |  Titanic: big boat, bigger
> sowmaster@juicepigs.com   |           iceberg, big deal

-- 
Bob Trieger               |  Titanic: big boat, bigger
sowmaster@juicepigs.com   |           iceberg, big deal


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

Date: Wed, 08 Apr 1998 11:32:15 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: Help: Sending a command to another command...
Message-Id: <352AD39F.A38F9570@nectar.com.au>

>
>
> The system would return the HTML file "index.html" on the screen.
>
> Now, how do you send the "Get...." part to the telnet command when
> using perl's "system" function.
>
> I've been dewelling on this matter for a long time already.  If you can
> help me out, I'll be very grateful.
>
> Thank you.  I've already sent off for the book,"Web Client Programming"
> , upon a poster's suggestion.
>
> -Khai

use something like this, only save the output ( I can't remember off the
top of my head)


>   #!/bin/perl
>   use LWP::UserAgent;
>
>   $ua = new LWP::UserAgent;
>   $server="IP.Details.of.your.server.here";
>   $req = new HTTP::Request 'GET' => "$server";
>   $req->header('Accept' => 'text/html');
>   $res = $ua->request($req);
>   if ($res->is_success)
>   {
>    print("Hey! $server is alive and working!!!\n");
>   }
>






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

Date: Wed, 08 Apr 1998 02:31:09 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: Help: Sending a command to another command...
Message-Id: <slrn6ilo6d.b65.jgloudon@manitoba.bbn.com>

KHAI <khn@engr.uark.edu> wrote:
 .
 .
>Now, how do you send the "Get...." part to the telnet command when
>using perl's "system" function.

You cannot do this with system(). At worst you could use IPC::Open2() or
better you can use the LWP modules that will allow you to make HTTP requests.

http://www.perl.com/CPAN-local//modules/by-module/LWP.

-- 
Jason Gloudon


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

Date: Tue, 07 Apr 1998 19:34:04 -0600
From: mitchmcc@concentric.net
Subject: How to find modules in WinNT
Message-Id: <6geglt$m2o$1@nnrp1.dejanews.com>

I just installed Perl on my WinNT WS 4.0.  When I try
to run a test program which loads a library/module,
I get the following error:

Can't locate Getopt/Std.pm in @INC at test2.pl line 1.
BEGIN failed--compilation aborted at test2.pl line 1.

My program is simply

use Getopt::Std;

if ($opt_h eq 1) {
        $usage();
        exit 0
}

My PATH environment variable is set to:

PATH=C:\WINNT\system32;C:\WINNT;C:\NTRESKIT;C:\NTRESKIT\Perl;c:\perl\bin;c:\pe
rl\lib

What do I have to do to get Perl to find the library?

THanks in advance,

Mitchell McConnell

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


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

Date: Tue, 7 Apr 1998 17:41:57 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gabor <gabor@vmunix.com>
Subject: Re: MKDIR problem
Message-Id: <Pine.GSO.3.96.980407173416.1034U-100000@user2.teleport.com>

On 7 Apr 1998, Gabor wrote:

> # mkdir($dir, 777);
> 
> change it to 
> mkdir $dir, 511;

Hmmm... That's bad. Why? Because your maintenance programmer may think you
meant 0511! If you do decide to write it in decimal, use a comment to
clarify. 

    "A program is written for the computer to interpret, and for the human
    to interpret as well. We hope that they will agree on its meaning!"

Hope this helps! 

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



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

Date: Tue, 7 Apr 1998 20:27:42 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: need help with references problem
Message-Id: <Er28u6.8A0@news.boeing.com>

In article <352A83CE.1A8BD45D@aig.com>, Vic Parekh  <vic.parekh@aig.com> wrote:
 > I can do this:
 > 
 > $entry->{'blahblah'}[0]
 > $entry->{'blahblah'}[1]
 > and get valid entries for both
 > 
 > I need to figure out how to loop through 'blahblah' to pull out all of
 > them, meaning $entry{'blahblah'}[n] A foreach type loop, if you will.
 > 
 > Can someone please provide some guidance? I have gone through the blue
 > camel book, and the websites.
 > 
 > 

One way:   foreach my $elem (@{$entry->{'blahblah'}}) {

HTH,
--
Charles DeRykus 




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

Date: Tue, 7 Apr 1998 17:44:05 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Patrick E Mcknight <pem@U.Arizona.EDU>
Subject: Re: Need help with simple for loop
Message-Id: <Pine.GSO.3.96.980407174247.1034V-100000@user2.teleport.com>

On Tue, 7 Apr 1998, Patrick E Mcknight wrote:

> for ($i = 1, $i < 46, $i++) {

That's a foreach loop "in disguise", with three elements over which to
iterate. Did you mean to use semicolons instead of commas? That would give
a for (;;) loop. Hope this helps! 

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



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

Date: Wed, 08 Apr 1998 11:36:09 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: Re: Parsing the command line
Message-Id: <352AD489.A7232A46@nectar.com.au>

use Getopt::Std;

getopts('aBcdeh0:');



Andrew F. Lee wrote:

> Hello:
>
> I keep getting this wrong and I searched the Perl faq.  Perhaps I missed
> it.  But, once and for all, what is a nifty way to parse options
> passed to your program?  Something about closures comes to mind, but if
> someone has an example I'd be saved a reinvention of the wheel.
>
> e.g.  foo.pl -h gives:
>
> usage:  foo.pl [-aBcdehl] input-file [[-o output-file | command]]
>
> User gives me "foo.pl -el bar.txt -o bar.html" and I go do something
> clever.





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

Date: Wed, 08 Apr 1998 02:13:47 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: Parsing the command line
Message-Id: <slrn6iln5p.b65.jgloudon@manitoba.bbn.com>

Andrew F. Lee <andrewf@cp.pathfinder.com> wrote:
>Hello:
>
>I keep getting this wrong and I searched the Perl faq.  Perhaps I missed
>it.  But, once and for all, what is a nifty way to parse options
>passed to your program?  Something about closures comes to mind, but if
>someone has an example I'd be saved a reinvention of the wheel.

Getopt::Std or Getopt::Long. Check your perl installation or look in CPAN at
www.perl.com/CPAN/.

-- 
Jason Gloudon


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

Date: Wed, 08 Apr 1998 12:17:11 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Parsing the command line
Message-Id: <352ADE27.1B5BBCD2@spider.herston.uq.edu.au>

I believe there's a module called GetOpts or something similar (none of
my scripts are clever enough to need it :-(  )

-- 
Jaime Metcher

Andrew F. Lee wrote:
> 
> Hello:
> 
> I keep getting this wrong and I searched the Perl faq.  Perhaps I missed
> it.  But, once and for all, what is a nifty way to parse options
> passed to your program?  Something about closures comes to mind, but if
> someone has an example I'd be saved a reinvention of the wheel.
> 
> e.g.  foo.pl -h gives:
> 
> usage:  foo.pl [-aBcdehl] input-file [[-o output-file | command]]
> 
> User gives me "foo.pl -el bar.txt -o bar.html" and I go do something
> clever.
> 
> Thanks in advance.
> 
> -------------------------------------------------------------
> Andrew F. Lee                 |                              |
> Software Engineer             |  parenttime.com              |
> email: andrewf@pathfinder.com |  1271 Avenue of the Americas |
> Phone: (212) 522-2769         |  New York, N.Y. 10020        |
> -------------------------------------------------------------
>         When I say, "Ignore the man behind the curtain."
>         That is because there is no man behind the curtain.


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

Date: Tue, 07 Apr 1998 16:58:01 -0700
From: ADR Webmaster <webmaster@mvrs.com>
Subject: Re: Perl in Visual Studio
Message-Id: <352ABD89.51926758@mvrs.com>

Kevin B Cohen wrote:

> if you find one, please let the rest of us know... have you tried
> creating perl scripts with the extension .cpp?

Yeah, and the results are what you'd expect...lame. =( 

Maybe I can cook something up w/ VBscript. Thanks for the idea, though.

	-/matt/-

p.s. - I figure at some point Perl will end up in the Visual Studio.
Maybe I'll just have to wait for that. (I can just see the MS ads now:
"New! It's Visual Perl ...embraced and extended for Windows". Yeah.)


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

Date: Tue, 07 Apr 1998 17:30:55 -0700
From: ADR Webmaster <webmaster@mvrs.com>
Subject: Re: Perl in Visual Studio
Message-Id: <352AC53F.B2A411D7@mvrs.com>

Warren Jones wrote:
> Take a look at Vim, a much-enhanced VI clone.
<snip>
>     o Vim provides syntax coloring for Perl.
> 
>     o Vim can be integrated with Visual Studio as your default editor.
<snip>
> For use with Visual Studio, you should get gvim51ole.zip.  Enjoy!

	Thanks! I'll look into it.

	-/matt/-


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

Date: 8 Apr 1998 00:09:52 GMT
From: mist@yoyo.cc.monash.edu.au (Michael Stillwell)
Subject: Re: Post - is lwp the only answer?
Message-Id: <slrn6ilg2d.g00.mist@fangorn.cs.monash.edu.au>

On Mon, 06 Apr 1998 10:01:09 -0700, Marcia L Sussman <pi83@dial.pipex.com> wrote:
: Sorry I was so vague -
: I have a search engine which will only accept POST data.
: I have a form for this on Yahoo, but they now tell me
: that they will only send out GET data.
: Therefore I need to write a Perl routine to take the incoming
: GET query string and send it to our database POST.
: I know that the lwp module will do this, but our host
: wont/can't let me install it...

I have some scripts for doing this but they require LWP, although it
should be possible to rewrite them to avoid using LWP without much
trouble.  However, you can run them via

    http://yoyo.cc.monash.edu.au/~mist/get2post/

if this helps.  Source is available from 
 
    http://yoyo.cc.monash.edu.au/~mist/perl/

You could try something like

    echo $QUERY_STRING | lynx -post_data http://whatever.com

Michael

-- 
 .. ABSOLUT .SIG. ..
 .. Michael Stillwell ..
 .. mist@yoyo.cc.monash.edu.au ..
 .. http://yoyo.cc.monash.edu.au/~mist/ ..


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

Date: 8 Apr 1998 01:08:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: reading file permissions
Message-Id: <6geim5$7v3$1@comdyn.comdyn.com.au>

In article <3529F83B.3E@mediaone.net>,
	Sneaker's Nest <sneaker@mediaone.net> writes:

> After I posted the backticked `ls` possibility, I wondered how far the
> stat command can be taken to get get owner/group/other break-downs...

Exactly as far as ls. ls uses stat to get at that information in the
first place. The last number corresponds to the last three letters,
and is an AND of the following:

	x	0001
	w	0002
	r	0004

Thus,
	
	mode	visual
	0644	-rw-r--r--
	0775	-rwxrwxr-x

(The first digit is reserved for other mode changes, see the chmod(1)
man page on your system.)

> Plus I knew stat prolly was platform specific and wouldn't give positive
> feed back on certain systems.

You might be surprised by this, but stat is LESS system specific than
ls. ls even differs between unices, while stat is much more portable
(especially under perl). Indeed, there are certain platforms that
don't have a stat system call, and where perl doesn't implement an
equivalent (on NT I think perl does provide something meaningful), but
those systems almost certainly also don't have ls.

A general rule of thumb: A call to internal perl functions is more
portable, faster and more reliable than spawning an external process.
Try to avoid external programs if at all possible.

I have never been disappointed by following that rule.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm just very selective about what I
Commercial Dynamics Pty. Ltd.       | accept as reality - Calvin
NSW, Australia                      | 


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

Date: 07 Apr 1998 00:45:11 -0700
From: Andy Tai <atai@zizkov.ucsd.edu>
Subject: Re: RMS should be invited to O'Reilly's "Free Software Summit"
Message-Id: <edzphyf52w.fsf@zizkov.ucsd.edu>

Don Bashford <bashford@gage.scripps.edu> writes:

> Andy Tai <atai@tyrell.ucsd.edu> writes:
> 
> > Mr. Tim O'Reilly will host a "Freeware Summit" 
>
> > but noteably
> > absent from the list is Richard Stallman....
> > 
> > I think we should write to Mr. O'Reilly (tim@oreilly.com) asking him
> > to reconsider.... 
> 
> Not so fast!  It may be that RMS was invited but turned it down.
> Do you really know?  ...

Mr. Tim O'Reilly said that RMS was not invited.  I consider this is
unfair to GNU.


-- 
Li-Cheng Tai (Andy Tai)                       e-mail: atai@ece.ucsd.edu

Free software:  the software by the people, of the people and for the people,
worldwide.  Develop! Share! Enhance! And enjoy!


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

Date: Tue, 7 Apr 1998 17:59:59 -0700
From: "Namsuk Kim" <a-namsuk@microsoft.com>
Subject: Re: Simple Unix Question,  ( Simple for you maybe )
Message-Id: <6geigh$b7s@news.microsoft.com>

Try @variable = `ls -l`

I think this is what you meant.

Tad McClellan wrote in message ...
>UNIXstuff (unixstuff@aol.com) wrote:
>
>: From with a perl script.
>: I want to run the UNIX command ls -l
>: and have the info/string stored in a variable.
>
>: If I do
>: $MY_VARIABLE = system (ls -l);
>                 ^^^^^^
>
>The very first paragraph of the description of system() in the
>'perlfunc' man page says how to capture the output of a command.
>
>
>You didn't even try to read about system(), did you?
>
>That's Not Good.
>
>Please try and be a responsible Usenet citizen in the future.
>
>
>   $my_variable = `ls -l`;
>

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




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

Date: Tue, 7 Apr 1998 23:37:10 GMT
From: kees@echelon.nl (Kees Hendrikse)
Subject: Tail-like functionality
Message-Id: <Er2HLy.Hw4@echelon.nl>

I'm looking for a way to add unix-like tail functionality to a perl
script. As I'm only interested in the last 10-20 lines of output, I
now run 'perlscript largfile | tail', which implies perl is doing a
lot of work for nothing. 'tail largfile | perlscript' is not the way
to go, because all the data in largefile is used in the caclualtions.
In need the tail 'halway' inside the script, without buffering lots
of data. Any suggestions?
-- 
Kees Hendrikse                               | email:     kees@echelon.nl
                                             | web:        www.echelon.nl
ECHELON consultancy and software development | phone: +31 (0)53 48 36 585
PO Box 545, 7500AM Enschede, The Netherlands | fax:   +31 (0)53 43 37 415


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

Date: Tue, 7 Apr 1998 17:56:40 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Trying to Match two lists
Message-Id: <8vaeg6.5u7.ln@localhost>

Lee Falkenhagen (falkenl@hotmail.com) wrote:
: I have two lists of data that I have to match.  I want to make sure that
: for every value in List A, this is a corresponding value in List B with the
: same date as the rest of values in List A.

: List A(array)	List B (list of files in directory)

: KC101		980402.KC101
: KC102		980402.KC102
: KC103		980402.KC103
: 		980403.KC101
: 		980403.KC102

: Since no match occurs on 980403 for KC103, I do not want to do any more
: processing on it.  I am thinking that my result set should be the list of
: dates.

: Any help would be appreciated.


----------------------------------
#!/usr/bin/perl -w

@a = qw(KC101 KC102 KC103);
$a = join '|', @a;    # make a pattern that matches anything in @a

@b = qw(980402.KC101 980402.KC102 980402.KC103 980403.KC101 980403.KC102);
foreach (@b) {
   $dates{$1} = 1 if /^(\d+)\./; # get a unique list of dates
}

foreach $date (sort keys %dates) {
   $count = grep /^$date\.($a)$/, @b;

   if ($count == @a)
      {print "$date matched\n"}
   else
      {print "$date NOT matched\n"}
}
----------------------------------


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


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

Date: Wed, 08 Apr 1998 11:15:37 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Why a FAQ is irritating (was Re: How do I strip newlines from a var)
Message-Id: <352ACFB9.3EF689A9@spider.herston.uq.edu.au>

Lloyd Zusman wrote:
snip
> 
> Not every usenet poster gets this "booklet" when first firing up their
> newsreader.
> 
> And I know from first-hand experience that many, many people who first
> start browsing newsgroups see "news.announce.newusers" and haven't the
> faintest idea that they should go there and read what that group
> contains.
> 
snip

Guys, we're working in the dark here.  We need to attach a questionnaire
to the AutoFAQ - something like:

                         strongly agree : agree : disagree : strongly
disagree
I am a newbie:
I know what the FAQ is:
I know where the FAQ is:
I have read the FAQ:
I am aware of
news.announce.newusers:
I am a KLB:
I think you perl
gurus can eat me:

and so on.

-- 
Jaime Metcher


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

Date: Wed, 08 Apr 1998 11:43:23 +1000
From: Justin Wills <justin@nectar.com.au>
Subject: why does this work ????
Message-Id: <352AD63B.89442FB0@nectar.com.au>

I can't see why this works on my linux 2.x system.  anybody shed any
light on it ???
if I use $$ in the sig_handler function, my rsh is still running.  if I
use $pid ( which is definitely unset), the script and the rsh die.  I
want the rsh to die, but can't see why this works.


#!/usr/bin/perl

use POSIX;      # for signal handling

trap_signals();
alarm 6;
system("rsh @ARGV");

exit;


sub trap_signals
{
    # use posix sigaction, etc to trap SIGALRM and run the sig_handler
function
}


sub sig_handler
{

    my($signal)=shift;

    return if ($signal!~/ALRM/i);

    # $pid is not set.  if I use
     kill 9, $pid
    exit(1);

}



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

Date: Wed, 08 Apr 1998 12:11:38 +1000
From: Jaime Metcher <metcher@spider.herston.uq.edu.au>
Subject: Re: Win::ODBC, Using "GROUP BY" SQL to output
Message-Id: <352ADCDA.CB7B119F@spider.herston.uq.edu.au>

Hi Laura

So you *are* getting the records out in the correct, grouped order?  And
you know how to iterate over them with (let me see..) something like:

#!/usr/bin/perl -w  
#Ha, ha...Win32

use strict;

unless (my $db = new Win32::ODBC("Some dsn name")) die "Can't open dsn:
$!";

# Note that I've added the "as countid", as I'm not sure how to refer to
this 
# field otherwise.
my $sql = <<END_SQL;
SELECT Count(ReportID) as countid, ServerName,
 ReportName, WeekEnd, ReportPath
 FROM Reports
 GROUP BY ServerName, ReportName,
 WeekEnd
 HAVING ServerName IN ($serverlist) AND WeekEnd>=#$selected_date#;
END_SQL

$db->Sql($sql) && die $db->Error();

my ($saved_server_name, $saved_report_name);

while ($db->FetchRow()) {
   my ($countid,  $server_name, $report_name, $weekend, $report_path) =
    $db->Data("countid", "ServerName", "ReportName", "Weekend",
"ReportPath");
 
   # I'm assuming you knew everything up to here.  Next comes the bit
which lets you
   # group the output.  The idea is to keep an eye on $server_name and
   # $report_name, and do things when they change.
   if ($server_name ne $saved_server_name) then {

      # This test evaluates false the first time, to avoid ending
sections
      # we haven't started
      if ($saved_server_name) {  
         end_report_name ($report_name);   
         end_server_name ($server_name);
      }
      
      $saved_server_name = $server_name;
      $saved_report_name = $report_name;
      start_server_name ($server_name);
      start_report_name ($report_name);
   }

   if ($report_name ne $saved_report_name) then {
      $end_report_name ($report_name);
      $saved_report_name = $report_name;
      start_report_name ($report_name);  
   }   

   print_detail ($weekend, $report_path);  # as Microsoft Access would
call it
}

# These output subs are down here to keep the main logic clear, not
because they
# should necessarily be subroutines.  Put anything you like here.
sub start_server_name {
   print "Server name: ", shift, "\n";
}

sub start_report_name {
   print "   Report name: ", shift, "\n";
}

sub end_server_name {
   # print "So long from ", shift, "\n";
}

sub end_report_name {
   # print "Another report name bites the dust\n";
}

sub print_detail {
   my ($weekend, $report_path) = @_;
   print "      Report path for $weekend is $report_path.\n";
}

__END__

I haven't compiled, run, or tested any of this, partly because I'm too
lazy and partly because I don't have a suitable database handy. 
Besides, the next post will no doubt have a format and 2.7 bytes of code
that do the same thing.

-- 
Jaime Metcher

webmistress@chicweb.com wrote:
> 
> Greetings :
> 
> I would think that it would be really easy to output the
> results of an SQL
> like the following :
> SELECT Count(ReportID), ServerName,
> ReportName, WeekEnd, ReportPath
> FROM Reports
> GROUP BY ServerName, ReportName,
> WeekEnd
> HAVING ServerName IN ($serverlist) AND WeekEnd>=#$selected_date#
> 
> The
> output of the query is correct meaning that I get the correct query data
> in
> the correct order, but I find no easy way to output the information in
> the
> manner that would make sense.
> 
> Here's what I want to output :
> 
> <loop over
> all ServerNames in $serverlist>
> ServerName
>   <loop over all ReportNames for
> ServerName>
>   ReportName
>   <loop over all WeekEnd dates for ReportName>
> 
> ReportPath for WeekEnd
>   </end loop over all WeekEnd dates for ReportName>
> 
> </end loop over all ReportNames for ServerName>
> </end loop over all
> ServerNames>
> 
> So you can see, the innermost loop should loop around for all
> of the
> ReportPath for WeekEnd for that ReportName, the next loop should
> loop
> around for all of the ReportNames for that ServerName, and the
> outermost loop
> should loop around for all of the ServerNames in the list.
> 
> I do a lot of
> this stuff in Cold Fusion and it's very easy to use a "GROUP BY"
> in the
> <OUTPUT> tag but I don't see anything similar for Win::ODBC. I can
> see I
> could do it by checking for 1. check for unique server name and
> looping, 2.
> check for unique ReportName and looping and
> 3. output all ReportPath for
> Weekend but this seems harder than
> it should be.
> 
> Maybe there is a trick
> using Win::ODB I don't know about. Does anyone
> have any ideas?
> 
> Thanks in
> advance. Laura
> 
> ps I thought I'd put "URGENT MESSAGE" in the subject but
> thought better
> of it when I saw the thread on the group. hahahaha
> 
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

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

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