[10398] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3991 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 16 12:01:35 1998

Date: Fri, 16 Oct 98 09:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 16 Oct 1998     Volume: 8 Number: 3991

Today's topics:
    Re: Activestate != standard distribution? [Was Re: Win3 (Nathan V. Patwardhan)
    Re: Compiling perl with mingw32 (Nathan V. Patwardhan)
        Flushing HTML to output before forking off another proc nkaiser@my-dejanews.com
        getting all matches (Emmanuel Michon)
    Re: getting all matches <jdf@pobox.com>
        grrrrr, why not while(<blah>) <daniel.vesma@thewebtree.com>
    Re: grrrrr, why not while(<blah>) <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: grrrrr, why not while(<blah>) <dmitri@sw-systemekarlhickl.de>
    Re: grrrrr, why not while(<blah>) <daniel.vesma@thewebtree.com>
    Re: I'm looking for someone who wants to write a comple (Steve Linberg)
        Is this a bug? <rjanosi@uakron.edu>
    Re: Is this a bug? <jdf@pobox.com>
    Re: New to programming - New to Perl - LOST!!!! <jdporter@min.net>
        newbie: getting the wrong month out of localtime() <M.Duivesteijn@cao-horeca.nl>
    Re: newbie: getting the wrong month out of localtime() <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Perl5 on Solaris reading MS Access Database <thaynes@openlinksw.co.uk>
    Re: problem with "use lib" dturley@pobox.com
    Re: Redirecting output of the system function <olafm@seas.upenn.edu>
        Reference to a sort function (Richard S. Holmes)
    Re: Reference to a sort function <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: Reference to a sort function (Richard S. Holmes)
    Re: Reference to a sort function <mkahn@vbe.com>
        Replacement for 'at'? <upsetter@shore.net>
    Re: Reverse foreach loop <aqumsieh@matrox.com>
        Sending mail via cgi/perl with a file attached to it <marcov@ctrl-v.nl>
    Re: Sending mail via cgi/perl with a file attached to i <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: sort with dynamic sort expression help (Andrew M. Langmead)
    Re: telnet session from PERL script??? <tonylabb@infonline.net>
        Trouble scheduling Perl scripts with WinNT AT command <gbuehler@NOSPAMmed.unc.edu>
    Re: What are these? dave@mag-sol.com
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Fri, 16 Oct 1998 14:40:31 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Activestate != standard distribution? [Was Re: Win32 Net::FTP trouble]
Message-Id: <zVIV1.693$1K4.162989@news.shore.net>

William D. Reardon (wdr1@pobox.com) wrote:

: 	I'm confused - as a result of the "one Perl" effort, isn't the
: ActiveState port & the standard distribution one and the same?

I'd suggest building 5.005_02 with mingw32/egcs.  libnet (Net::FTP,
etc), LWP, pTk, Term::ReadKey, Curses, etc., work just great!  The
"Perl Compiler" doesn't seem to work -- but I've no need for it
anyways.  :-)

What I'm suggesting is that if you find something "broken" under the
pre-compiled version (like Net::FTP), there are (even free)
alternatives which will work for you if you don't mind build your own
Perl.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: Fri, 16 Oct 1998 14:53:53 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Compiling perl with mingw32
Message-Id: <56JV1.697$1K4.162989@news.shore.net>

massimobalestra@my-dejanews.com wrote:

: I am trying to compile Perl with mingw32 (with gcc) but I've got some
: compilation errors.

I need the following information from you:
	- are you running Windows 95/98 or NT?
	- which version of mingw32 are you using?  egcs version?
	- which version of Perl are you attempting to build?
	- have you looked at the perl5-porters mailing list archive to
	  get the mingw32/egcs patches for perl5.005_01 (win32.h)?  I
	  believe that this patch can also be applied to 5.005_02's
	  win32.h with minor changes.

In fact, I'm almost certain that the _environ error (that's fixed with
the patch) is what's causing you problems.  See below:

: c:\mingw32\\include\tchar.h:138: `TCHAR' previously declared here win32.c: In
: function `win32_environ': win32.c:1345: `_environ' undeclared (first use in
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Note that this is not a warning but an error.

Here's the patch:

-- BEGIN PATCH.  DO NOT USE THIS LINE.

--- win32.h.~1  Wed Sep 09 10:22:48 1998
+++ win32.h     Wed Sep 09 12:53:14 1998
@@ -27,6 +27,7 @@ typedef long long __int64;
 /* GCC does not do __declspec() - render it a nop 
  * and turn on options to avoid importing data 
  */
+#  undef __declspec
 #  define __declspec(x)
 #  ifndef PERL_OBJECT
 #    define PERL_GLOBAL_STRUCT
@@ -213,7 +214,6 @@ struct mgvtbl {
                         \
 
 typedef long           uid_t;
 typedef long           gid_t;
-#define _environ       environ
 #define flushall       _flushall
 #define fcloseall      _fcloseall

-- END PATCH. DO NOT USE THIS LINE.

Basically, install the patch utility for win32.  There's a link to
it on Sarathy's website.  If you don't want to install the patch
utility, you're doomed.  :-)  Kidding.  Just edit win32.h by hand and
add the line with the '+', and remove the line with the '-'; you can
also comment them out with /* ... */  Normally I wouldn't suggest
patching anything by hand, but ... this patch involves two lines so
it's not horrible to do by hand.  :-)

After patching, I'd suggest doing a 'dmake clean' (make sure that all
the .o files and 'mini' directory are gone) and 'dmake' again.  Don't
forget to 'dmake test'.  This should cure the problem.

--
Nate Patwardhan|root@localhost
"Fortunately, I prefer to believe that we're all really just trapped in a
P.K. Dick book laced with Lovecraft, and this awful Terror Out of Cambridge
shall by the light of day evaporate, leaving nothing but good intentions in
its stead." Tom Christiansen in <6k02ha$hq6$3@csnews.cs.colorado.edu>


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

Date: Fri, 16 Oct 1998 14:22:30 GMT
From: nkaiser@my-dejanews.com
Subject: Flushing HTML to output before forking off another process
Message-Id: <707kr5$ii5$1@nnrp1.dejanews.com>

I have a script where I print something out, fork something off, then print
again.  My problem is, I want the first thing I print to be displayed to the
browser first. But, it seems to wait until the system call is done and display
everything all at once. ie:

select (STDOUT);
print "Please wait, this may take a minute....";
$|=1;
my $output = `/bin/exe`;
print "Here is the output: $output";

How can I make this so it prints in sequence....

Thanks,
Neal

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


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

Date: 16 Oct 1998 14:01:18 GMT
From: michon@news.enst.fr (Emmanuel Michon)
Subject: getting all matches
Message-Id: <707jje$m52$1@enst.enst.fr>

regexps are generally used to know if yes or no,
a string matches a regexp and when the regexp
engine finds one match, it stops.

is there a way to get all possible matches?
maybe in other languages than perl?

--
Manu (http://www.enst.fr/~michon)


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

Date: 16 Oct 1998 17:02:42 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: michon@news.enst.fr (Emmanuel Michon)
Subject: Re: getting all matches
Message-Id: <m3ww60o8h9.fsf@joshua.panix.com>

michon@news.enst.fr (Emmanuel Michon) writes:

> regexps are generally used to know if yes or no, a string matches a
> regexp and when the regexp engine finds one match, it stops.

This is a weird oversimplification.  Have you read the documentation
for Perl's regex support?  You'll find it in perlre and perlop, not to
mention perlfaq6.

> is there a way to get all possible matches?

That depends on what you mean.

  @matched_stuff = /(some_pattern)/g;

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 16 Oct 1998 15:59:47 +0100
From: "Daniel Vesma" <daniel.vesma@thewebtree.com>
Subject: grrrrr, why not while(<blah>)
Message-Id: <36275f46.0@news.thefree.net>

As far as I can tell, the following code should work. It doesn't. The
while() doesn't start.

It produces the following out put

variables set - file opened - while about to be started - end while -
Thank you Daniel

But the while loop doesn't start. Please help, I'm going mad :-(

Daniel Vesma
www.thewebtree.com/daniel-vesma



#!/usr/bin/perl
use CGI qw(param);

print "Content-type: text/html\n\n";

$Name = param("name");
$ID = param("id");
$Pass = param("password");
$DateForRetrievel = param("date");
$Message = param("message");
$gotRecord = 0;

print "variables set - ";

$file = "names.txt";

open(INDB, "<$file");

print "file opened - ";

print "while about to be started - ";
while(<INDB>)
  {
         print "while started - ";
         ($tempONE, $tempTWO, $tempTHREE) = split(/^/, $_);
  print "file split - ";
         $Email =  $tempTHREE;
         print "Email set to $Email - ";
         $gotRecord = 1;
         print "gotRecord set to $gotRecord - ";


      }

print "end while - ";




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

Date: 16 Oct 1998 17:12:56 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <837ly0sfpj.fsf@vcpc.univie.ac.at>

Re: grrrrr, why not while(<blah>), Daniel
<daniel.vesma@thewebtree.com> said:

Daniel> open(INDB, "<$file");

Daniel> print "file opened - ";

Untested open().

Trap that and things should become somewhat clearer.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Fri, 16 Oct 1998 17:37:23 +0200
From: Dmitri Levitin <dmitri@sw-systemekarlhickl.de>
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <36276833.1837E19@sw-systemekarlhickl.de>

Daniel Vesma wrote:

> As far as I can tell, the following code should work. It doesn't. The
> while() doesn't start.
>
> It produces the following out put
>
> variables set - file opened - while about to be started - end while -
> Thank you Daniel
>
> But the while loop doesn't start. Please help, I'm going mad :-(
>
> Daniel Vesma
> www.thewebtree.com/daniel-vesma
>
> #!/usr/bin/perl
> use CGI qw(param);
>
> print "Content-type: text/html\n\n";
>
> $Name = param("name");
> $ID = param("id");
> $Pass = param("password");
> $DateForRetrievel = param("date");
> $Message = param("message");
> $gotRecord = 0;
>
> print "variables set - ";
>
> $file = "names.txt" # ; forgotten?

> open(INDB, "<$file");

You should always(!) check your open, wether it really works. You should
say rather so:open(INDB, "<$file") || die "Cannot open $file: $!";If
you'll see the program saying Cannot open "names.txt" while running,
that means the file wasn't opened and your while(....) doesn't have
anything to do.

> print "file opened - ";
>
> print "while about to be started - ";
> while(<INDB>)
>   {
>          print "while started - ";
>          ($tempONE, $tempTWO, $tempTHREE) = split(/^/, $_);
>   print "file split - ";
>          $Email =  $tempTHREE;
>          print "Email set to $Email - ";
>          $gotRecord = 1;
>          print "gotRecord set to $gotRecord - ";
>
>       }
>
> print "end while - ";

  Dmitri



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

Date: Fri, 16 Oct 1998 16:19:12 +0100
From: "Daniel Vesma" <daniel.vesma@thewebtree.com>
Subject: Re: grrrrr, why not while(<blah>)
Message-Id: <362763cf.0@news.thefree.net>

Thanks to Edgar Sigal.

He asked if I had data in the correct format in the names file.

I checked, I had up-loaded in Binary (whoops). I uploaded in ASCII and it
works. DOH!

Daniel Vesma
www.thewebtree.com/daniel-vesma




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

Date: Fri, 16 Oct 1998 11:56:46 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: I'm looking for someone who wants to write a complete perl-script (for free)
Message-Id: <linberg-1610981156460001@ltl1.literacy.upenn.edu>

In article <3621e50b.23824482@news.uunet.be>, bdispa@bigfoot.com
(PsIoNnEkE) wrote:

> Hi !

Hi, Patrick!  (You're not fooling me again!)
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Fri, 16 Oct 1998 10:02:00 -0400
From: Renata Janosi <rjanosi@uakron.edu>
Subject: Is this a bug?
Message-Id: <362751D8.3F52@uakron.edu>

Hello all,
The following sed command works, but the perl command doesn't. What did
I do wrong or is this a perl bug?

===========================================================
% cat xx
===========================================================
-rw-rw-r--   1 misjad   idf          1952 Sep  8 10:23 AK
 
-rw-rw-r--   1 misjad   idf           488 Sep  8 10:24 AN
-rw-rw-r--   1 misjad   idf           244 Sep  8 10:28 AS|
-rw-rw-r--   1 misjad   idf           732 Sep  8 10:28 AU

===========================================================
% sed -e '/^ *$/d' -e 's/[^|]$/&|/g' xx
===========================================================
-rw-rw-r--   1 misjad   idf          1952 Sep  8 10:23 AK|
-rw-rw-r--   1 misjad   idf           488 Sep  8 10:24 AN|
-rw-rw-r--   1 misjad   idf           244 Sep  8 10:28 AS|
-rw-rw-r--   1 misjad   idf           732 Sep  8 10:28 AU|

===========================================================
% perl -ne 'unless ( /^ *$/ ) { s/[^|]$/$&|/; print }' < xx
===========================================================
-rw-rw-r--   1 misjad   idf          1952 Sep  8 10:23 AK|
-rw-rw-r--   1 misjad   idf           488 Sep  8 10:24 AN|
-rw-rw-r--   1 misjad   idf           244 Sep  8 10:28 AS|
|-rw-rw-r--   1 misjad   idf           732 Sep  8 10:28 AU|

-- 

If you like it heavy, you need "Girth".
http://www.wintersbane.com


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

Date: 16 Oct 1998 16:59:41 +0200
From: Jonathan Feinberg <jdf@pobox.com>
To: rjanosi@uakron.edu
Subject: Re: Is this a bug?
Message-Id: <m3zpawo8ma.fsf@joshua.panix.com>

Renata Janosi <rjanosi@uakron.edu> writes:

> % perl -ne 'unless ( /^ *$/ ) { s/[^|]$/$&|/; print }' < xx

Try this:

  % perl -wlne 'next if /^\s*/; chomp; s/([^|])$/$1|/; print';

As for why your one-liner doesn't work, I'm as mystified as you.  I
traced it with perl -Dr, and the results are confusing.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Fri, 16 Oct 1998 11:02:30 -0400
From: John Porter <jdporter@min.net>
Subject: Re: New to programming - New to Perl - LOST!!!!
Message-Id: <36276006.B759275E@min.net>

Mark Cain wrote:
> 
> Strange...
> I just tried http://www.ActiveState.com/ActivePerl/download/APi504e.exe and
> was 'told' the file did not exist.  But, I downloaded it yesterday!
> 
> 1 minute later I went to http://www.ActiveState.com/ActivePerl/download.htm
> then typed over the 'download.htm' with 'download/APi504e.exe' and a
> download dialog box opens asking me where to save the file.
> 
> After this, the URL
> http://www.ActiveState.com/ActivePerl/download/APi504e.exe works!
> 
> As to whether or not it is ready for prime time I do not know.  I do know
> that downloading build 504 fixed a bug that I was experiencing in 502 with
> NET::FTP.

Sounds like it's checking its Referer, to insist that you come from the
download page in order to access the binary file.

-- 
John "Gashlycrumb" Porter

"A fugitive and lurid gleam
  Obliquely gilds the gliding stream." -- EG


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

Date: Fri, 16 Oct 1998 16:34:32 +0200
From: "Marcel Duivesteijn" <M.Duivesteijn@cao-horeca.nl>
Subject: newbie: getting the wrong month out of localtime()
Message-Id: <707lgs$j2u$1@news2.xs4all.nl>

Hello,

I am using Perl under windows 95 (and NT).
I tried to print the current date with the localtime function.
To my surprise I got the wrong month. I got month 9 instead of 10.
My code looks like this:

($sec,$min,$hour,$mday,$mon,$year,$wday,$ydat,$isdst) = localtime();
print "$mon \n";
print localtime(), "\n";

output:

9
3018161699852881

My date and time under windows95 (or NT) are right. October 16 1998. Also
the system time is OK.

I also tried another machine running windows NT, same result.
I am using Gurusamy's latest version of Perl, but i also tried the
Activestate version that comes with the NT resource kit, same result.
I even tried the localtime object from the time module that came with this
distribution but the localtime->mon() also gave me month 9 instead of 10.

Does anybody know this problem?
Am i doing something wrong here?

Thanks in advance.
Marcel Duivesteijn





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

Date: 16 Oct 1998 16:37:26 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: newbie: getting the wrong month out of localtime()
Message-Id: <83af2wshcp.fsf@vcpc.univie.ac.at>

Re: newbie: getting the wrong month out of localtime(),
Marcel <M.Duivesteijn@cao-horeca.nl> said:

Marcel> Hello, I am using Perl under windows 95 (and NT).  I
Marcel> tried to print the current date with the localtime
Marcel> function.  To my surprise I got the wrong month. I
Marcel> got month 9 instead of 10.  My code looks like this:

The month field goes from 0 .. 11 (presumably for the
historic reason that C subscripts start at 0).

The Date::DateCalc and Date::Manip modules are helpful here.

tony


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

Date: Fri, 16 Oct 1998 15:23:49 GMT
From: Tim Haynes <thaynes@openlinksw.co.uk>
Subject: Re: Perl5 on Solaris reading MS Access Database
Message-Id: <707oe5$opd$1@nnrp1.dejanews.com>

Hi,

Just as a direct pointer, OpenLink will connect your perl programs to Access;
the drivers (ODBC, UDBC and JDBC) are available for free evaluation download
from <http://www.openlinksw.com/> onwards.

Best regards,

Tim Haynes
Support Consultant
OpenLink Software Web: <http://www.openlinksw.co.uk/>
Universal Database Connectivity Technology Providers


In article <3626534E.3832@gecm.com>,
  jim.michael@gecm.com wrote:
> scott@softbase.com wrote:
> >
> > Stephen Palmer (slpalmer@NOSPAM.flex.net) wrote:
> > > After a careful search of DejaNews, and CPAN, I'm still at a loss as to
>
> Not careful enough...
>
> > There is no good way to do this, because Access doesn't work in a
> > networked environment. Access is also not a multiuser database like
>
> Try a dejanews search in the old database on 'unix perl access openlink'
>
> HTH.
>
> Cheers,
>
> Jim
>

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


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

Date: Fri, 16 Oct 1998 14:20:12 GMT
From: dturley@pobox.com
Subject: Re: problem with "use lib"
Message-Id: <707kmr$ig0$1@nnrp1.dejanews.com>

In article <7059hg$d05$1@csnews.cs.colorado.edu>,
  tchrist@mox.perl.com (Tom Christiansen) wrote:
> In comp.lang.perl.misc, Randal Schwartz <merlyn@stonehenge.com> writes:
> :	use constant MY_LIB => /u/lib/perl;
>
> I think not.

Okay, I'll bite. Perhaps a bit of explanation for the resrt of us. :-)

cheers,

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


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

Date: 16 Oct 1998 11:56:59 -0400
From: Olaf Meyer <olafm@seas.upenn.edu>
Subject: Re: Redirecting output of the system function
Message-Id: <gbjww60xzxw.fsf@saul.cis.upenn.edu>

mgjv@comdyn.com.au (Martien Verbruggen) writes:

> In article <gbjyaqhxj79.fsf@saul.cis.upenn.edu>,
> 	Olaf Meyer <olafm@seas.upenn.edu> writes:
> > Is there an easy way of redirecting the output of commands
> > executed via the system function?
> > 
> > I would for example like to store the ouput in a string variable,
> > similar to the bash command
> >   files=`pick -from whoever +folder`
> 
> Have you actuall ever looked at perl's documentation? You should...

Yes I have. I actually have the Perl Programming book, but this
actually doesn't mention what the online documentation has available!
I didn't know about perldoc, now I do and the next time I'll read
it first before posting :-)

> 
> # perldoc -f system

Cool.

Thanks anyway,

Olaf
-- 
 Olaf Meyer                       | mailto://olafm@seas.upenn.edu    |    _~o
 Computer and Information Science | http://www.seas.upenn.edu/~olafm |  _-\_<,
 University of Pennsylvania       |				     | (*)/'(*)
 Philadelphia, PA 19104-6389, USA | PGP: finger -l olafm@seas.upenn.edu


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

Date: 16 Oct 1998 10:15:21 -0400
From: rsholmes@rodan.syr.edu (Richard S. Holmes)
Subject: Reference to a sort function
Message-Id: <xzc7ly0bnk6.fsf@rodan.syr.edu>

How come this doesn't work:

     $sorttype = \&backwards;

     print sort &$sorttype ( Camel, Aardvark, Gnu, Zebra ), "\n";

     sub backwards {
	 $b cmp $a;
     }

but this does:

     $sorttype = \&backwards;

     print sort somehow ( Camel, Aardvark, Gnu, Zebra ), "\n";

     sub somehow {
	 &$sorttype;
     }

     sub backwards {
	 $b cmp $a;
     }

 ... ?

-- 
- Rich Holmes
  Syracuse, NY /             We have more important things to do...
  Newport News, VA           Censure and move on!  Sign the petition at
  rsholmes@earthling.net     <http://www.moveon.org>


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

Date: 16 Oct 1998 16:34:45 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
To: rsholmes@rodan.syr.edu
Subject: Re: Reference to a sort function
Message-Id: <83d87sshh6.fsf@vcpc.univie.ac.at>

Re: Reference to a sort function, Richard
<rsholmes@rodan.syr.edu> said:

Richard> How come this doesn't work:

Richard> $sorttype = \&backwards;
Richard> print sort &$sorttype ( Camel, Aardvark, Gnu, Zebra ), "\n";
Richard> sub backwards { $b cmp $a; }

Richard> but this does:

Richard> $sorttype = \&backwards;
Richard> print sort somehow ( Camel, Aardvark, Gnu, Zebra ), "\n";
Richard> sub somehow { &$sorttype; }
Richard> sub backwards { $b cmp $a; }

Because if you say &$sorttype you've actually evaluated the
subroutine, then passed the result to sort as the sort
comparison function.  But you want to tell sort which sub to
use only when the sort is actually happening.

So the following works:

    $sorttype = 'backwards';
     
    print sort $sorttype qw( Camel Aardvark Gnu Zebra ), "\n";
     
    sub backwards { $b cmp $a; }

But as usual I suspect TMWOWTDI

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: 16 Oct 1998 10:56:22 -0400
From: rsholmes@rodan.syr.edu (Richard S. Holmes)
Subject: Re: Reference to a sort function
Message-Id: <xzc67dkblnt.fsf@rodan.syr.edu>

Aaah... the veil lifts.  Thank you.
-- 
- Rich Holmes
  Syracuse, NY /             We have more important things to do...
  Newport News, VA           Censure and move on!  Sign the petition at
  rsholmes@earthling.net     <http://www.moveon.org>


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

Date: Fri, 16 Oct 1998 10:39:50 -0500
From: Mark Kahn <mkahn@vbe.com>
Subject: Re: Reference to a sort function
Message-Id: <362768C6.FB0D27BE@vbe.com>

Richard S. Holmes wrote:
> 
> How come this doesn't work:
> 
>      $sorttype = \&backwards;
> 
>      print sort &$sorttype ( Camel, Aardvark, Gnu, Zebra ), "\n";
> 
>      sub backwards {
>          $b cmp $a;
>      }
> 
> ... ?
>

Try this:

print sort {&$sorttype} ( Camel, Aardvark, Gnu, Zebra ), "\n";
-- 
Mark Kahn
mkahn@vbe.com


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

Date: Fri, 16 Oct 1998 15:33:43 GMT
From: Art Cohen <upsetter@shore.net>
Subject: Replacement for 'at'?
Message-Id: <rHJV1.709$1K4.166854@news.shore.net>


I'm sure somebody has had to deal with this before, but searching for "at"
on DejaNews wasn't too productive... :-\

I would like (in an ideal world) for a CGI script to schedule a task using
"at". However, it seems pretty common for the user "nobody" to be denied
access to "at". 

The obvious alternative, I guess, would be to fork off a process that
just waits until a certain time and then does what I want (sleeping in
30-minute chunks or some such), but I don't know if there are any
unforseen pitfalls to this approach.

Any suggestions? TIA.

--Art


-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Fri, 16 Oct 1998 10:17:49 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Reverse foreach loop
Message-Id: <Pine.SUN.3.96.981016101625.28168A-100000@tigre.matrox.com>

On Fri, 16 Oct 1998 darrensw@my-dejanews.com wrote:

    > Hi
    > 
    > I am using a simple foreach loop;
    > e.g. foreach $i (0 .. $#array)
    > 
    > What I actually need is for it to go in reverse;
    > 
    > e.g. foreach $i ($#array .. 0)

Then just reverse it!

	foreach $i (reverse (0 .. $#array))

    > 
    > Can this be done?

Everything can be done in Perl, and in more than one way too!

    > Thanks for all help,
    > 
    > regards
    > 
    > Darren

Hope this helps,
--
Ala Qumsieh               email: aqumsieh@matrox.com
ASIC Design Engineer      phone: (514) 822-6000 x7581
Matrox Graphics Inc.      (old) webpage :
Montreal, Quebec          http://www.cim.mcgill.ca/~qumsieh



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

Date: Fri, 16 Oct 1998 16:45:25 +0200
From: Marco Vlemmings <marcov@ctrl-v.nl>
Subject: Sending mail via cgi/perl with a file attached to it
Message-Id: <36275C04.927E4B64@ctrl-v.nl>

Hi,

I have made a script which sends a email.
But now i want to attach a file to the email.
Can anybody help me.

Thanks



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

Date: 16 Oct 1998 17:09:21 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Sending mail via cgi/perl with a file attached to it
Message-Id: <8390igsfvi.fsf@vcpc.univie.ac.at>

Re: Sending mail via cgi/perl with a file attached to it,
Marco <marcov@ctrl-v.nl> said:

Marco> Hi, I have made a script which sends a email.  But
Marco> now i want to attach a file to the email.  Can
Marco> anybody help me.

Yes :-)

Try the MIME::Tools modules.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Fri, 16 Oct 1998 14:34:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: sort with dynamic sort expression help
Message-Id: <F0xCI7.5DA@world.std.com>

lr@hpl.hp.com (Larry Rosler) writes:

>my $sortsub = eval "sub { $sorteq }"; # Note double-quotes to cause
>                                      # substitution here for $sorteq.
># Now 'sortsub' points to the equivalent of your sort comparison.
>print sort { &$sortsub } 'a' .. 'z', "\n";

A simple optimization on this, which will avoid the overhead a
coderef dereference on every comparison would be:

{
  # temporarily define a subroutine named "sortsub"
  local(*sortsub) = eval "sub { $sorteq }";
  # and give that name as the comparison routine.
  print sort sortsub 'a' .. 'z', "\n";
}
-- 
Andrew Langmead


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

Date: Fri, 16 Oct 1998 11:19:43 -0400
From: Tony Labbiento <tonylabb@infonline.net>
Subject: Re: telnet session from PERL script???
Message-Id: <3627640F.8E6439A6@infonline.net>

robertpower@my-dejanews.com wrote:
> 
> I am trying to write a short script which will initiate a telnet session, send
> UNIX commands to this newly initiated session, and which will receive the
> response for the command back from the telnet session. After this has been
> completed the telnet session should be released.
> 
> Is this possible?  Any suggestions?

Most Definately! Get yourself a copy of the Net::Telnet module if you
don't already have it. You can find it on CPAN. I have personally
written several applications using this module.

> 
> I'd greatly appreciate any help...
> 
> Robert
> 
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

-- 
			****************************************
			*    Tony Labbiento                    *
			*    Infinity Online, Inc.             *
			****************************************


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

Date: Fri, 16 Oct 1998 11:16:19 -0400
From: "Georg Buehler" <gbuehler@NOSPAMmed.unc.edu>
Subject: Trouble scheduling Perl scripts with WinNT AT command
Message-Id: <707o3i$305$1@camel25.mindspring.com>

I've read in the FAQs that folks use the "at" command in WinNT to schedule
events. However, I'll be gosh-durned if I can make it work in my system.

I've tried every permutation of the commands that I can think of:
at 03:00 perl e:\weblogs\getdailylog.pl
at 03:00 cmd /c perl e:\weblogs\getdailylog.pl
at 03:00 "e:\perl\5.00502\bin\MSWin32-x86-object\bin\perl.exe
e:\weblogs\getdailylog.pl"

Nothing seems to work. I know my script is working properly, it runs without
a hitch from a command-line, manaully. The schedule service is working, I
can successfully schedule NT commands, just not my Perl scripts.
What am I missing?

--Georg Buehler
gbuehler@elsitech.com






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

Date: Fri, 16 Oct 1998 15:12:16 GMT
From: dave@mag-sol.com
Subject: Re: What are these?
Message-Id: <707nof$nri$1@nnrp1.dejanews.com>

In article <36272BF6.7C47DDCC@ia.pw.edu.pl>,
  Abdallah Ally <aally@ia.pw.edu.pl> wrote:
> What are these foo,qw and how should I use command shift

foo - is a nonsense word that we use when we need to use an example filename
or something like that. e.g. print $foo.

qw - quote words. A short cut for assigning lists,
     e.g. my @list = qw/This is a list/;
          is the same as
          my @list = ('This', 'is', 'a', 'list');

shift - returns the first item of a list and removes it from the list.
     e.g. (following on from the last example)
          my $thing = shift $list;
          puts 'This' in $thing and leaves @list with ('is', 'a', 'list').

hth,

Dave...

--
dave@mag-sol.com
London Perl M[ou]ngers: <http://london.pm.org/>
[Note Changed URL]

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


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

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

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