[17852] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 12 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 7 21:05:39 2001

Date: Sun, 7 Jan 2001 18:05:06 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978919506-v10-i12@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 7 Jan 2001     Volume: 10 Number: 12

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
        Advanced HTML/DHTML, Perl, JavaScript, VBScript, Flash, (David)
    Re: Could I remotely zip a file before I get it by FTP (Abigail)
    Re: Formatting numbers inside perl-generated html <tony_curtis32@yahoo.com>
    Re: Microsoft access <michael@NOSPAM.vilain.com>
    Re: multiple setCookies <sarbayo@telis.org>
    Re: Newbie question on Subs <hafateltec@hotmail.com>
    Re: Newbie question on Subs <hafateltec@hotmail.com>
    Re: Newbie question on Subs <jhelman@wsb.com>
    Re: Newbie question. <hafateltec@hotmail.com>
    Re: Reposting - Pattern match in an array of strings <johnlin@chttl.com.tw>
    Re: Syntac of passing a hash to a subroutine? <s2mdalle@titan.vcu.edu>
    Re: Syntac of passing a hash to a subroutine? <jhelman@wsb.com>
        What am I doing wrong with 1st line sandywadkins123@my-deja.com
    Re: What am I doing wrong with 1st line <johngros.NOSPAM@bigpond.net.au>
    Re: What do you call the => operator? <uri@sysarch.com>
    Re: What do you call the => operator? (Abigail)
    Re: xs trouble on Win32 (building Win32::API) <randy@theory.uwinnipeg.ca>
    Re: xs trouble on Win32 (building Win32::API) <apankow@next-wave.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 07 Jan 2001 11:20:54 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage978866645.5746@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

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


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

Date: 7 Jan 2001 21:49:44 GMT
From: david_xia@yahoo.com (David)
Subject: Advanced HTML/DHTML, Perl, JavaScript, VBScript, Flash, ASP and XML Books For Sale
Message-Id: <Xns90228D679AB73davidxiayahoocom@129.46.64.77>

Advanced HTML/DHTML, Perl, JavaScript, VBScript, Flash, ASP and XML Books 
For Sale
All books are Brand New.


"HTML 4 for the World Wide Web Visual Quickstart Guide"
by Elizabeth Castro
Paperback - 384 pages 4th edition (January 15, 2000) 
Peachpit Press; ISBN: 0201354934 
Asking $12

"Platinum Edition Using HTML 4, XML, and Java 1.2"
by Eric Ladd, Jim O'Donnell
Hardcover - 1282 pages Bk&Cd Rom edition (December 1, 1998) 
MacMillan Publishing Company; ISBN: 078971759X 
Asking $40

"JavaScript Bible"
by Danny Goodman, Brendan Eich
Paperback - 1015 pages 3rd Edition edition (March 1998) 
IDG Books Worldwide; ISBN: 0764531883 
Asking $30

"Flash 4 Magic" with CD
by David J. Emberton, J. Scott Hamlin, David Emberton
Textbook Binding - 325 pages Bk&Cd Rom edition (January 2000) 
New Riders Publishing; ISBN: 0735709491 
Asking $30

"Flash 4 Creative Web Animation" with CD
by Derek Franklin, Brooks Patton
Paperback - 352 pages 1st edition (January 15, 2000) 
Peachpit Press; ISBN: 0201354705 
Asking $25

"Visual InterDev 6 Unleashed"
by Paul Thurrott, Paul Thurrott et al., Brad Jones
Paperback - 1090 pages Bk&Cd Rom edition (April 23, 1999) 
Sams; ISBN: 067231262X 
Asking $30

"Programming Web Components" with CD
by Reaz Hoque, Tarun Sharma
Paperback - 810 pages Bk&Cd Rom edition
McGraw Hill; ISBN: 0079123163
Asking $40

"Dynamic Html : The Definitive Reference"
by Danny Goodman
Paperback - 1073 pages (August 1998) 
O'Reilly & Associates; ISBN: 1565924940 
Asking $30

"Dynamic Html in Action" with CD
by Eric M. Schurman, William J. Pardi
Paperback - 497 pages 2nd Bk&cdr edition (March 1999) 
Microsoft Press; ISBN: 0735605637 
Asking $22

"Professional Active Server Pages 3.0"
by Alex Homer, David Sussman, Brian Francis, George Reilly, Esposito,
   Dino Esposito, Andrea Chiarelli, Bill Kropog, Craig McQueen, 
   Godfrey Nolan, Simon Robinson, John Schenken, Kent Tegel
Paperback - 1277 pages 3rd edition (September 1999) 
Wrox Press Inc; ISBN: 1861002610 
Asking $40

"ASP/MTS/ADSI Web Security" with CD
by Richard Harrison
Paperback - 450 pages 1 edition (March 11, 1999) 
Prentice Hall; ISBN: 0130844659 
Asking $35

"Developing Asp Components"
by Shelley Powers
Paperback - 490 pages 1st edition (July 15, 1999) 
O'Reilly & Associates; ISBN: 1565924460 
Asking $20

"ASP in a Nutshell: A Desktop Quick Reference"
by A. Keyton Weissinger
Paperback; O'Reilly & Associates
Asking $10

"ADO 2.1 Programmer's Reference"
by David Sussman, Alex Homer
Mass Market Paperback - 607 pages 2 edition (June 1999) 
Wrox Press Inc; ISBN: 1861002688 
Asking $15

"Professional ADO 2.5 RDS Programming with ASP 3.0"
by John Papa
Mass Market Paperback - 819 pages 2nd edition (February 2000) 
Wrox Press Inc; ISBN: 1861003242
Asking $30

"XML Bible" with CD
by Elliotte Rusty Harold
Paperback - 1015 pages Bk&Cd Rom edition (July 1999) 
IDG Books Worldwide; ISBN: 0764532367 
Asking $30

"Building Professional Web Sites with the Right Tools: Build It With Visual 
Studio 6, FrontPage, Active Server Pages, VBScript, JavaScript, ADO, Paint 
Shop Pro, and Image Composer"
by Jeff Greenberg, J. R. Lakeland
Paperback - 576 pages 1 edition (August 10, 1999) 
Prentice Hall; ISBN: 0130843172 
Asking $30

"Administering IIS4"
by Mitch Tulloch
Paperback - 608 pages (May 29, 1998) 
Computing McGraw-Hill; ISBN: 0070655367 
Asking $25

"Learning Vbscript" with CD
by Paul Lomax, Ronald Petrusha (Editor)
Paperback - 640 pages Bk&Cd-Rom edition (October 1997) 
O'Reilly & Associates; ISBN: 1565922476 
Asking $25

"Learning Perl"
by Randal L. Schwartz, Tom Christiansen, Larry Wall (Foreword)
Paperback - 302 pages 2nd edition (July 1997) 
O'Reilly & Associates; ISBN: 1565922840 
Asking $15

"Programming Perl"
by Larry Wall, Tom Christiansen, Randal L. Schwartz, Stephen Potter
Paperback - 645 pages 2nd edition (October 1996) 
O'Reilly & Associates; ISBN: 1565921496 
Asking $25

"Perl Cookbook"
by Tom Christiansen, Nathan Torkington, Larry Wall
Paperback - 794 pages 1 Ed edition (August 1998) 
O'Reilly & Associates; ISBN: 1565922433 
Asking $25

"Programming the Perl DBI"
by Alligator Descartes, Tim Bunce
Paperback - 346 pages (February 2000) 
O'Reilly & Associates; ISBN: 1565926994 
Asking $25


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

Date: 8 Jan 2001 00:12:44 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Could I remotely zip a file before I get it by FTP
Message-Id: <slrn95i1fs.9u.abigail@tsathoggua.rlyeh.net>

Monte Phillips (montep@hal-pc.org) wrote on MMDCLXXXVI September MCMXCIII
in <URL:news:3a58971f.24713556@news.hal-pc.org>:
)) On 7 Jan 2001 10:27:55 GMT, abigail@foad.org (Abigail) wrote:
)) 
)) >Monte Phillips (montep@hal-pc.org) wrote on MMDCLXXXV September MCMXCIII
)) >in <URL:news:3a57781a.20805036@news.hal-pc.org>:
)) >^^ On 6 Jan 2001 18:54:07 GMT, abigail@foad.org (Abigail) wrote:
)) >^^ 
)) >^^ >Regent Linus (wstsoi@netvigator.com) wrote on MMDCLXXXV September
)) >^^ >MCMXCIII in <URL:news:937egf$kpg3@imsp212.netvigator.com>:
)) >^^ >^^ How could perl do this?
)) >^^ >
)) >^^ >There are various ways. You could use UUCP to give a remote command.
)) >^^ >Or you could NSF mount the drive the file is on, then zip it. Or
)) >^^ >install (write?) an FTP server that zips on the fly. Perl doesn't
)) >^^ >really play much of a role in all of this though.
)) >^^ >Abigail
)) >^^ 
)) >^^ I beg your pardon?  why not system() and zip or tarball the thing?
)) >
)) >
)) >And which command do you propose to use for this zipping on a remote
)) >system?
)) >Abigail
)) 
)) For crying out loud! If the OP wants to compress and transfer a file
)) from a remote location it is assumed (by optimists) that the OP is
)) intelligent enough to know they would need certain permissions on that
)) remote system.  If they are so ignorant of that, then whats the point
)) of wasting any bandwidth telling them anything at all?
)) 
)) And except for your natural perversity and perpetual PMS, you would
)) have pointed that out to the guy.  Albeit I admit that if he were so
)) aware of the permissions issue, then he would also be expected to
)) know about such things as tar, gzip, pkzip or wahtever compression
)) program resides on the remote system.
)) 
)) Or are you telling me that you could not run a script remotely that
)) would call tar?


What do you think my first suggestion does?



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'


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

Date: 07 Jan 2001 13:41:25 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Formatting numbers inside perl-generated html
Message-Id: <877l47b15m.fsf@limey.hpcc.uh.edu>

>> On Wed, 03 Jan 2001 11:22:04 -0600,
>> "Daniel J. Brill" <brill@hfhmn.org> said:

> I'm writing a script that keeps track of inventory.  For
> example, I want to print out $round_total as
> $1,234,567.89, instead of $1234567.89.  How would I get
> the commas in place in this block of html?

"perldoc -q comma" has this as its second match.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Sun, 07 Jan 2001 17:50:59 -0800
From: "Michael Vilain <michael@NOSPAM.vilain.com>"
Subject: Re: Microsoft access
Message-Id: <michael-9A29BE.17505907012001@news.nanospace.com>

In article <3A58B86D.B9359E54@home.nl>, AvA <a.v.a@home.nl> wrote:

> jtjohnston wrote:
> ...
> >
> > open(QUESTIONSFILE, "$datafile") || die "I can't open $datafile\n";
> >  @Questions = <QUESTIONSFILE>;
> >  close QUESTIONSFILE;
> >
> >   foreach $ThisQuestion (@Questions)
> >   {
> >   @TempData = split (/\|\|/, $ThisQuestion);
> >   print "<TR>\n";
> 
> use : print "<TR><br>"; #instead of \n -> i presume that ur using it in a
> html context
> 
> >   print "<TD><B>$TempData[0]</B></TD><TD
> > COLSPAN=2><B>$TempData[1]</B></TD>";
> >   print "</TR>\n";

I think the salient part of this question is "how do I connect to a M$ 
Access database file and scan through it?"  or better yet "How do I 
connect to a M$ Access database and make queries and updates to it?"

I don't know if there's a DBI module for it, which would be useful to
have if it exists.  I haven't seen one in CPAN.

-- 
Michael Vilain
Certified Advanced Rolfer(r)
rolfer@vilain.com
http://www.vilain.com


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

Date: Sun, 07 Jan 2001 22:31:26 GMT
From: steve a <sarbayo@telis.org>
Subject: Re: multiple setCookies
Message-Id: <3a58e7bb.854742@news.inreach.com>

On 07 Jan 2001 15:35:30 +0000, nobull@mail.com wrote:
:steve a <sarbayo@telis.org> writes:
:
:> On Sat, 6 Jan 2001 23:23:29 +0100, "Mösl Roland" <founder@pege.org>
:> wrote:
:> :"steve a" <sarbayo@telis.org> wrote in message
:> :news:3a57977c.9653618@news.inreach.com...
:> :> Q:
:> :> using Perl, 
:
:There is yuor mistake, you are asking "using Perl" when you need to
:think "funadmentally".   Time travel is impossible - in any language.

Your remark makes no sense.
:
:> 1) to determine if cookies are enables on the browser, by sending 
:>      a  "dummy" cookie and then reading it,
:> 2) If cookies are enabled,  set a real cookie.
:> As I stated:
:> #pseudo code:
:> #set a dummy cookie
:> print header(-cookie=>[$cookie1]);
:> 
:> #next, test if cookies are "on" by fetching the dummy
:> %cookies = fetch CGI::Cookie;
:>   if(! %cookies) {
:>       #do plan "B"
:>       #indicate cookies are "off"
:>   } else {
:>      #do plan "A"
:>      #set a valid cookie
:>   }
:
:You are forgetting the transactional nature of HTTP.  

I'm am well aware of the "transactional nature of HTTP".

:A single HTTP transaction is err... well... how shall I put this... a single
:transaction.  There is no way for the processing of a single HTTP
:tranastion to observe effects that are dependant on the outcome of the
:transaction. 
Not exactly true.
1) set_Cookie,
2) fetch_Cookie,
3) print to browser, results of Cookie transaction,

Distinctly three HTTP transactions.
I can provide source if you like.

:
:This has nothing whatever to do wiht Perl.
It has everything to do with perl.
If I can do the above steps; 1, 2 and 3, why not a step #4 ?
ie: set_Cookie#2



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

Date: Mon, 8 Jan 2001 09:06:45 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Newbie question on Subs
Message-Id: <93asr3$5bb$1@brokaw.wa.com>

This didn't work.
nospam <nospam@mistnet.com> wrote in message
news:3a57f2d4$1@news.iprimus.com.au...
> ?? wouldn't this do it?
>
> #!/usr/bin/perl
> &getwebparams unless $Webaddress;
>
> "Mike McPherson" <hafateltec@hotmail.com> wrote in message
> news:935no6$g6r$1@brokaw.wa.com...
> > I am obviosly a newbie to perl.  Can somebody please help me out on
> this
> > one.
> > What I want this sub to do is simple:
> > 1. Sombody imputs a URL in either xxx.xxx.xxx.xxx or
> http://www.whatever.com
> > format
> > 2. If they do not input anything by just hitting retrun for
> $Webaddress I
> > want it to loop back up to the line above it again and reask untill
> they
> > fill it out?
> >
> >
> > sub getwebparams {
> > print "\nPlease input the URL (Use xxx.xxx.xxx.xxx or www.whatever.com
> > Format)\n";
> > $Webaddress = <STDIN>;
> >      unless
> > ined($Webaddress)){
> >                    print "\nYou must enter a value\n";
> >      return &getparams;
> >      }
> > print "\nPlease enter the port for the website. ie. 80\n";
> > $Webport = <STDIN>;
> > }
> >
> >
> > Thanks in advance
> >
> >
> >
>
>




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

Date: Mon, 8 Jan 2001 09:07:54 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Newbie question on Subs
Message-Id: <93ast7$5i1$1@brokaw.wa.com>

This almost worked.  This just keeps running untill something is input.  But
it never re-asks them to input something.
kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote in message
news:3A56684B.4E2E3574@yvtugubhfrovm.pbz...
> > I am obviosly a newbie to perl.  Can somebody please help me out on this
> > one.
> > What I want this sub to do is simple:
> > 1. Sombody imputs a URL in either xxx.xxx.xxx.xxx or
http://www.whatever.com
> > format
> > 2. If they do not input anything by just hitting retrun for $Webaddress
I
> > want it to loop back up to the line above it again and reask untill they
> > fill it out?
>
> This works for me:
> #!/usr/bin/perl
> $myvar="\n";
> while ($myvar eq "\n") { $myvar = <STDIN>; }
> print "You said, $myvar";
>
>
>
> --
> Kevin Metcalf
> (Carbon Ocelot)
> email: xzrgpnys@yvtugubhfrovm.pbz
> Huh?  http://www.flactem.com/utils/rot13.html




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

Date: Mon, 08 Jan 2001 01:32:22 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Newbie question on Subs
Message-Id: <b74i5tcuv5akeuhm88oh3ci21nshg82pjo@4ax.com>

On Sat, 6 Jan 2001 10:05:22 +1000, "Mike McPherson"
<hafateltec@hotmail.com> wrote:

>I am obviosly a newbie to perl.  Can somebody please help me out on this
>one.
>What I want this sub to do is simple:
>1. Sombody imputs a URL in either xxx.xxx.xxx.xxx or http://www.whatever.com
>format

By xxx.xxx.xxx.xxx, I assume you are looking for an IP address?  If
so, that is NOT a URL.  A URL includes such things as a protocol
identifier (like http://) as well as other optional data.  I can only
assume you want either a machine name (like www.yahoo.com) or an IP
address (like 204.71.200.67).  And I also assume that you want to test
whatever is entered to make sure it is valid, right? :)

>2. If they do not input anything by just hitting retrun for $Webaddress I
>want it to loop back up to the line above it again and reask untill they
>fill it out?

As well as valid, right?

>sub getwebparams {
>print "\nPlease input the URL (Use xxx.xxx.xxx.xxx or www.whatever.com
>Format)\n";
>$Webaddress = <STDIN>;
>     unless
>ined($Webaddress)){  

I should hope this is a syntax error.  Let's see....yep.  If you
copied and pasted your code in here, then perl would tell you your
problem when you ran this.  Something like...

syntax error at C:\Test.pl line 6, near "ined"
syntax error at C:\Test.pl line 12, near "}"
Execution of C:\Test.pl aborted due to compilation errors.

So, for starters, add an open parenthesis in front of
ined($Webaddress)) (or lose one of the closing parens).  But since you
didn't post you ined subroutine, we have no idea what it is or what it
does.

So anyway, let's rewrite this a bit.  Start by including the following
line at the top of your script:

use Socket;

Then rewrite your sub as follows:

sub getwebparams {
    my ($IP, $Port);
    while (!defined($IP)) {
        print "Please enter the destination machine (either its name
or it's IP address --> ";
        $IP = <STDIN>;
        chomp($IP);
        undef $IP unless (defined(inet_aton($IP)));
    }
    print "Please enter a port to connect to [80 is default] --> ";
    $Port = <STDIN>;
    chomp $Port;
    $Port = 80 unless ($Port =~ /^\d+$/);
    return ($IP, $Port);
}

I think this will accomplish what you want (depending on some
definitions of "what you want".)

Hope this helps,
JH



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

Date: Mon, 8 Jan 2001 09:44:28 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Re: Newbie question.
Message-Id: <93av17$736$1@brokaw.wa.com>

Take a look at this little scriplet

#!/usr/local/ActivePerl-5.6/bin/perl -w
use IO::Socket;

#Get a IP addy from the command line.
$host = $ARGV[0] ;
unless (defined($host)) {
print "\nYou must enter something\n";
#If no command line option is selected ask for the IP.
$host = <STDIN>;
}

$remote = IO::Socket::INET->new(
        Proto    => "tcp",
        PeerAddr => $host,
        PeerPort => "13",
        )
or die "cannot connect to daytime port at $host";

$time = <$remote>;
print "\n$time";


Adrian Mink <akmink@austin.rr.com> wrote in message
news:Q_O56.12840$dZ5.276309@typhoon.austin.rr.com...
> I want to be able to pass my script a variable from the command line, like
> this:
>
> perl perl.pl somevalue
>
> Where does "somevalue" get stored and how do I access it from within the
> script?
> Thanks for any help.
>
>
> --
>
>
> ------------------------------------------------------------------
> Do not reply via email, the reply address is
> strictly for spam. Thanks!
>
> Adrian
>
> MCSE, CCNA
> ------------------------------------------------------------------
>
>




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

Date: Mon, 8 Jan 2001 09:49:29 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Reposting - Pattern match in an array of strings
Message-Id: <93b6eu$mlk@netnews.hinet.net>

"Bart Lateur" wrote
>
> Anyway, here's a thought:
>
> if(/$x[0]/g && /\G\s*$x[1]/g) {
>     print "Found \"@x[0, 1]\"!\n";
> }
>
> You need the /g modifier because that's the only way you can continue
> matching, i.e. the second pattern continues where the first one stopped.

Excuse me...  It seems to me that the following lines are equivalent.

if(/$x[0]/g && /\G\s*$x[1]/g)
if(/$x[0]\s*$x[1]/)

Are they different?

Besides, can I save the second  /g  (in /\G\s*$x[1]/g)?

Thank you.

John Lin





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

Date: Sun, 07 Jan 2001 19:20:23 GMT
From: "David Allen" <s2mdalle@titan.vcu.edu>
Subject: Re: Syntac of passing a hash to a subroutine?
Message-Id: <Xj366.5230$8O3.1141533@typhoon2.ba-dsg.net>

In article <93a4qb$6nq$1@panix2.panix.com>, stanb@panix.com  wrote:

> I have wrinte a subroutine which I use to obtain a key from a database table
> contiang key value pairs. 
> 
> Now I need for it to be able to handle optional fileds.
> 
> I have defined this subroutine linke this:
> 
> foo($$$$)
> 
> And now I need to do something like:
> 
> foor($$$$%) {
> 
> my $val1 = $_[0]; my $val2 = $_[1]; my $val3 = $_[2]; my $val4 = $_[3]; my
> %hash = $_[4];
> 
> I have read man perlsub, but I'm still drawing a blank here.
> 
> How can I do this?

You have two options.

sub foo { 
my $val1 = $_[0];
my $val2 = $_[1];
my $val3 = $_[2];
my $val4 = $_[3];
my %hash = @_;
}

(which by the way can also be written as:
sub foo { 
my($val1, $val2, $val3, $val4, %hash) = @_;
})

Your second option is to rather than pass a hash
into this function, pass a hashref.  I.e.

foo(3, 4, 5, 6, \%myhash);

that will come into the subroutine as a scalar.  
$hashref.  Then you can say %hash = %{$hashref};

-- 
David Allen
http://opop.nols.com/
----------------------------------------
People are like onions -- you cut them up, and they make you cry.


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

Date: Sun, 07 Jan 2001 19:51:11 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Syntac of passing a hash to a subroutine?
Message-Id: <hrhh5tofr88b7svk4m4kq84btg7uvkqu29@4ax.com>

On Sun, 07 Jan 2001 19:20:23 GMT, "David Allen"
<s2mdalle@titan.vcu.edu> wrote:

>You have two options.
>
>sub foo { 
>my $val1 = $_[0];
>my $val2 = $_[1];
>my $val3 = $_[2];
>my $val4 = $_[3];
>my %hash = @_;
>}

This does not do what you might think.  By defining %hash to contain
the values of @_ without shift()ing your four parameters out, then
your %hash will contain $_[0] and $_[2] as keys mapped to $_[1] and
$_[3], respectively.

If you want to use this mechanism, your final line should be changed
to:

my %hash = @_[4..$#_];

To illustrate this, assume the following subroutine:

sub Test {
	my $val1 = $_[0];
	my $val2 = $_[1];
	my $val3 = $_[2];
	my $val4 = $_[3];
	my %hash = @_;

	foreach (sort keys %hash) {
		print "$_ = $hash{$_}\n";
	}
}

Now call this with:

Test('Val1', 'Val2', 'Val3', 'Val4', 'Key1', 'Val1', 'Key2', 'Val2');

And Test() will output:

Key1 = Val1
Key2 = Val2
Val1 = Val2
Val3 = Val4

Note that those last two lines shouldn't be there.  Cahnge the
assignment to %hash as above and the subroutine now prints out:

Key1 = Val1
Key2 = Val2

as expected.

JH



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

Date: Sun, 07 Jan 2001 20:31:55 GMT
From: sandywadkins123@my-deja.com
Subject: What am I doing wrong with 1st line
Message-Id: <93ajnr$2db$1@nnrp1.deja.com>

What am I doing wrong, trying to code for a windows server. First time
not using unix.

here is error message.

CGI Error
The specified CGI application misbehaved by not returning a complete
set of HTTP headers. The headers it did return are:


Can't open perl script "C:\web": No such file or directory



Here's code I tried.

#!c:\perl\bin\perl.exe

	print "Content-type: text/html\n\n";
	print "<P>made it";

also tried with out shebang, #!c:\perl\bin, always same message.
Is it me or server, I'm first person trying to use perl on it.

thanks
sandy







Sent via Deja.com
http://www.deja.com/


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

Date: Sun, 07 Jan 2001 23:18:32 GMT
From: "John Boy Walton" <johngros.NOSPAM@bigpond.net.au>
Subject: Re: What am I doing wrong with 1st line
Message-Id: <cP666.49736$xW4.397030@news-server.bigpond.net.au>


<sandywadkins123@my-deja.com> wrote in message
news:93ajnr$2db$1@nnrp1.deja.com...
> What am I doing wrong, trying to code for a windows server. First time
> not using unix.
>
> here is error message.
>
> CGI Error
> The specified CGI application misbehaved by not returning a complete
> set of HTTP headers. The headers it did return are:
>
>
> Can't open perl script "C:\web": No such file or directory
That means the file name or the location of the file is wrong. Check its
location and name.




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

Date: Sun, 07 Jan 2001 19:08:33 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: What do you call the => operator?
Message-Id: <x7bstj6uz2.fsf@home.sysarch.com>

>>>>> "UG" == Uri Guttman <uri@sysarch.com> writes:

  MJD> I never heard that in my life, and it isn't in the manual.

  UG> deja has 55 hits on fat comma in the perl groups since may 99. some
  UG> mention it in the subject.

camel 3 has it the index as => (corresponds to) but no name is mentioned
in the main text. it does refer to it 'the => digraph' but not as the
only digraph as the OP's book seems to imply.

someone on irc says they say 'goes to' or 'is' when reading code out
loud.

another suggestion is 'fat arrow' which is ok IMO. another is 'equal
greater' (the two chars used) but i don't like that.

fat comma works for me.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: 8 Jan 2001 00:16:07 GMT
From: abigail@foad.org (Abigail)
Subject: Re: What do you call the => operator?
Message-Id: <slrn95i1m7.9u.abigail@tsathoggua.rlyeh.net>

Uri Guttman (uri@sysarch.com) wrote on MMDCLXXXVI September MCMXCIII in
<URL:news:x7u27b7qin.fsf@home.sysarch.com>:
}} >>>>> "BO" == Ben Okopnik <ben-fuzzybear@geocities.com> writes:
}} 
}}   BO> "Perl 4 used the comma to separate the key and value items; Perl5
}}   BO> uses => (digraph symbol)."
}} 
}}   BO> Does anyone know the actual name for this thing, though? _Is_
}}   BO> there one?
}} 
}} well, most perl hackers call it fat comma.


I guess I'm either not a Perl hacker, or not most.


Abigail
-- 
It's a right arrow.


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

Date: Sun, 7 Jan 2001 13:46:57 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: xs trouble on Win32 (building Win32::API)
Message-Id: <93ahed$cqa$1@canopus.cc.umanitoba.ca>

"Bjoern Hoehrmann" <bjoern@hoehrmann.de> wrote in message
news:3a5eaa9b.31678721@news.bjoern.hoehrmann.de...
> * Soren Andersen wrote in comp.lang.perl.misc:
> >I am trying to compile the module Win32::API (http://dada.perl.it/) on
WinNT4
> >sp6 using MinGW - gcc-2.95.2.1 and having a rough go of it with the xs
code.
> >The compilation fails because this code has an undeclared identifier:
>
> >Anybody (perhaps familiar with xs and Win32/MSVC++) got any insights?
>
> Well, I tried to build it with VC++ 6.0 and got
>
>   API.xs(155) : error C2065: 'na' : undeclared identifier

Try building it as
     perl Makefile.PL POLLUTE=1

best regards,
randy kobes





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

Date: Sun, 7 Jan 2001 19:52:14 -0600
From: "Adam Pankow" <apankow@next-wave.net>
Subject: Re: xs trouble on Win32 (building Win32::API)
Message-Id: <93b6dc$17n$1@newsfeed.norlight.net>

Did you try using PPM (Perl Package Manager) it has the package on there and
autoinstalls to use it just goto command line or Start... Run and type "ppm"
then type "install Win32::API" and it will proceed with the install.
--
Adam Pankow
ADPankow@yahoo.com
http://www.pankow.org/
DesktopDollars.com . . . get paid to go online
http://www.desktopdollars.com/default.asp?id=apankow
"Randy Kobes" <randy@theory.uwinnipeg.ca> wrote in message
news:93ahed$cqa$1@canopus.cc.umanitoba.ca...
> "Bjoern Hoehrmann" <bjoern@hoehrmann.de> wrote in message
> news:3a5eaa9b.31678721@news.bjoern.hoehrmann.de...
> > * Soren Andersen wrote in comp.lang.perl.misc:
> > >I am trying to compile the module Win32::API (http://dada.perl.it/) on
> WinNT4
> > >sp6 using MinGW - gcc-2.95.2.1 and having a rough go of it with the xs
> code.
> > >The compilation fails because this code has an undeclared identifier:
> >
> > >Anybody (perhaps familiar with xs and Win32/MSVC++) got any insights?
> >
> > Well, I tried to build it with VC++ 6.0 and got
> >
> >   API.xs(155) : error C2065: 'na' : undeclared identifier
>
> Try building it as
>      perl Makefile.PL POLLUTE=1
>
> best regards,
> randy kobes
>
>
>




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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V10 Issue 12
*************************************


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