[10497] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4089 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 28 02:05:56 1998

Date: Tue, 27 Oct 98 23:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 27 Oct 1998     Volume: 8 Number: 4089

Today's topics:
    Re: -t test in Win32 <kprice@cardinal.co.nz>
        byte code yuezhao@eri.u-tokyo.ac.jp
        changing file timestamp in Win32 stevenfitz@my-dejanews.com
    Re: Checking for uppercase (Jason Spears)
    Re: Communicating to ftp <maurerf@post.ch>
    Re: Date 2 Num (Ronald J Kimball)
        Document contains no data <khalifa@blitz.cs.pitt.edu>
    Re: END{exit(1)} (Ilya Zakharevich)
        File Permissions on NT 4 using Perl 5.004 <nobody@noplace.com>
    Re: getopts question (Larry Rosler)
    Re: Handling text files <shiloh@shell9.ba.best.com>
    Re: Handling text files (Tad McClellan)
    Re: non-looping range match <ianchurc@ozemail.com.au>
    Re: Not to start a language war but.. (Thomas)
    Re: Not to start a language war but.. (Abigail)
        Off the beaten path (Justin Wilde)
        Off the beaten path (Justin Wilde)
    Re: Perl & Y2K - booby trap code (Tye McQueen)
    Re: Perl & Y2K - booby trap code <cberry@cinenet.net>
    Re: Problem with Win32 reg exp (Ronald J Kimball)
    Re: Problem with Win32 reg exp (Tye McQueen)
    Re: RFC - Signature (Ronald J Kimball)
    Re: sorting a hash by values (sorry if this is a stupid (Tad McClellan)
        Syntactic flexibility (was: Re: psychology of language  mvanier@my-dejanews.com
    Re: USE declaration for modules in remote directories (Tad McClellan)
    Re: USE declaration for modules in remote directories <tjhill@flash.net>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Wed, 28 Oct 1998 16:55:14 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: -t test in Win32
Message-Id: <363695A2.3F95C911@cardinal.co.nz>

> I am using ActiveState build 502 perl for Win32 and have a problem
> with the -t test.  It returns true whether or not the script is in
> the foreground or running from Windows AT command or a NT Service.
> Does anyone know of a reliable way for a perl script running on NT
> to determine whether it is in the foreground or the background ?
> 
Just to clarify, I am using something like

if ( -t STDOUT ) {
    $interactive = "Y";
} 
else {
    $interactive = "N";
};

I am guessing that it always returns true because when it runs in the
background it is running in a virtual window on a virtual desktop, so
even though no-one can see the output -t believes STDOUT is attached to
a tty device.  I want to use the test to decide whether messages should
go to the screen or a logfile.


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

Date: Wed, 28 Oct 1998 05:03:17 GMT
From: yuezhao@eri.u-tokyo.ac.jp
Subject: byte code
Message-Id: <7168il$smu$1@nnrp1.dejanews.com>

The document in perl5.005 says the perl script can be compiled(?)
to byte code. But it does not tells me how to do it. Anyone can
tell me something about it?

Thanks

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 28 Oct 1998 04:35:03 GMT
From: stevenfitz@my-dejanews.com
Subject: changing file timestamp in Win32
Message-Id: <7166tn$pqd$1@nnrp1.dejanews.com>

I am writing a small Win32 Perl script to synch two directories and find that
once I have copied a file, the date and time of the new file are set to the
current date and time. To make the files match, I am trying to change the
timestamp for the newly created file.

So far my script looks like:
"
use File::Copy;

copy($source_path,$dest_path);
$newTime = time - (-M $source_path)*24*60*60;
utime ($newTime, $newTime, $dest_path);
"

where $source_path is the original file and $dest_path is the copied file.

It doesn't seem to matter what I set $newTime to, utime always seems to set it
to the current time. Any thoughts on what I'm doing wrong or how I could do
this better?

Thanks,
Steven

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 28 Oct 1998 01:44:33 GMT
From: jspears@usit.net (Jason Spears)
Subject: Re: Checking for uppercase
Message-Id: <715su1$n37$1@us4.usit.net>

In article <36363E81.1857FFA1@mountain-inter.net>,
	John Borchert <borchert@mountain-inter.net> writes:
> How can I properly check for uppercase.  I am looking for the equivalent
> of something like:
>   if upper($4) ne "_TOP"
> 
> My line of perl code is as follows:
>   push(@goodLinks, $cBaseURL . $2) if $4 ne "_TOP" && $4 ne "_top";
> 
> Should I use a regex for this?

Well, you certainly _could_ use a regex.  I don't see any compelling reason
why you should in this case.  If you were looking for multiple "target="
values in your HTML you might do something like

    push(@goodLinks, $cBaseURL . $2) if $4 !~ /^(_top|main1|main2|nav)$/i;

I find a regex a little more readable than your example.  Mostly it's
just personal preference, isn't it?

HTH,

Jason Spears



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

Date: Tue, 27 Oct 1998 16:52:03 +0100
From: "Felix Maurer" <maurerf@post.ch>
Subject: Re: Communicating to ftp
Message-Id: <714q84$6p1@gd2inews.swissptt.ch>

I decided to take option of using Net::FTP. This was a little hard because I
had no idea of the syntax using the modules, and I also had to reinstall
perl completly on my system as the previous perl version was not compatible.
Any way I'm very glad now and learned a lot

Felix

>I'm trying to communicate to ftp, in order to transfer files from one
system
>to an other. I know, there is some perl modules to do it, but I'm not
>familiar with and I also like to learn by myself. So far I have the
>following code, but I don't see how proceed with subsequent commands (like
>login,ls and logout):
>
>ftp_xfer();
>
>sub ftp_xfer {
>  my $ftp_host          = "some_node";
>  my $ftp_con           = "ftp -in $ftp_host";
>  my $ftp_login         = "user username pwd";
>  my $ftp_dir           = "ls";
>  my $ftp_logout        = "bye";
>
>  use FileHandle;
>  STDOUT->autoflush("1");
>
>  exec $ftp_con;
>  return;
>}
>
>Any hint to a newbie would be greatly appreciated
>
>




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

Date: Tue, 27 Oct 1998 23:20:30 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Date 2 Num
Message-Id: <1dhkvu7.k305ic5ex340N@bay1-204.quincy.ziplink.net>

Joergen W. Lang <jwl@_munged_worldmusic.de> wrote:

> Craig Pickles <pickles_c@hotmail.com> wrote:
> 
> > I know the Date:Calc module would do this, but unofrtunately, I am
> > running my site from a cheap server that doesnt allow me access to C
> > for compiling......

> BTW, you don't have to access C for compiling. [...]

I think you missed Craig's point...  From the INSTALL file for the
DateCalc package:


    Prerequisites:
    --------------

    Perl version 5.000 or higher,
    a C compiler capable of the ANSI C standard (!)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

[original emphasis]


So, you do need access to C to compile the Date::Calc module.


-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 28 Oct 1998 06:05:13 GMT
From: Yasir Khalifa <khalifa@blitz.cs.pitt.edu>
Subject: Document contains no data
Message-Id: <716c6p$hbt$1@usenet01.srv.cis.pitt.edu>

Hi:

I have a multiple page/cgi application, and in one of them I don't
want to pass data to the cgi (unless all fields in the form are filled
out before submitting). Instead, I want to redisply automatically 
the same window (simulating the incomplete form javascript alert!).
I am getting the "Document contains no data" warning. Is there a 
way to supress it?

Any help is appreciated.
-Yasir




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

Date: 28 Oct 1998 05:00:21 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: END{exit(1)}
Message-Id: <7168d5$19n$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to 
<stuart_poulin@nospam.yahoo.com>],
who wrote in article <36367E5C.2F9B3F61@nospam.yahoo.com>:
> I would like to exit from a script using the END block and and exit
> value.  Is this possible?
> 
>  perl -Mdiagnostics -e 'END{exit(0)}'; echo $?
> 0
>  perl -Mdiagnostics -e 'END{exit(1)}'; echo $?
> Callback called exit (#1)

Did you try POSIX::_exit?

Ilya


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

Date: Tue, 27 Oct 1998 21:26:41 -0800
From: "R.G." <nobody@noplace.com>
Subject: File Permissions on NT 4 using Perl 5.004
Message-Id: <716a3l$40u@sjx-ixn5.ix.netcom.com>

Has anyone had any experience changing file permissions on an NT server
using Perl?

The chmod() command is described in the Perl Manual pages as having the
ability to change the read/write permission for a file, but I can find no
reference as to the usage of chmod() under Win32.  It seems to me that the
permutations of permissions under Win32 makes chmod() not exactly the same.

Any suggestions greatly appreciated,
Rich G.





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

Date: Tue, 27 Oct 1998 19:27:24 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: getopts question
Message-Id: <MPG.10a02ef8a5be32029898e2@nntp.hpl.hp.com>

In article <363680F5.C98DCF37@cardinal.co.nz> on Wed, 28 Oct 1998 
15:27:01 +1300, Kelvin Price <kprice@cardinal.co.nz> says...
> Chintan Adhyapak wrote:
> > 
> > fact. However, you can always check to see whether @ARGV has been
> > completely emptied or not - that is, whether all arguments have been
> > processed."
> > How do I verify that? Thanks,
> > 
> If @ARGV = () (IE The @ARGV list equals an empty list) then there are no
> more arguments.

It is difficult to test for @ARGV to equal an empty list, as your non-
Perl pseudocode seems to imply.  What you really want to test for is 
whether @ARGV has any elements, which can be done simply by code like:

   if (@ARGV) { ... process the elements in @ARGV ... } 

which evaluates @ARGV in scalar context, i.e., the number of elements.

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


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

Date: 28 Oct 1998 05:03:38 GMT
From: <shiloh@shell9.ba.best.com>
Subject: Re: Handling text files
Message-Id: <3636a5aa$0$29751@nntp1.ba.best.com>


: On Mon, 12 Oct 1998, Todd Dunsirn wrote:

:> I have some files (a lot actually) that are like the following format...
:> 
:> Name: Joe
:> Age: 23

:> Any help with this would be greatly appreciated. I have some
:> experience with Perl but would appreciate a rough template or idea to
:> get going.

Here is a solution.  This assumes all your files are named junk8.in*, like
junk8.in1, junk8.in2 etc.

#!/usr/local/bin/perl4

while ($filename = <junk8.in*>){

  open (INFILE, "$filename");

  $var = 1;
  while ( $item = <INFILE>){
    ($junk,$junk2) = split(/\s+/, $item);
    if ($var == 1){
  
      print "${junk2},";
        ++$var;
    } else {
  
      print "$junk2\n";
      $var = 1;
    }
  }  # second while
}  # first while
# end

# cat junk8.in
Name: joe
Age: 43
Name: Al
Age: 41
Name: Sandy
Age: 37

# junk8
joe,43  
Al,41   
Sandy,37

--Joe McCaughan | Great is the Lord, and greatly to be praised,
shiloh@best.com | And His greatness is unsearchable!           Psalm 145:3



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

Date: Wed, 28 Oct 1998 01:28:43 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Handling text files
Message-Id: <b3h617.mmg.ln@flash.net>

shiloh@shell9.ba.best.com wrote:

: : On Mon, 12 Oct 1998, Todd Dunsirn wrote:

: :> I have some files (a lot actually) that are like the following format...
: :> 
: :> Name: Joe
: :> Age: 23

: :> Any help with this would be greatly appreciated. I have some
: :> experience with Perl but would appreciate a rough template or idea to
: :> get going.

: Here is a solution.  


   Nooooooo...


   Thanks for trying to help out. But you have three big problems
   that I just can't let be copied by those who don't see the
   Three Big Problems.

   1) perl4

   2) no -w switch

   3) didn't check return value from open()



: This assumes all your files are named junk8.in*, like
: junk8.in1, junk8.in2 etc.


   I also would not make assumptions when the can be easily avoided.
   (this is not one of the Big Three Problems, but is poor design)

   Let the user specify the filenames on the command line. Then
   maybe they'll be able to use the script again when you have
   different filenames. Hardcoding stuff that may change should
   be avoided.



: #!/usr/local/bin/perl4
                   ^^^^^

   Do you know that when perl4 was current, most PCs were running
   Windows 3.1?

   Perl4 is no more.

   Friends don't let friends use perl4.





   You should enable warnings from perl on every single script
   that you ever write.

   Really.


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



: while ($filename = <junk8.in*>){

:   open (INFILE, "$filename");


   You should always, yes *always* check the return value from open():

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



(of course, if you leave it to the user to specify the filenames
 on the command line, then you don't even have any open() calls
 to worry about...
)



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

while (<>) {
   if ( /^Name: (.*)/ ) {
      $name = $1;
   }
   elsif ( /^Age: (.*)/ ) {
      print "$name,$1\n";
   }
}
------------------------------------------



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


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

Date: Wed, 28 Oct 1998 14:07:40 +1100
From: Ian Church <ianchurc@ozemail.com.au>
Subject: Re: non-looping range match
Message-Id: <36368A7C.628F40A8@ozemail.com.au>


yes it helps...

    the data I gave as an example works fine (reduced to provide a
manageable example)
the problem was with the RE in the range (the real RE on the real data).

I guess I should run my own examples.

Thanks.

Ian

Tom Phoenix wrote:

> On Wed, 28 Oct 1998, Ian Church wrote:
>
> >     eg if my file contains:
> >
> >             abc
> >             def
> >             ghi
> >             jkl
> >             mno
> >             ghi
> >
> > using something like:
> >
> >     perl -ne 'print if /abc/ .. /ghi/'
> >
> >     I want:
> >
> >         abc
> >         def
> >         ghi
> >
> > The range operators loop and hence I get the whole file as a match.
>
> Not with my copy of perl. Doesn't yours do just as you ask? Maybe you
> should try it again. Hope this helps!
>
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 27 Oct 1998 18:44:01 -0800
From: nouser@nohost.nodomain (Thomas)
Subject: Re: Not to start a language war but..
Message-Id: <tz8ogqxl826.fsf@aimnet.com>

In article <slrn738img.e4b.spam@riffraff.plig.net> spam@browser.org (Rob Partington) writes:

   > My issue with Perl: it has a load of visual clutter and after filtering

   So get a syntax highlighting editor like vim, elvis, or emacs?

Is there a Perl mode for Emacs now that doesn't get confused by the
various quoting conventions in Perl?  The latest modes I have
been able to find still had problems distinguishing quoted from
unquoted text in some circumstances, and still would incorrectly
indent code in some cases if there were open parens or brackets
left in quoted text.

Thomas.



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

Date: 28 Oct 1998 06:47:45 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Not to start a language war but..
Message-Id: <716emh$390$7@client3.news.psi.net>

Klaus Schilling (Klaus.Schilling@home.ivm.de) wrote on MDCCCLXXXIV
September MCMXCIII in <URL:news:874ssp2zyr.fsf@ivm.de>:
++ John Call <johnc@interactive.ibm.com> writes:
++ > 
++ > As for me and what I do, Perl has the BEEF!
++ 
++ Is there a version that vegetarians can understand?


Perl has nuts.
Perl is cheesy.
Perl is sunny-side up.
Perl is fruity.
Perl has soybeans.



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


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

Date: 27 Oct 98 20:47:09 PST
From: airjus@netscape.net (Justin Wilde)
Subject: Off the beaten path
Message-Id: <19981028044709.13971.qmail@www0e.netaddress.usa.net>

I have developed a multi-page online sales system with Perl.  Near the en=
d of
the process, the customer fills in his information, hits the "Complete
Transaction" button, and all the info is passed to a final script which
verifies it all, gives it to the database, waits for an Accept or Decline=

response, then creates an html page with either 'Congrats, heres your
receipt',or a 'Sorry' message.

If the user hits the Reload button on the last page, it results in a dupl=
icate
purchase, though.  I don't have any control over the database code, or I'=
d
just do duplication checking there.

Is there a way to throw an independent "database-communication" script be=
tween
the other two which is never seen by the browser (and therefore not subje=
ct to
'reload' button)? In other words, does Perl provide a way to call and pas=
s
info to another 'behind-the-scenes' perl script which handles the actual
purchase, then passes the info to a final "Results" html-generation scrip=
t?

This may sound like a cgi- or browser-related issue, but I don't believe =
it is
completely.  I'm kinda stuck now and I hope Perl has capabilities to hand=
le
this.  I hope to avoid creating/reading/writing temporary data files on t=
he
webserver if there's a cleaner way to do it.  Please point me in the righ=
t
direction.

Regards,
     Justin


____________________________________________________________________
More than just email--Get your FREE Netscape WebMail account today at htt=
p://home.netscape.com/netcenter/mail



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

Date: 27 Oct 98 20:48:34 PST
From: airjus@netscape.net (Justin Wilde)
Subject: Off the beaten path
Message-Id: <19981028044834.7433.qmail@www0m.netaddress.usa.net>

I have developed a multi-page online sales system with Perl.  Near the en=
d of
the process, the customer fills in his information, hits the "Complete
Transaction" button, and all the info is passed to a final script which
verifies it all, gives it to the database, waits for an Accept or Decline=

response, then creates an html page with either 'Congrats, heres your
receipt',or a 'Sorry' message.

If the user hits the Reload button on the last page, it results in a dupl=
icate
purchase, though.  I don't have any control over the database code, or I'=
d
just do duplication checking there.

Is there a way to throw an independent "database-communication" script be=
tween
the other two which is never seen by the browser (and therefore not subje=
ct to
'reload' button)? In other words, does Perl provide a way to call and pas=
s
info to another 'behind-the-scenes' perl script which handles the actual
purchase, then passes the info to a final "Results" html-generation scrip=
t?

This may sound like a cgi- or browser-related issue, but I don't believe =
it is
completely.  I'm kinda stuck now and I hope Perl has capabilities to hand=
le
this.  I hope to avoid creating/reading/writing temporary data files on t=
he
webserver if there's a cleaner way to do it.  Please point me in the righ=
t
direction.

Regards,
     Justin


____________________________________________________________________
More than just email--Get your FREE Netscape WebMail account today at htt=
p://home.netscape.com/netcenter/mail



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

Date: 27 Oct 1998 23:13:16 -0600
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <71695c$f0a@fohnix.metronet.com>

Russ Allbery <rra@stanford.edu> writes:
) 
) [...] Perl and C's handling of years
) is illogical *in the context of human handling of years in dates*.  Ilya's
) certainly correct from the theoretical perspective that any given start of
) epoch is as good as any other, [...]

And the epoch for Unix dates is 1970 so if the motivation for
$year-1900 was _not_ the near-sighted desire to easilly have
2-digit years for the next few decades, then the choice would
have been $year-1970 instead.

$year-1900 was chosen to make it easier to write code that
wouldn't work past Y2K.  It is still possible to write
"Y2K-compliant code" using $year-1900, just choosing to
not subtract 1900 in the first place would have made bad
code harder and good code easier.

Now if we admit that in the Perl FAQ maybe we won't have to
argue it as much here?

What, was tm_year originally of type C<char>?  Then we could
get to year 127, I mean 2027, which is about as far as we
need to go in Unix anyway.

Tye "Still managing to mention Perl in this thread" McQueen
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Tue, 27 Oct 1998 21:55:50 -0800
From: Craig Berry <cberry@cinenet.net>
To: Jim Davis <hippie@www.grannybunt.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <Pine.GSO.3.95.981027215418.22701A-100000@hollywood.cinenet.net>

[cc'd to cited author]

On Tue, 27 Oct 1998, Jim Davis wrote:

> In article <712vnc$6o$2@marina.cinenet.net> you wrote:
> : existence, is mere coincidence.  In 1908 it would have returned 1 digit,
> : in 2000 it will return 3 digits.
> 
> ...and in 1900, it would've returned "false"  :)

Hrm...perhaps the tm_year field should be renamed to tm_year_not_1900? :)

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."



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

Date: Tue, 27 Oct 1998 23:20:32 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem with Win32 reg exp
Message-Id: <1dhkws9.oxbalu32j3ggN@bay1-204.quincy.ziplink.net>

Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:

> Try this (works for me on Gurusamy Sarathy Perl 5.004_02 on Win95):
> 
> perl -e "while(<>) {s/foo/bar/gi; print;}" -i.bak test.txt
> 
> The -p switch doesn't work (for me) on win32 (I don't know why),
> so I have to manually put in a while loop.

You must be doing something wrong.  -p works fine in any port of Perl.
It wouldn't be a very good port if -p didn't work, would it?

perl -pi.bak -e "s/foo/bar/gi" test.txt

> The single quotes for the -e switched Perl code doesn't work (for me)
> on win32 (I don't know why), so I have to use double quotes.

Because win32 is a different operating system from Unix, and uses quotes
differently on the command line.  As you discovered, on win32 you have
to use double quotes instead of single quotes.

> You won't get it to do what you want (I think) with any version of Perl
> without the 'print' statement, as is documented for the -i switch in
> perldoc perlrun .

Well, yes, if you don't output anything, you don't get any output.
Imagine!

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: 27 Oct 1998 23:38:29 -0600
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: Problem with Win32 reg exp
Message-Id: <716akl$k1m@fohnix.metronet.com>

"Tim Peter" <timpeter@primenet.com> writes:
) 
) perl -e 's/foo/bar/gi' -p -i.bak *.txt

Try:

    perl -e "s/foo/bar/gi" -p -i.bak *.txt

but that will only work if you are using a version of Perl
that does globbing of command-line arguments.

The FAQ surely told you to use "-w" when you can't figure
out why it isn't working:

    C:\> perl -w -e 's/foo/bar/gi' -p -i.bak *.txt
    Useless use of a constant in a void context at -e line 1.

In future, you can also add "-d" to help figure out why it failed:

    C:\> perl -d -e 's/foo/bar/gi' -p -i.bak *.txt
    [...]
    main::(-e:1):   's/foo/bar/gi'
      DB<1> x @ARGV
    0 '*.txt'

Notice that the single quotes are being passed to Perl so
that the Perl code is:

    's/foo/bar/gi'

not

    s/foo/bar/gi

Just what "-w" warned me about.

And on my version of Perl, @ARGV is just "*.txt", not a list
of all files matching *.txt.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Tue, 27 Oct 1998 23:20:33 -0500
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: RFC - Signature
Message-Id: <1dhkx9x.gm5phpa1iwu0N@bay1-204.quincy.ziplink.net>

Bill Jones, FCCJ Webmaster <webmaster@fccj.org> wrote:

> Anybody have ideas about shortening this a bit?
> (My first 'official' attempt :)
> 
> Thx!
> -Sneex- 
> ______________________________________________________________________
> Bill Jones  |  904/632-3089  |  http://www.fccj.org/cgi/mail?webmaster
> ----------------------------------------------------------------------
> $perlRulez = "FCCJ Webmaster";
> if ($perlRulez =~ /(F)(C)(C)(J)( )(W)(e)(b)(m)(a)(s)(t)(e)(r)/) {
>     print "$4", chr(ord($12)+1), "$11$12$5", uc($10), chr(ord($9)+1),
>         chr(ord($14)-3), "$12", lc(chr(ord($1)+2)), reverse($14,$13),
>         "$5", uc(chr(ord($14)-2)), "$13$14", chr(ord($9)-1), "$5",
>         uc(chr(ord($7)+3)), "$10", chr(ord($10)+2),chr(ord($9)-2),
>         reverse($14,$13), "\n"; }


Unnecessary parens, quotes, whitespace, and reverse.

$perlRulez="FCCJ Webmaster";
$perlRulez=~/(F)(C)(C)(J)( )(W)(e)(b)(m)(a)(s)(t)(e)(r)/&&
  print$4,++($a=$12),$11,$12,$5,uc$10,++($b=$9),chr ord($14)-3,$12,
    chr ord($1)+34,$13,$14,$5,chr ord($14)-34,$13,$14,chr ord($9)-1,
    $5,chr ord($7)-29,$10,lc$2,++($c=lc$4),$13,$14,"\n";


By using ^ instead of chr and ord, you could reduce it quite a bit
further.  That's probably too easy, though.

-- 
 _ / '  _      /         - aka -         rjk@coos.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Tue, 27 Oct 1998 23:15:40 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: sorting a hash by values (sorry if this is a stupid question)
Message-Id: <s99617.3kf.ln@flash.net>

just (elmo@innocent.com) wrote:


: i'm really new to perl and i'm making a genuine effort to teach myself
: it without bothering u kind ppl, 


   You should redouble your efforts then, as they appear ineffective.


: but i've got stuck so pls forgive me if
: this is a stupid question.


   It is not a stupid question.

   It is, however, a question that has been asked already time
   and time again.

   It is what is known as a Frequently Asked Question. 


   Perl FAQ,  part 4:

      "How do I sort a hash (optionally by value instead of key)?"




P.S. You should get that shift key fixed.


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


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

Date: Wed, 28 Oct 1998 03:35:34 GMT
From: mvanier@my-dejanews.com
Subject: Syntactic flexibility (was: Re: psychology of language choice (was Re: language war ...))
Message-Id: <7163e7$lne$1@nnrp1.dejanews.com>

<disclaimer>
I am not flaming perl or any other language.  People should use whatever
language they feel most comfortable/productive in.  Can't we all just get
along?
</disclaimer>

I agree with most of Uri Guttman's observations on language choice, even
though he's a perler and I'm a pythonist :-)  One thought occurred to me
that I thought I'd share.

Many perl fans really seem to like perl's syntactic flexibility i.e. the
ability to express essentially the same construct in different ways.
Clearly, this is a personal choice, but I wonder... why stop there?  Perl
does have many ways to do the same thing, but it still has a finite set.
For instance, there are many different control structures built into perl,
but AFAIK no way to add new ones of your own.  Contrast this with, say,
scheme or dylan where the macro system is powerful enough to allow
programmers to define their own control structures (or anything else).  For
instance, I find it amusing that in guile scheme I can do this:

(define def define)
(def (square x) (* x x))
(square 10)
100

You've created a new name for the fundamental defining word!  Not that this
is useful per se, but it shows that scheme takes perl's "no limits"
philosophy one step further wrt syntax.  Whether this is a good thing or
not can be debated endlessly (and pointlessly); my feeling is that it's
useful for designing an embedded language or for code only you will use,
and probably bad otherwise.  But again, if you *really feel* that syntactic
flexibility is that important, why not add a macro system to perl?

Mike


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 27 Oct 1998 22:59:57 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: USE declaration for modules in remote directories
Message-Id: <dc8617.3kf.ln@flash.net>

Tom Hill (tjhill@flash.net) wrote:
: I've tried many different variations of the syntax...


   ... but you're not going to show any of them to us?

   Can't help much if we can't see the code...


   If all of your variations used 'USE' as in your Subject: header,
   then try 'use'. Perl is case sensitive.


: I've created a module that will not be run from a directory of the /perl
: directory, but from a completely separate place.


   I'm not sure I understand what you're saying there, but I'm
   wondering if maybe this Frequently Asked Question is your
   question:

   Perl FAQ, part 8:

      "How do I keep my own module/library directory?"

   Does what it says there help?


: I'm testing the module and scripts on ActiveState on Win95, but it will run
: on a Solaris machine with the module in another remote directory.

: docs, faqs, et. al. have not pointed me to the correct solution.


   Oh. I guess it doesn't help then...


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


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

Date: Tue, 27 Oct 1998 21:57:38 -0800
From: "Tom Hill" <tjhill@flash.net>
Subject: Re: USE declaration for modules in remote directories
Message-Id: <716bnd$psr$1@excalibur.flash.net>

 ... and then I found it...

Thanks for the effort Tad.

Eventually found what I needed in The Perl Cookbook regarding "use lib".

Thanks again

Tad McClellan wrote in message ...
>Tom Hill (tjhill@flash.net) wrote:
>: I've tried many different variations of the syntax...
>
>
>   ... but you're not going to show any of them to us?
>
>   Can't help much if we can't see the code...
>
>
>   If all of your variations used 'USE' as in your Subject: header,
>   then try 'use'. Perl is case sensitive.
>
>
>: I've created a module that will not be run from a directory of the /perl
>: directory, but from a completely separate place.
>
>
>   I'm not sure I understand what you're saying there, but I'm
>   wondering if maybe this Frequently Asked Question is your
>   question:
>
>   Perl FAQ, part 8:
>
>      "How do I keep my own module/library directory?"
>
>   Does what it says there help?
>
>
>: I'm testing the module and scripts on ActiveState on Win95, but it will
run
>: on a Solaris machine with the module in another remote directory.
>
>: docs, faqs, et. al. have not pointed me to the correct solution.
>
>
>   Oh. I guess it doesn't help then...
>
>
>--
>    Tad McClellan                          SGML Consulting
>    tadmc@metronet.com                     Perl programming
>    Fort Worth, Texas




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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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