[21727] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3931 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 8 00:06:31 2002

Date: Mon, 7 Oct 2002 21:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 7 Oct 2002     Volume: 10 Number: 3931

Today's topics:
    Re: -M not working when inside of a function.  Why? <krahnj@acm.org>
    Re: Anyone who uses Perl on VAX <tom.beer@btfinancialgroup.spamfilter.com>
    Re: Anyone who uses Perl on VAX <jozefn@newbolt.sonic.net>
    Re: Anyone who uses Perl on VAX <jozefn@newbolt.sonic.net>
    Re: Anyone who uses Perl on VAX <flavell@mail.cern.ch>
        Getting info of file last update <epanagio@frontiernet.net>
    Re: Getting info of file last update <tony_curtis32@yahoo.com>
    Re: Getting info of file last update <epanagio@frontiernet.net>
    Re: Help me understand *foo = \... <s_grazzini@hotmail.com>
        mod_perl startup.pl and require (Ken)
    Re: need help with regular expressions and not matching (Tad McClellan)
    Re: need help with regular expressions and not matching <krahnj@acm.org>
        newb here learning Perl <ChrisFL@cfl.rr.com>
    Re: newb here learning Perl <krahnj@acm.org>
    Re: newb here learning Perl <jeff@vpservices.com>
    Re: newb here learning Perl <jkeen@concentric.net>
    Re: newbie question - perl vs ? (Ken)
    Re: Problems using Http::Date <bongie@gmx.net>
    Re: Sharing a program? <joec@annuna.com>
    Re: Simple Way to Refer to ARGV Values as a String <krahnj@acm.org>
    Re: Simple Way to Refer to ARGV Values as a String <s_grazzini@hotmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 07 Oct 2002 22:56:45 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: -M not working when inside of a function.  Why?
Message-Id: <3DA2111A.54D7F86B@acm.org>

Perl Man wrote:
> 
> # Find the latest JOINER PORTS file according to time stamp.
> sub JPort ()
> {
>    $newtime=999999999;
>    $newestfile = "";
> 
>    foreach $file (@array)
>    {
>       chomp $file;
> 
>       # skip over the . .. directories
>       next if ($file =~ /^\./ or $file =~ /\.log/i);

This skips over _any_ file that starts with a dot.

      next if $file =~ /^\.\.?$/ or $file =~ /\.log/i;


>       $stamp = -M $file; # file modified date -M
>       print "s: $stamp\n";
> 
>       # If stamp is newer, then set newtime to be the most recent
>       if ($stamp < $newtime)
>       {
>          $newtime=$stamp;
>          $newestfile=$file; # set newest file to be the most recent.
>       }
>    }
> }
> 
> -------------
> The print statement should be returning the modified date of the file.
>  This works fine when its not inside the function.  I'm running build
> 633.  Any ideas?

Using my crystal ball I would probably guess that you are populating
@array from readdir().  If this is the case then you have to include the
directory name with the file name when you use -M.  Also, you should use
warnings and strict when developing your program and let Perl help you
find mistakes.


John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 8 Oct 2002 08:29:48 +1000
From: "Tom Beer" <tom.beer@btfinancialgroup.spamfilter.com>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <ant1ss$ava$1@merki.connect.com.au>

Jim Agnew wrote in message <3DA1DC51.382DBAF7@vcu.edu>...
>jozefn wrote:
>> I now have a project on a VAX. Have not seen the box yet - don't know
about the OS - as you can see - very green.
>>
>Welcome to one of the finest os's around. Definitely not a desktop
>except for the very hard-core..

Technically, VAX refers to the hardware (and I think VAXs are now obsolete -
replaced by Alphas). The OS is most likely to be VMS.

Tom.




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

Date: Mon, 07 Oct 2002 22:46:31 GMT
From: Joseph Norris <jozefn@newbolt.sonic.net>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <Pine.LNX.4.40.0210071545030.6857-100000@newbolt.sonic.net>


Tom,

You are right - I should have said openvms.  I did not know that this was
going to be the OS when I orginally sent the email.  The manager just
said "Vax box".

BTW.  I understand that you can get a hobbist version of OpenVms but
I don't know where.  Any Ideas?

Thanks.

#Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
-68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);


On Tue, 8 Oct 2002, Tom Beer wrote:

> Jim Agnew wrote in message <3DA1DC51.382DBAF7@vcu.edu>...
> >jozefn wrote:
> >> I now have a project on a VAX. Have not seen the box yet - don't know
> about the OS - as you can see - very green.
> >>
> >Welcome to one of the finest os's around. Definitely not a desktop
> >except for the very hard-core..
>
> Technically, VAX refers to the hardware (and I think VAXs are now obsolete -
> replaced by Alphas). The OS is most likely to be VMS.
>
> Tom.
>
>
>



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

Date: Mon, 07 Oct 2002 22:49:36 GMT
From: Joseph Norris <jozefn@newbolt.sonic.net>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <Pine.LNX.4.40.0210071548440.6857-100000@newbolt.sonic.net>


Thanks a bunch pkent.  this has given me some good starting points.
You are right - I wrote wrong - should have written openvms not just
Vax box.

Thanks.


#Joseph Norris (Perl - what else is there?/Linux/CGI/Mysql)
print @c=map chr $_+100,(6,17,15,16,-68,-3,10,11,16,4,1,14,-68,12,1,14,8,
-68,4,-3,-1,7,1,14,-68,-26,11,15,1,12,4,-68,-22,11,14,14,5,15,-90);


On Mon, 7 Oct 2002, pkent wrote:

> In article
> <Pine.LNX.4.40.0210071000310.27518-100000@newbolt.sonic.net>,
>  jozefn <jozefn@newbolt.sonic.net> wrote:
>
> > territory for me ).  Are there any Perl Hackers out there using Perl
> > on Vax boxes? The project I have involves a menu system that runs
> > simple reports on the VAX box.  The reports are already in place - I
> > just want to put a front-end html based system that allows the running
> > of these reports using PERL/HTML/Javascript etc.
>
> ...and also replying to
> <Pine.LNX.4.40.0210071039540.4141-100000@newbolt.sonic.net> ...
>
> First, I used to work on a Vax at a previous orkplace, so this may all
> be out of date or indeed wrong...
>
> A Vax is the hardware platform, and it runs the operating system
> OpenVMS. I don't think Vaxen run Digital UNIX.
>
> Ask the sysadmin about the best way to transfer files to/from the Vax.
>
> The VMS filesystem is case insensitive. Perl is case sensitive. VMS
> doesn't like more than one '.' in filenames, but files have version
> numbers for free.
>
> The VMS way of specifying filenames might be strange to you, so use
> File::Spec and its friends for filepath operations, and that's got the
> added bonus of better portability too.
>
> AFAIK VMS is an ASCII based system, but has the DOSish idea of 2-byte
> line endings in text mode... sometimes :->
>
> Vaxes are little-endian. This probably doesn't make any difference to
> you, but you never know
>
> > Are the any gotch'yas working on VAX?
> > Do all of the parts of Perl work the same way on VAX as they do on the above
> > mentioned platforms?
>
> For more differences see the VMS section of perlport, the perlvms.pod
> page in the source kit and online, or
> http://www.sidhe.org/vmsperl/index.html
>
> > What is it similar to - UNIX? MPEIX? Dos?
>
> I'd say it's different from all of them, in various ways :-)
>
> > Can I put a web based front-end on this box, so as to automate the current
> > command-line entry setup that is used to run reports etc?
>
> It sounds like thesecond thing you'll need to set up is a web server
> that allows you to run programs via the CGI. Apparently Apache has been
> ported after some fashion to OpenVMS and there are other webservers
> available for VMS. Your sysadmin may already be running a webserver.
>
> The _first_ thing is to get yourself an account on the box, get perl
> installed and try your programs out on the command line. Take the
> unknowns one at a time.
>
> > Can I use the system command to run alread resident programs and scripts in
> > background?
>
> But yes, system() and pipes and all that work just fine. And definitely
> read those docs I cited.
>
> P
>
> --
> pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
> Remove the tea to reply
>



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

Date: Tue, 8 Oct 2002 00:51:32 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <Pine.LNX.4.40.0210080044140.1261-100000@lxplus033.cern.ch>

On Oct 7, pkent inscribed on the eternal scroll:

> A Vax is the hardware platform, and it runs the operating system
> OpenVMS. I don't think Vaxen run Digital UNIX.

Sort-of.  VAX is a (now obsolete) hardware platform, which usually ran
VAX/VMS - what has now become OpenVMS.

However, the VAX hardware could run some kind of unix.  But anyone who
was doing that would say so up front - if you're told nothing more
than that it's a VAX, it's a near certainty that the OS is VMS, I
would say.

> > What is it similar to - UNIX? MPEIX? Dos?
>
> I'd say it's different from all of them, in various ways :-)

Indeed ;-)

Its habit of keeping multiple versions of the same file would be quite
welcome - now that disk space has become so cheap.  Back then we were
forever purging old versions to retrieve some of the precious disk
space.



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

Date: Mon, 7 Oct 2002 21:49:16 -0400
From: "epanagio" <epanagio@frontiernet.net>
Subject: Getting info of file last update
Message-Id: <uq4e204lt1erb0@corp.supernews.com>

How can I get the date and time stamp of a file? I use the following code
but I get the wrong date! It reports the date of 1969! The server is windows
2000. Thanks,

#!/usr/local/bin/perl
#filedate.pl  Uses stat to get the last modified date from a file.

# Note that in the stat array $mtime is the last modification time
# (measured in secs since the epoch)
$file= $ARGV[0];
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,
$blks)= stat(taxfile);
($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst)=
localtime($mtime);
$year= 1900 + $year;

print "mtime (the last modify time since the epoch): $mtime\n";
print "Applying mtime to localcaltime time we get: ";
printf("  %d-%d-%d\n",$mon+1,$mday,$year);

--
Evan




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

Date: Mon, 07 Oct 2002 20:58:00 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Getting info of file last update
Message-Id: <87r8f1wv2v.fsf@limey.hpcc.uh.edu>

>> On Mon, 7 Oct 2002 21:49:16 -0400,
>> "epanagio" <epanagio@frontiernet.net> said:

> How can I get the date and time stamp of a file? I use
> the following code but I get the wrong date! It reports
> the date of 1969! The server is windows 2000. Thanks,

December 31 no doubt?

> #!/usr/local/bin/perl

Add -w and use strict;

> $blks)= stat(taxfile);

You want either $taxfile if it's set somewhere, or
'taxfile' if it's a literal file name.  I'd guess you
really meant $file since that comes from the command line.

This is where -w/strict will help you enormously.

I'd use File::stat and POSIX with strftime to do this,
e.g. along the lines of:

    use File::stat;
    use POSIX qw(strftime);

    my $st = stat('.bashrc') or die "suitable error message";

    my $modtime = strftime('%m-%d-%Y %H:%M:%S',
                           localtime($st->mtime));

      $modtime ==> 09-20-2002 21:10:44

hth
t


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

Date: Mon, 7 Oct 2002 22:25:11 -0400
From: "epanagio" <epanagio@frontiernet.net>
Subject: Re: Getting info of file last update
Message-Id: <uq4g5b2k7rgead@corp.supernews.com>

Thanks Tony!
The single quotes around the filename did it. I read your comments and I
thank you for your time.
Evan P.

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87r8f1wv2v.fsf@limey.hpcc.uh.edu...
> >> On Mon, 7 Oct 2002 21:49:16 -0400,
> >> "epanagio" <epanagio@frontiernet.net> said:
>
> > How can I get the date and time stamp of a file? I use
> > the following code but I get the wrong date! It reports
> > the date of 1969! The server is windows 2000. Thanks,
>
> December 31 no doubt?
>
> > #!/usr/local/bin/perl
>
> Add -w and use strict;
>
> > $blks)= stat(taxfile);
>
> You want either $taxfile if it's set somewhere, or
> 'taxfile' if it's a literal file name.  I'd guess you
> really meant $file since that comes from the command line.
>
> This is where -w/strict will help you enormously.
>
> I'd use File::stat and POSIX with strftime to do this,
> e.g. along the lines of:
>
>     use File::stat;
>     use POSIX qw(strftime);
>
>     my $st = stat('.bashrc') or die "suitable error message";
>
>     my $modtime = strftime('%m-%d-%Y %H:%M:%S',
>                            localtime($st->mtime));
>
>       $modtime ==> 09-20-2002 21:10:44
>
> hth
> t




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

Date: Mon, 07 Oct 2002 22:20:31 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Help me understand *foo = \...
Message-Id: <PMno9.40756$YI.9247183@twister.nyc.rr.com>

Michael Carman <mjcarman@mchsi.com> wrote:
> On 10/7/02 1:23 PM, Da Witch wrote:
>>
>> still very confused by Perl expressions such as:
>> 
>>   *xyz = [1, 2, 3];
 ...

>> How does the effect of above line differ from that of
>> 
>>   our @xyz = (1, 2, 3);
> 
> Subtly. The first assigns to the ARRAY slot of the *xyz glob in the
> main:: package. our() has lexical scoping semantics, so the latter
> assigns to the ARRAY slot of the *xyz glob in the current package, which
> may or may not be main::.
  
Agreed with the rest of your answer, but this isn't quite 
right.  *xyz also refers to the current package.

The lexically-scoped symbol 'our' creates is relevant:

  1) under strict 'vars', since it lets you use a global
     without fully-qualiyfing (or the 'vars' pragma).

  2) when you want to mask a pad variable with a global,
     which of course you never do, but:

        my $x = 1; 
        { our $x; $x = 2 }

        print "$x $::x\n";  # "1 2"

  3) to 'share' globals across two packages in a single
     file.
 
     $ perldoc -f our
        ...

        package Foo;
        our $bar;       # declares $Foo::bar for rest of lexical scope
        $bar = 20;

        package Bar;
        print $bar;     # prints 20

-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: 7 Oct 2002 17:54:30 -0700
From: angel@xev.net (Ken)
Subject: mod_perl startup.pl and require
Message-Id: <fafcc419.0210071654.2adc908@posting.google.com>

I am currently using mod_perl. I use a startup.pl script to preload
all my needed modules. Most of them I load with use(). However, there
are some modules that I need to create when Apache is started. The
files don't exist until Apache is started. (Just bare with me.) I
create the modules in startup.pl. Therefore, I can't use the use()
statement. If I try, the modules are loaded before they exist.

Ok, here is my question: Will loading modules with require() preload
them into memory like the use statement does? Are there any reasons I
shouldn't load modules with require() in this way?


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

Date: Mon, 7 Oct 2002 17:22:23 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: need help with regular expressions and not matching
Message-Id: <slrnaq428v.2d5.tadmc@magna.augustmail.com>

:crp: <chips@eskimo.com> wrote:

> I am trying to find all lines that have the word "with" but do not have ";" 
> anywhere on the line after it.


   /with[^;]*$/

or

   /with(?!.*;)/

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 07 Oct 2002 23:01:14 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: need help with regular expressions and not matching
Message-Id: <3DA2122A.7F2AD4@acm.org>

:crp: wrote:
> 
> I am trying to find all lines that have the word "with" but do not have ";"
> anywhere on the line after it.
> I tried :
>         with .*[^;]
> but that did not work.

$ perl -le'
for ( " some with out ", "some with one ; ", " ; before with none " ) {
    print if /with(?!.*;)/;
    }
'
 some with out 
 ; before with none 



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 08 Oct 2002 00:44:11 GMT
From: "Frito - Lay" <ChrisFL@cfl.rr.com>
Subject: newb here learning Perl
Message-Id: <vTpo9.92433$O8.2209253@twister.tampabay.rr.com>

  Hello all!
I am learning Perl and was directed to this newsgroup by an e-book. It said
something about an E-Mail/FAQ thing I will get when I post for the first
time, so I am posting. I hope to learn and become proficient at Perl, and I
will return to this newsgroup whenever I need help, or just want to see
whats happening.




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

Date: Tue, 08 Oct 2002 01:02:10 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: newb here learning Perl
Message-Id: <3DA22E82.620B441@acm.org>

Frito - Lay wrote:
> 
> I am learning Perl and was directed to this newsgroup by an e-book. It said
> something about an E-Mail/FAQ thing I will get when I post for the first
> time, so I am posting. I hope to learn and become proficient at Perl, and I
> will return to this newsgroup whenever I need help, or just want to see
> whats happening.

news:comp.lang.perl.moderated sends an E-Mail/FAQ thing when you post
for the first time.


John
-- 
use Perl;
program
fulfillment


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

Date: Mon, 07 Oct 2002 18:17:26 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: newb here learning Perl
Message-Id: <3DA23226.9050405@vpservices.com>

Frito - Lay wrote:

>   Hello all!
> I am learning Perl and was directed to this newsgroup by an e-book. It said
> something about an E-Mail/FAQ thing I will get when I post for the first
> time, so I am posting.


No, I don't think you'll get the perl FAQs that way.  But there are many 
other ways.  The Perl FAQ comes with perl.  If you have perl installed 
somewhere, go to a command prompt and type "perldoc perldoc" (yes twice) 
to see it.  If you are using ActiveState perl, it comes with an HTML 
version of all the FAQs. (on windows, find it by going to the Start 
menu, Programs, ActivePerl, Documentation). The FAQs are also available 
many places online, for example:

   http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq.html

I think Steven Wright (the comic) is working on the "How do I find the 
FAQ?" entry for the FAQ.

-- 
Jeff



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

Date: 08 Oct 2002 03:13:08 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: newb here learning Perl
Message-Id: <antig4$9sh@dispatch.concentric.net>


"Jeff Zucker" <jeff@vpservices.com> wrote in message
news:3DA23226.9050405@vpservices.com...
> Frito - Lay wrote:
>
> >   Hello all!
> > I am learning Perl and was directed to this newsgroup by an e-book. It
said
> > something about an E-Mail/FAQ thing I will get when I post for the first
> > time, so I am posting.
>
>
> No, I don't think you'll get the perl FAQs that way.  But there are many
> other ways.  The Perl FAQ comes with perl.  If you have perl installed
> somewhere, go to a command prompt and type "perldoc perldoc" (yes twice)
> to see it.  If you are using ActiveState perl, it comes with an HTML
> version of all the FAQs. (on windows, find it by going to the Start
> menu, Programs, ActivePerl, Documentation). The FAQs are also available
> many places online, for example:
>
>    http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq.html
>
And don't forget that all the Perl documentation is now available in a nice
interface at www.perldoc.com




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

Date: 7 Oct 2002 15:51:15 -0700
From: angel@xev.net (Ken)
Subject: Re: newbie question - perl vs ?
Message-Id: <fafcc419.0210071451.354584b5@posting.google.com>

Dave Cross <dave@dave.org.uk> wrote in message:
> 
> > A great place to find scripts is at
> > http://cgi.resourceindex.com/Programs_and_Scripts/Perl/
> 
> But the problem with this approach is that most of these "script
> repository" sites simlpy list all of the programs they can find. As the
> majority of Perl programs available on the internet are badly written
> you're likely to end up picking up some very bad habits from reading
> random Perl programs that you find on the internet.
> 
> For example of good Perl code try Perlmonks <http://perlmonks.org/>.
> 
> Dave...

This is true as well. Perlmonks.org will teach good programming
practice. But so will Perl books. CGI.ResourceIndex.com provides full
scripts that are used on live websites. Studying these scripts will
teach many things that won't be found in Perl books or websites such
as Perlmonks. There are a lot of bad scripts out there, but there are
also a lot of good ones. I learned Perl by studying other scripts as
well as through books and online tutorials. After a while, I found
myself completly rewriting many of the scripts I got from the CGI
Resource Index because of their flaws. But they still taught be how to
do things I would have never learned from a book. So while it is true
that many people's scripts are bad by design, they can still be
helpful to study.

-Ken


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

Date: Tue, 08 Oct 2002 04:50:50 +0200
From: "Harald H.-J. Bongartz" <bongie@gmx.net>
Subject: Re: Problems using Http::Date
Message-Id: <1229086.TVRTcVMX4u@nyoga.dubu.de>

Paul Tomlinson wrote:
> What purpose does "use diagnostics" serve?  What functionality does it
> have and where should it be used?

See "perldoc diagnostics".
It gives you verbose explanations of errors and warnings emitted by perl 
during compile and execution time. You won't need it in production 
code, but it helps when debugging code.

BTW, did you read Helgi's signature? ;-)

> "Helgi Briem" <helgi@decode.is> wrote in message
> news:3da1b65c.2448277647@news.cis.dfn.de...
[...]
>>                            A: Top posting
>>                            Q: What is the most irritating thing on
>>                            Usenet?
>>                                            - "Gordon" on apihna

Ciao,
        Harald
-- 
Harald H.-J. Bongartz <bongie@gmx.net>
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Atheism is a non-prophet organization.


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

Date: Mon, 07 Oct 2002 22:46:52 GMT
From: Joe Creaney <joec@annuna.com>
Subject: Re: Sharing a program?
Message-Id: <3DA20EE2.7040600@annuna.com>

My next project is to figure out how to pick up items and use them.  I 
hope this is agood start for a fun game.  I am glad I posted it because 
I just lost my HD.

James E Keenan wrote:
> "Joe Creaney" <joec@annuna.com> wrote in message
> news:3D9F97AD.30905@annuna.com...
> 
>>I am fairly new to perl and programming but I wrote a very simple
>>adventure program is there any place I can share this program?
>>
> 
> 1.  You just did.
> 
> 2.  CPAN (Comprehensive Perl Archive Network) has a scripts repository, but
> there doesn't seem to be a specific sub-repository for games
> (http://www.cpan.org/scripts/index.html).
> 
> 
> 



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

Date: Mon, 07 Oct 2002 22:44:34 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Simple Way to Refer to ARGV Values as a String
Message-Id: <3DA20E42.389128D6@acm.org>

Kevin Simonson wrote:
> 
> I want to pass a Java program root name to a Perl file, along with the
> arguments I want it to execute on.  I want to do some processing to
> the root name, and then when I'm done I want to execute the Java pro-
> gram on the arguments I passed to it.  From what I learned in the
> class I took ages ago on Perl, it seemed like there was some quick way
> to do this last bit, to call a program giving it all the arguments
> that I originally passed the Perl file.
> 
>      I guess one way I could do it would be like this:
> 
>           #!/usr/bin/perl
> 
>           if ($#ARGV >= 0)
>           { $root = $ARGV[0];
>             shift @ARGV;
> 
>             # Do some processing on $root.
> 
>             $argumentList = join( " ", @ARGV);
> 
>             # Execute command.
> 
>             print `java $root $argumentList`;
>           }
>           else
>           { # Print usage.
>           }
> 
> But it seems like there was a simpler way to concatenate all the argu-
> ments into one string.  Anybody out there know how to do it?  Thanks!


You don't have to concatenate all the arguments if you just want to
execute them:

#!/usr/bin/perl

if ( @ARGV ) {
    # Do some processing on $ARGV[0]

    # Execute command.
    system @ARGV;
    }
else {
    # Print usage.
    }

__END__



John
-- 
use Perl;
program
fulfillment


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

Date: Tue, 08 Oct 2002 00:41:40 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: Simple Way to Refer to ARGV Values as a String
Message-Id: <8Rpo9.40775$YI.9335463@twister.nyc.rr.com>

Kevin Simonson <kvnsmnsn@hotmail.com> wrote:
> I want to pass a Java program root name to a Perl file, along with the
> arguments I want it to execute on.  I want to do some processing to
> the root name, and then when I'm done I want to execute the Java pro-
> gram on the arguments I passed to it.  From what I learned in the
> class I took ages ago on Perl, it seemed like there was some quick way
> to do this last bit, to call a program giving it all the arguments
> that I originally passed the Perl file.
> 
>      I guess one way I could do it would be like this:
> 
>           #!/usr/bin/perl
> 
>           if ($#ARGV >= 0)
>           { $root = $ARGV[0];
>             shift @ARGV;
> 
>             # Do some processing on $root.
> 
>             $argumentList = join( " ", @ARGV);
> 
>             # Execute command.
> 
>             print `java $root $argumentList`;
>           }
>           else
>           { # Print usage.
>           }

  #!/usr/bin/perl
  die "usage: $0 CLASS [ args.. ]\n" unless @ARGV;

  my $root = shift;
  ...

  exec 'java', $root, @ARGV;


-- 
Steve

perldoc -qa.j | perl -lpe '($_)=m("(.*)")'


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 3931
***************************************


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