[19667] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1862 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 3 14:06:03 2001

Date: Wed, 3 Oct 2001 11:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1002132313-v10-i1862@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 3 Oct 2001     Volume: 10 Number: 1862

Today's topics:
        $x =~ s/search/replace/ on temporary w/o changing $x (anonimus cowerd)
    Re: Accessing Files on Client PC <jurgenex@hotmail.com>
        Accurate timing <bberube@versus.com>
    Re: Accurate timing (Mark Jason Dominus)
    Re: Accurate timing <jurgenex@hotmail.com>
    Re: Accurate timing nobull@mail.com
    Re: binmode with "perl -p" doesn't work (Malcolm Dew-Jones)
    Re: Calling function with hash values as key-value argu (Miko O'Sullivan)
    Re: Calling function with hash values as key-value argu nobull@mail.com
    Re: carriage return <min_c_lee@yahoo.com>
        Courtesy post for TPJ <djberge@qwest.com>
    Re: CPAN module and local directory <fred@nospam.com>
    Re: Efficient code? <darkon@one.net>
    Re: filehandles between functions <bart.lateur@skynet.be>
    Re: filehandles between functions <joe+usenet@sunstarsys.com>
        func prototype enforcement with sub refs (Paul Balyoz)
    Re: GIF encoding <bart.lateur@skynet.be>
    Re: GIF encoding <pne-news-20011003@newton.digitalspace.net>
    Re: GIF encoding <pne-news-20011003@newton.digitalspace.net>
        Joining 3-D arrays (Dimitri)
    Re: Joining 3-D arrays (Randal L. Schwartz)
    Re: Joining 3-D arrays <dtweed@acm.org>
    Re: many file search and replace (Windows) (Malcolm Dew-Jones)
        opening directories <catherine2.mullen@uwe.ac.uk>
    Re: Passing arguments to subs nobull@mail.com
    Re: passing parameters between perl cgi scripts <jurgenex@hotmail.com>
    Re: Perl 5.6.0 bug: best workaround? nobull@mail.com
    Re: Pixel Color at particular coordinate <pne-news-20011003@newton.digitalspace.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 3 Oct 2001 08:01:18 -0700
From: johngooglegroups@kumpf.org (anonimus cowerd)
Subject: $x =~ s/search/replace/ on temporary w/o changing $x
Message-Id: <a2ea4487.0110030701.2f31662@posting.google.com>

I tried to search deja (google) on this, but coming up with search terms
was quite difficult.

I did find a message by david henderson subject: thoughts on =~ s///
date: 1999/03/23
in comp.lang.perl.moderated, and there were 3 replies, but, alas, no answer.

So, exactly what i want to do is this:

sub some_func {
}
$x = "some string";

# start the code i want to 'fix'
{
  my $tmp = $x;
  $tmp =~ s/some/another/;
  some_func $tmp;
}
# end the code i want to fix

Except: i want to do it in all one line, w/o having
to specify $tmp myself.

Eg, what i would like to work (but dosent) is this:

some_func $x =~ s/some/another/;

BUT have it not modify $x, but instead create a
automatic temporary, execute the s///, and then pass that to some_func().

I suppose i could do this;

  some_func scalar (($tmp=$x) =~ s/some/another,$tmp)

which assigns $x to $tmp, then runs the s/// on $tmp, and then
returns the second term, $tmp, because of the explicit scalar contxt, 
but it's still awkward.

Thanks.


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

Date: Wed, 3 Oct 2001 06:56:32 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Accessing Files on Client PC
Message-Id: <3bbb1912@news.microsoft.com>

"Niall" <Niall.e@no.usa.spam.net> wrote in message
news:g7xu7.525$Wz5.1671@nsw.nnrp.telstra.net...
> Is it possible to use perl to check for a file on the client machine.

Well, yes, depending on how client and server are connected and what
protocol is used.

> We want a client to visit a website. This website has to be check that a
> file exists, and then launch that file.

"Visit" how? Using a web browser like IE, Lynx, or Navigator?
Are you seriously asking if some web site can check for the existance
of/read/execute an arbitrary file on the client computer? You must be
kidding. This would be a crime in many countries.

If you role your own protocol and install some program on the client
computer with the permission of the user things are different, of course.
Another option (which is not portable of course) would be to use OCX (aka
AktiveX controls).

However, nothing of this has anything to do with Perl whatsoever.

jue




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

Date: Wed, 3 Oct 2001 10:41:29 -0400
From: "Neb" <bberube@versus.com>
Subject: Accurate timing
Message-Id: <tsFu7.35555$Z2.518384@nnrp1.uunet.ca>

Hi,

I have a script that I want to calculate its total running time from start
to finish.  It takes less than a second to run, so I can't use the time()
function to calcule it.  Is there a way to get milliseconds?

Thanks in advance,

Neb





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

Date: Wed, 03 Oct 2001 15:04:19 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Accurate timing
Message-Id: <3bbb28f0.122b$2a3@news.op.net>

In article <tsFu7.35555$Z2.518384@nnrp1.uunet.ca>,
Neb <bberube@versus.com> wrote:
>Is there a way to get milliseconds?

Get the Time::HiRes module.  
-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print


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

Date: Wed, 3 Oct 2001 09:12:01 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Accurate timing
Message-Id: <3bbb38d3@news.microsoft.com>

"Neb" <bberube@versus.com> wrote in message
news:tsFu7.35555$Z2.518384@nnrp1.uunet.ca...
> I have a script that I want to calculate its total running time from start
> to finish.  It takes less than a second to run, so I can't use the time()
> function to calcule it.  Is there a way to get milliseconds?

Please see PerlFAQ8:   How can I measure time under a second?
A simple
    perldoc -q time
displays the answer as the 5th entry

jue




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

Date: 03 Oct 2001 18:24:32 +0100
From: nobull@mail.com
Subject: Re: Accurate timing
Message-Id: <u9d7443acv.fsf@wcl-l.bham.ac.uk>

"Neb" <bberube@versus.com> writes:

> Is there a way to get milliseconds?

FAQ: "How can I measure time under a second?"

> Thanks in advance,

If you are going to do anything in advance, it should be to check the
FAQ.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 3 Oct 2001 10:32:28 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: binmode with "perl -p" doesn't work
Message-Id: <3bbb4bac@news.victoria.tc.ca>

Joe Smith (inwap@best.com) wrote:
: In article <a73bcad1.0110012300.53397c24@posting.google.com>,
: John Lin <johnlin@chttl.com.tw> wrote:
: >So, do you think my proposal of "perl -b" switch for binmode is considerable?
: >What can I contribute to make it happen?

: Go to the perl5-porters mailing list archive and read a couple weeks worth
: of messages to see how patches and program enhancements are handled.

: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2001-09/threads.html

: Fetch a copy of the current development sources, using something like
:   rsync -avz rsync://ftp.linux.activestate.com/perl-current/ src/perl-5.7.x/
: and read Porting/patching.pod and the various README files.

: Modify the sources to get "-b" working the way you want it.
: Create a binmode.t file to test the new functionality.
: Create a unified 'diff' comparing the original files versus your mods.
: Submit the diff to the perl5-porters list and hope it is accepted.
: 	-Joe
: --
: See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


This identical problem and the identical suggested solution have been
discussed in the past, so maybe work has already been done and could be
found if you search in the right place.  (I have no idea where the "right
place"  would be.) 



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

Date: 3 Oct 2001 07:38:07 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: Re: Calling function with hash values as key-value arguments
Message-Id: <db27ea77.0110030638.2ded95f0@posting.google.com>

Joonas Paalasmaa <joonas@olen.to> wrote in message news:<3BBADD06.B3E035CD@olen.to>...

> my %hash = {"first" => "1",
>             "second" => "2"};

That's not going to give you what you're hoping for.  It will attempt
to assign the string representation of an anonymous hash (which you
created by surrounding everything with {}) and no value.  If you have
warnings turned on (which you should) you'll get a warning about an
odd number of elements being assigned to a hash. You probably want
something more like this:

  my %hash = ("first" => "1",
            "second" => "2");

> So how can I call the function with arguments passed like below.
> 
> function("first" => "1",
>          "second" => "2");

Like this:

 function(%hash);

-miko


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

Date: 03 Oct 2001 18:16:04 +0100
From: nobull@mail.com
Subject: Re: Calling function with hash values as key-value arguments
Message-Id: <u9itdw3aqz.fsf@wcl-l.bham.ac.uk>

Joonas Paalasmaa <joonas@olen.to> writes:

> fruiture wrote:
> > 
> > "Joonas Paalasmaa" <joonas@olen.to> wrote:
> > > I have variable sized hash %hash and i want to call a function with it's
> > > values as key-value args.
> > > my %hash = {"first" => "1",
> > >             "second" => "2"};
> > >
> > >
> > > So how can I call the function with arguments passed like below.
> > >
> > > function("first" => "1",
> > >          "second" => "2");
> > 
> > function( %hash ); #that's why i love Perl
> 
> What should I do if I the first argument is normal argument and the
> following arguments are
> key-value pairs.
> Like:
> 
> function(firstarg, "first" => "1", "second" => "2");

I suspect that you'd do well to understand what's happening rather
than behave as if there's no pattern.

If a function has no prototype then the whole argument list is
effectively evaluated as a single list.

A hash evaluated in a list context is simply unrolled.

So you can do:

function(firstarg, %hash);

This will work so long as firstarg() when called in a list context
always returns exactly one item.  If firstarg() can return a list of a
length other than 1 then wierd things would happen.

To avoid this:

function(scalar(firstarg), %hash);

Of course this is not an issue if function() has a suitable prototype.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 03 Oct 2001 17:59:41 GMT
From: "Michael" <min_c_lee@yahoo.com>
Subject: Re: carriage return
Message-Id: <hmIu7.972$Le.33232@sea-read.news.verio.net>


"Benjamin Goldberg" <goldbb2@earthlink.net> wrote in message
news:3BB664A3.9FD73CC1@earthlink.net...
> Michael wrote:
> >
> > "Graham Wood" <Graham.T.Wood@oracle.com> wrote in message
> > news:3BB317B0.21D68E64@oracle.com...
> > > Michael wrote:
> > >
> > > > How do I replace carriage ruturn character with a space?
> > > > s/\n/ /g or s/\r\n/ /g can't work.
> > > >
> > > > Michael
> > >
> > > In what context are you trying to do this and why can't they work?
> > >
> > > Graham Wood
> > >
> >
> > I am trying to handle the content in "comments" area (in a text box
> > from form submission), replacing all carriage returns with spaces, so
> > it turns into a regular string that can be carried into a query
> > string, then a remote server can accept it.
>
> There's a lot more to do to make an arbitrary string into something
> which will be safe to use as part of a query string than just changing
> newlines to spaces.
>
> You need to urlencode it... convert those characters which are special
> in urls into url-escapes... which are %xx where xx is a two digit
> hexidecimal number.
>
> I would advise against doing roll-your-own.  Use a library.
>
> use URI::Escape;
> my $encoded = uri_escape( $textarea );
>
> --
> "I think not," said Descartes, and promptly disappeared.

That module is not included in my library, where can I download
the code?

Michael




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

Date: Wed, 3 Oct 2001 09:06:00 -0500
From: "Mr. Sunblade" <djberge@qwest.com>
Subject: Courtesy post for TPJ
Message-Id: <0TEu7.672$_d5.61604@news.uswest.net>

From The Perl Journal website:

Notice to All Past TPJ Contributors

We're producing a CD of The Perl Journal archives. We'd like to include all
past content, but we need your help. If you've not received an email
requesting permission to include your article(s) on this CD, or if you've
not responded to that email, please contact me as soon as possible. Thank
you.
Amber Ankerholz
aankerholz@cmp.com

Regards,

Mr. Sunblade




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

Date: Wed, 03 Oct 2001 15:51:21 +0100
From: fred56 <fred@nospam.com>
Subject: Re: CPAN module and local directory
Message-Id: <ed9mrtcrr0dgn4d6col48iejivh6hmnmn1@4ax.com>

On 2 Oct 2001 13:34:59 -0700, miko@idocs.com (Miko O'Sullivan) wrote:

>I know how to install something to a local directory.
>
>I know how to use the CPAN module (at least minimally).
>
>I DON'T know how to use the CPAN module to install a module to a local
>directory.
>
>Could somebody point me in the right direction on using the CPAN
>module to install a module in my own custom directory instead of to
>the machine's global Perl library (which I don't and shouldn't have
>rights to).
>
>-Miko

#!/usr/bin/perl -w

BEGIN { $home = glob("~closey"); }
use lib  "$home/secure/perl/inc";
use dbhtmlt;
use cookie;


try that its the only way iv found of doing it some one else may know
a better way but that works for me so.....




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

Date: Wed, 03 Oct 2001 14:38:53 -0000
From: David Wall <darkon@one.net>
Subject: Re: Efficient code?
Message-Id: <Xns912F6C3A3D691darkononenet@207.126.101.97>

logan@cs.utexas.edu (Logan Shaw) wrote on 03 Oct 2001:

> In article <Xns912EA25175D93darkononenet@207.126.101.97>,
> David Wall  <darkon@one.net> wrote:
>>"S Warhurst" <s.warhurst@rl.ac.uk> wrote on 02 Oct 2001:
>>
>>> 1) If one wants to go through each line of a 100,000 line text file,
>>> looking for one of 50 different strings, is the quickest way to do
>>> it 
> 
>>I'd put the strings in a list and then loop over the list.
>>
> Another way you can do this is to quote the regular expressions using
> "qr".  I think this will be faster since they won't have to keep
> getting rebuilt into finite state machines[1].  

Good point -- I didn't think of that.  Thanks!

-- 
David Wall
darkon@one.net


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

Date: Wed, 03 Oct 2001 13:51:54 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: filehandles between functions
Message-Id: <nr5mrtoai3krj7dmvlsip6i597uovml2vj@4ax.com>

Les Ander wrote:

>I would like to write a routine called get_one_line(), which
>gets the next line. However, i am not sure how i can acheive this
>as i need to know where i am in the file.
>
>my $file_pos=0;
>sub some_routine
>{
>   my $fileHandle=new FileHandle("<$infile");
>   while(my $line=&get_next_line($fileHandle)){
>       process($line);
>   }
>  close ($fileHandle);
>}
>
>sub get_next_line
>{
>   return_the_line_after_the_file_pos;
>...
>}
>I guess what I am asking is : How do i pass around a file handle.

First of all: don't close the file.

Second: pass around your $fileHandle scalar. It will do.

Third: You can use the <$fileHandle> syntax to read a line. Or you can

	print $fileHandle @data; # no comma!

to print to it.

-- 
	Bart.


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

Date: 03 Oct 2001 12:36:41 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: filehandles between functions
Message-Id: <m33d50llye.fsf@mumonkan.sunstarsys.com>

Ilmari Karonen <iltzu@sci.invalid> writes:

> Another variant, which works for pipes and other funny things too:
> 
>   sub slurp ($) {
>       my $fh = shift;
>       return <$fh> if wantarray;
>       local $/;
>       return <$fh> unless -s $fh;
                            ^^^^^^

-s on a stream typically returns the number of bytes in 
the stream's buffer, which is rarely zero.

  % cat bigfile | perl -wle 'print -s STDIN'
  4096
  % perl -wle 'print -s STDIN' < bigfile
  37310
  % wc bigfile
  632    2434   37310 bigfile

In any event, it is unreliable to use -s $fh for pipes and
other funny things.

-- 
#include <stdio.h> /* requires gcc and *nix
use strict; system("cc -x c $0") and die $?; open C, "|a.out" or die $! . q*/
int main(void){char s[32]; remove("a.out"); printf("%s/C hacker\n",fgets(s,32,
stdin))}/*; print C "Just another Perl"; close C or die $?; #*/



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

Date: 3 Oct 2001 10:41:02 -0700
From: paul.a.balyoz@intel.com (Paul Balyoz)
Subject: func prototype enforcement with sub refs
Message-Id: <bd587db3.0110030941.6bc30954@posting.google.com>

How do you enforce function prototypes when you call a subroutine
from a reference to it?  It ignores my prototype.  Example:

    use strict;
    sub a($) {
        print @_;
    }
    $b = \&a;
    &$b(1,2,3,4);

Is there any way to get a reference to a sub without using the "&" syntax?
That would probably fix it....

In Perl 5 when you call a sub with & in front, it uses some kind of
Perl 4 calling mode (ignores the prototype) which I think is biting me here.

       -- paul


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

Date: Wed, 03 Oct 2001 13:48:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: GIF encoding
Message-Id: <bo5mrtsgg4qtf4r3hcafpqqigdqpje72e3@4ax.com>

Martien Verbruggen wrote:

> If YOU, the user,
>are producing LZW compressed GIF right now, then YOU, the user, are
>responsible for making sure that your software is covered by at least
>one license from Unisys. 

Question: do you need a license to READ the GIF format?

-- 
	Bart.


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

Date: Wed, 03 Oct 2001 20:00:57 +0200
From: Philip Newton <pne-news-20011003@newton.digitalspace.net>
Subject: Re: GIF encoding
Message-Id: <1fkmrto7hs7bkjtn16l8un59c9mfisd4ct@4ax.com>

On Wed, 3 Oct 2001 21:56:50 +1000, mgjv@tradingpost.com.au (Martien
Verbruggen) wrote:

> What people don't seem to realise is that _if_ they use and install that
> older version of libgd and/or GD, that _they_ (the users) are
> responsible for obtaining the correct license from Unisys to be able to
> produce LZW compressed GIF.

Older version of libgd do not write LZW compressed GIFs (at least, the
medium-age ones before the thing was discontinued -- I don't know about
the very old ones). They use a different algorithm which is,
nevertheless, accepted by GIF readers. Don't ask me about the details.

So I think Boutell dropped the support not because he had to, but
because there could have been a hassle anyway.

> PS. When people ask for the old GD modules again, use this argument.

Not really relevant for libgd AIUI.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: Wed, 03 Oct 2001 20:01:50 +0200
From: Philip Newton <pne-news-20011003@newton.digitalspace.net>
Subject: Re: GIF encoding
Message-Id: <iikmrtc0euviu625p1af3nlccfq3ob8lsg@4ax.com>

On Wed, 03 Oct 2001 13:48:42 GMT, Bart Lateur <bart.lateur@skynet.be>
wrote:

> Martien Verbruggen wrote:
> 
> > If YOU, the user,
> >are producing LZW compressed GIF right now, then YOU, the user, are
> >responsible for making sure that your software is covered by at least
> >one license from Unisys. 
> 
> Question: do you need a license to READ the GIF format?

Opinions differ.

Short answer: I've read that some people believe the patent only covers
LZW encoding, not decoding, but apparently Unisys has claimed their
patent covers both. Or something.

Long answer: ask a patent lawyer.

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

Date: 3 Oct 2001 08:51:26 -0700
From: mauroid@csi.forth.gr (Dimitri)
Subject: Joining 3-D arrays
Message-Id: <a3ebf7b8.0110030751.106c5f80@posting.google.com>

I have a 3-D array @array, i.e. the elements are accessed like this :

$element = $array[$i][$j][$k];

I want to join the elements of this array. Something faster than but
equivalent to this loop :

    $out = "";
    for ($i = 0; $i < @array; $i++) {
        for ($j = 0; $j < @{$array[$i]}; $j++) {
            $out .= join("", @{$array[$i][$j]});
        }
    }

Any ideas?

Thanks,
Dimitri


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

Date: 03 Oct 2001 09:08:59 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Joining 3-D arrays
Message-Id: <m1ofno66zo.fsf@halfdome.holdit.com>

>>>>> "Dimitri" == Dimitri  <mauroid@csi.forth.gr> writes:

Dimitri> I have a 3-D array @array, i.e. the elements are accessed like this :
Dimitri> $element = $array[$i][$j][$k];

Dimitri> I want to join the elements of this array. Something faster than but
Dimitri> equivalent to this loop :

Dimitri>     $out = "";
Dimitri>     for ($i = 0; $i < @array; $i++) {
Dimitri>         for ($j = 0; $j < @{$array[$i]}; $j++) {
Dimitri>             $out .= join("", @{$array[$i][$j]});
Dimitri>         }
Dimitri>     }

    sub recurjoin {
      join "", map { ref $_ ? recurjoin(@$_) : $_ } @_;
    }

    my $result = recurjoin(@array);

print "Just another Perl hacker,"
-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Wed, 03 Oct 2001 16:47:42 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: Joining 3-D arrays
Message-Id: <3BBB3FDF.5937397C@acm.org>

Dimitri wrote:
> I have a 3-D array @array, i.e. the elements are accessed like this :
> 
> I want to join the elements of this array. Something faster than but
> equivalent to this loop :

For a fixed number of dimensions, this is about as simple as it gets:

$out = join '', map {join '', map {join '', @$_} @$_} @array;

-- Dave Tweed


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

Date: 3 Oct 2001 10:24:17 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: many file search and replace (Windows)
Message-Id: <3bbb49c1@news.victoria.tc.ca>

Max Gravitt (magrav@wnt.sas.com) wrote:
: That worked, but it would not allow me to use wildcards when
: specifying the file names.. . for example....

: perl -pi.bak -e "s/oldstring/newstring/g" *.txt

: ...gives the error "Can't open *.txt: No such file or directory".


No, NT doesn't handle wild cards the same way as a unix shell.

There are several ways to handle this.

== the for command

	for %%n in (*.txt) do perl -pi.bak ...etc... %%n

(one or two %'s depending on whether its interactive or in a batch file)


== use dir + perl to make a command for each file

	dir /b *.txt  | perl -pe "s/^/perl ...etc... /" > temp.bat
	call temp.bat

== or install a version of sh for NT.  There's at least one standalone
version, plus cygwin has shell versions, and then run

	sh -c "perl -pi.bak -e "s/oldstring/newstring/g" *.txt"

(some of the " need to be changed).



I have used all of the above techniques, but none of the specific
examples shown above are tested, so some minor details may be wrong.


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

Date: Wed, 3 Oct 2001 14:29:28 GMT
From: "catherine mullen" <catherine2.mullen@uwe.ac.uk>
Subject: opening directories
Message-Id: <GKMw94.1Mz@bath.ac.uk>

Hi kind people

The following piece of code is used to 'test'/'check' a login page to see if
the username is in the eLectures directory.

If it is the sub printFrameset is invoked

If it isn't the sub register is invoked, which is a form the user can fill
out, the results will then be saved to a directory of that username in the
eLectures directory.

This program creates directories for each user and within each of these
directories there are five more directories which store the different
objects and .sml files. One of the said directories 'uploads' stores the
files the user has selected from their computer/network/floppy disc
(whatever!)

At the same time that files are loaded into the 'uploads' directory, objects
are also created to allow the uploaded files to function, these are stored
in the 'objects directory for that user.

Another directory called 'structures' is created which in turn creates
directories, which in turn have more objects

THIS IS A VERY BRIEF OVERVIEW OF A SMALL PART OF THIS PROGRAM!

my problem:

when the code below checks the eLectures to find that username, if it finds
it a home page is printed.

I want to then check the 'eLectures\\structures'to see if the username has
any structures, if they have the normal home page can be called, if not I
want a different homepage to be invoked with more direction to uploading
files.

What do you think? Can I open more than one file and test for occupancy!?

sub testLogin {

my $username = param('username');

my $password = param('password');

open(FILE, "c:\\electures\\info\\lecturers.dat") or print "Can't DO it";

@pwd = <FILE>;

close FILE;

@match = grep {/^$username/} @pwd;

(my @results) = split(/\t/, $match[0]);

if ($username eq $results[0]) {

#makeCookie($username);

printFrameset($username);

}else {

register();

}

}





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

Date: 03 Oct 2001 18:06:47 +0100
From: nobull@mail.com
Subject: Re: Passing arguments to subs
Message-Id: <u9lmis3b6g.fsf@wcl-l.bham.ac.uk>

David Wall <darkon@one.net> writes:

> "David K. Wall" <darkon@one.net> wrote on 30 Sep 2001:
> > Isn't a standard way to do this is to use a dispatch table,
> 
> I gather from the echoing silence that my post was either (a) a post not 
> needing a reply

Yes.  We all asumed the "isn't a standard way?" was rhetorical.  Yes
it is the standard way.  Although you'll see some detractors like
myself who believe that since a Perl symbol table is just a hash
there's sometimes (but not often) a case for using a symbol table as a
dispatch table i.e. using symbolic references but prefixing them with
a package name.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 3 Oct 2001 07:01:37 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: passing parameters between perl cgi scripts
Message-Id: <3bbb1a42@news.microsoft.com>

"hugo" <hugo@fractalgraphics.com.au> wrote in message
news:3BBADF44.71F2808B@fractalgraphics.com.au...
> I have a perl CGI script where I have a text field where the user can
> type in his/her name. I can easily get the content of the text field of
> course - if the name of the textield is "login" I can get it by:
[...]
> $user = query->param('login');
>
> However, later on the first perl script calls a second one. How do I
> pass the value of $user to the second cgi-script?

If script A calls script B then why not pass the argument as ordinary
command line parameter?
    system "B.pl $user";

jue





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

Date: 03 Oct 2001 17:59:13 +0100
From: nobull@mail.com
Subject: Re: Perl 5.6.0 bug: best workaround?
Message-Id: <u9r8sk3bj2.fsf@wcl-l.bham.ac.uk>

David Coppit <newspost@coppit.org> writes:

> sub foo(\@@) { die }
> 
> sub bar { foo(@_) }
> 
> eval { bar() };
> eval { bar() };

> Attempt to free unreferenced scalar at crash.pl line 6.
> Segmentation fault (core dumped)

> The problem seems to be the prototype. I can remove it and perl doesn't 
> core dump.

No the prototype is not, I believe, relevant.  The relevant thing is
that you take a reference to @_.  The following simplified test case
produces the error too:

 sub foo { die }
 sub bar { foo(\@_) }
 eval { bar() };
 bar();

My advice is avoid anything that takes a reference to @_.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 03 Oct 2001 20:02:55 +0200
From: Philip Newton <pne-news-20011003@newton.digitalspace.net>
Subject: Re: Pixel Color at particular coordinate
Message-Id: <blkmrt0tvbvmqf017jrmbn74nr5pi60817@4ax.com>

On Wed, 03 Oct 2001 11:00:55 +0200, Philip Newton
<pne-news-20011003@newton.digitalspace.net> wrote:

> PPM

(That's Portable PixMap, not the Perl Package Manager, in case anyone
was confused.)

Cheers,
Philip
-- 
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.


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

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


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