[11607] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5207 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 23 13:07:19 1999

Date: Tue, 23 Mar 99 10: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, 23 Mar 1999     Volume: 8 Number: 5207

Today's topics:
    Re: "small" problem <jim@*nospam*network-2001.com>
    Re: << string definer (Randal L. Schwartz)
    Re: << string definer <donny@impulsesoftware.com>
    Re: << string definer (Jonathan Stowe)
    Re: << string definer (Matthew Bafford)
        =?utf-8?Q?Role_for_Developer_/_Admin_upto_=C2=A340k?= <rgriffiths@homedirectory.com>
    Re: array question <aqumsieh@matrox.com>
    Re: Bad Byte Count <Michael.Cameron@REMOVETHIS.technologist.com>
    Re: CGI.pm questions (Randal L. Schwartz)
    Re: CGI.pm questions (Jonathan Stowe)
    Re: Checking Directories contents.. (Larry Rosler)
    Re: Date/Time calculation: % through current month? <dwatanab@uci.edu>
    Re: Days in Month array <dhenders@cpsgroup.com>
    Re: Extreme Newbie here needs help <haverlan@agric.gov.ab.ca>
        How do variable substitution on a string twice? <d97-muv@d.kthKEiN_SPAM.se>
    Re: How do variable substitution on a string twice? <jglascoe@giss.nasa.gov>
    Re: HTTP:Request. POST method adding HTTP/1.0 to header <donny@impulsesoftware.com>
    Re: Odd/Even <aqumsieh@matrox.com>
    Re: Perl WIN32 - How to return a DOS ErrorLevel? <cassell@mail.cor.epa.gov>
    Re: Possible values for $^O? <droby@copyright.com>
    Re: return codes in Win32 Perl haakon.alstadheim@sds.no
        Sending HTTP Referer field using perl <henrik@arkitekt-maa.dk>
    Re: Want to learn Perl <cassell@mail.cor.epa.gov>
    Re: Win32:EventLog and problems capturing data <cassell@mail.cor.epa.gov>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 23 Mar 1999 10:40:13 -0600
From: "Jim" <jim@*nospam*network-2001.com>
Subject: Re: "small" problem
Message-Id: <7d8g30$ol$1@news3.infoave.net>

Thanks very much, however I have already been emailed with a simpler way

sub start{
open(DATABASE, "$path/database.txt");
@data_info = <DATABASE>;
close(DATABASE);
print "Content-type: text/html\n\n";
@data_info = sort @data_info;
foreach (@data_info) {
($prod_cat, $prod_name, $prod, $price) = split /\|/;
if ($prod_cat ne $last_prod_cat) {
print "$prod_cat<br>\n";
$last_prod_cat = $prod_cat;
}
print "$prod_name - \$$prod.$price\n";
}
&bottom ;
}

--
Jim
-)(-


Ronald J Kimball wrote in message
<1dp3doy.dri7gzvbnm9iN@p57.block2.tc3.state.ma.tiac.com>...




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

Date: 23 Mar 1999 08:11:32 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: << string definer
Message-Id: <m1d820424r.fsf@halfdome.holdit.com>

>>>>> "Timothy" == Timothy Larson <larsot2@krypton.mankato.msus.edu> writes:

Timothy> In _Teach Yourself Perl in 21 Days_ I found a neat use of <<
Timothy> to define multiline strings.  I tried it with Perl 5.004 on
Timothy> linux and it doesn't work.  OK, the book is an old one, so I
Timothy> was thinking maybe this use of << has been dropped.  Does
Timothy> anyone know?  I haven't found a mention of it so far.  I just
Timothy> thought it would be a convenient way to make my comment block
Timothy> into a string that could be shown to the user if something
Timothy> goes wrong.

You'll have to give us an example that "doesn't work", because it
works for nearly everybody else. :) << has been in Perl since Perl 0
or 1, and there are no plans to drop it from any future release of
Perl that I'm aware of.

print <<END =~ /./gismos;
Just another Perl hacker,
END

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 23 Mar 1999 16:28:18 GMT
From: Donny Widjaja <donny@impulsesoftware.com>
Subject: Re: << string definer
Message-Id: <36F7C1C0.228DD58F@impulsesoftware.com>

Timoty, 

When you use <<, you must not put extra space in front of the word
'END'.  It might work for some people (I don't know), but it does not
work when I put extra space.

I cut this from the Randal's posting.
Working :
print <<END =~ /./gismos;
Just another Perl hacker,
END

NOT Working:
print <<END =~ /./gismos;
Just another Perl hacker,
   END

Timothy Larson wrote:
> 
> In _Teach Yourself Perl in 21 Days_ I found a neat use of << to define
> multiline strings.  I tried it with Perl 5.004 on linux and it doesn't
> work.  OK, the book is an old one, so I was thinking maybe this use of
> << has been dropped.  Does anyone know?  I haven't found a mention of it
> so far.  I just thought it would be a convenient way to make my comment
> block into a string that could be shown to the user if something goes
> wrong.
> Tim
> 
> PS  I'll keep looking and post if I find anything.


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

Date: Tue, 23 Mar 1999 16:23:56 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: << string definer
Message-Id: <36f7bdb0.26476477@news.dircon.co.uk>

On 23 Mar 1999 15:23:29 GMT, larsot2@krypton.mankato.msus.edu (Timothy
Larson) wrote:

>In _Teach Yourself Perl in 21 Days_ I found a neat use of << to define
>multiline strings.  I tried it with Perl 5.004 on linux and it doesn't
>work.  

Thats strange.

>     OK, the book is an old one, so I was thinking maybe this use of
><< has been dropped.  Does anyone know? 

Yep sure do - those old here docs are still working at least they were
this morning when I used them.

>                                        I haven't found a mention of it
>so far.  

You must have missed the perldata manpage.  Or alternatively on of
several threads here in the last week that have mentioned them.

>         I just thought it would be a convenient way to make my comment
>block into a string that could be shown to the user if something goes
>wrong.

Amongst a wide variety of other uses yes ...

/J\


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

Date: Tue, 23 Mar 1999 16:35:19 GMT
From: dragons@scescape.net (Matthew Bafford)
Subject: Re: << string definer
Message-Id: <slrn7fffad.126.dragons@scescape.net>

23 Mar 1999 15:23:29 GMT -- Timothy Larson <larsot2@krypton.mankato.msus.edu>:
-> In _Teach Yourself Perl in 21 Days_ I found a neat use of << to define
-> multiline strings.  I tried it with Perl 5.004 on linux and it doesn't
-> work.  OK, the book is an old one, so I was thinking maybe this use of
=> << has been dropped.  Does anyone know?  I haven't found a mention of it
-> so far.  I just thought it would be a convenient way to make my comment
-> block into a string that could be shown to the user if something goes
-> wrong.

Try posting your code if you'd like us to figure out what's wrong with it.

<<HERE documents do indeed work.

-> Tim

--Matthew


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

Date: Tue, 23 Mar 1999 17:05:01 -0000
From: "Robert Griffiths" <rgriffiths@homedirectory.com>
Subject: =?utf-8?Q?Role_for_Developer_/_Admin_upto_=C2=A340k?=
Message-Id: <922209005.21422.0.nnrp-08.c29fdced@news.demon.co.uk>

Role for Developer / Admin

Salary: upto 40k
Situated: Islington, London N1
The primary role is the developer:

The work for this role will not start in earnest for a couple of months:

o7 Maintenance of current set-up b
o7 Building of modules to add on to the current site
o7 Managing the outsourcing of other modules
o7 Developing a targeting advertising mechanism
The secondary role but more heavily weighted during the first couple of
months is the Admin:

o7 Preparation of data for upload b
language
o7 Data upload and Db admin b
o7 Page modifications b
o7 Query construction and report generation
o7 Site tracking

Nice to have:

o7 Networking skills and familiarity with NT Back Office Server
o7 Experience of using perl for text extraction


For both posts reply: CV and Current Salary details to:
Rupert Connelly (fax: 0171 288 1644)

Or reply on line via rconnelly@homedirectory.com
and c.c. rgriffiths@homedirectory.com







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

Date: Tue, 23 Mar 1999 10:55:15 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: array question
Message-Id: <x3ysoaw6w0s.fsf@tigre.matrox.com>


Mark P. wrote:
> $file_extension =~ /\.(.*)$/is;

1) The /i isn't needed.
2) The /s isn't needed.
3) Your match is greedy.
4) You assign the extension to $1, but never use $1.

HTH,
Ala



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

Date: Tue, 23 Mar 1999 17:05:19 +0000
From: Michael Cameron <Michael.Cameron@REMOVETHIS.technologist.com>
To: bryan.c.spann@nationsbank.com
Subject: Re: Bad Byte Count
Message-Id: <36F7C9CF.AC667E50@REMOVETHIS.technologist.com>

bryan.c.spann@nationsbank.com wrote:

> scalar($privpath) = @filearr;

What is this the above for?

Problem could be OS related,  I created a big file and tried to stat it and it
all worked fine (using Linux):

[mcameron@synteks d]$ ls -l big.file
-rwxr-xr-x   1 mcameron users    120000000 Mar 23 16:56 big.file
[mcameron@synteks d]$ perl -e '$sz = -s "big.file"; print "$sz\n"'
120000000
[mcameron@synteks d]$


HTH,

Michael



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

Date: 23 Mar 1999 08:07:22 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: CGI.pm questions
Message-Id: <m1hfrc42bp.fsf@halfdome.holdit.com>

>>>>> "melLA" == melLA  <melLA@west.net> writes:

>> And, if you have CGI-related Perl questions, the best place to ask is
>> comp.infosystems.www.authoring.cgi, not here.
>> 
>> Name: Randal L. Schwartz

melLA> Randall, you're wrong. If you had not snipped my original post
melLA> beyond comprehension, it would have shown that my specific
melLA> questions were germaine to the CGI.pm module, which is written
melLA> in Perl. My questions were not CGI related in any specific
melLA> sense -- they were definitely Perl
melLA> related. comp.infosystems.www.authoring.cgi threads are not
melLA> language specific. Please try again with worthwhile advice if
melLA> you have any.

I read comp.infosystems.www.authoring.cgi (CIWAC) every day.
CGI-specific questions about Perl are best answered there, and get
answered frequently there.  Perl is used for a lot more than CGI, and
the "gentleman's agreement" between CIWAC readers and
comp.lang.perl.m* (CLPM) readers is that CGI-Perl stuff goes into
CIWAC, so that the *rest* of the Perl world can be covered in CLPM.

A little sniffing with Dejanews will confirm this.

My advice still stands.  If you want to tell me I'm wrong (while
misspelling my name), feel free. :)

Just another guy who reads waaaaayyy too many newsgroups, :)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Tue, 23 Mar 1999 16:06:46 GMT
From: gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: CGI.pm questions
Message-Id: <36f7bb0a.25798182@news.dircon.co.uk>

On Tue, 23 Mar 1999 15:33:18 GMT, melLA@west.net wrote:

>merlyn@stonehenge.com (Randal L. Schwartz) wrote:
>
>>>>>>> "melLA" == melLA  <mel@west.net> writes:
>>
>>melLA> I'm in the process of chucking my Perl 4 form-processing
>>melLA> routines and start from scratch using the magnificent CGI.pm
>>melLA> routines. I just read the entire CGI.pm documentation and have
>>melLA> some questions in that regard.
>>
>[snipped worthless recommendations]
>>
>>And, if you have CGI-related Perl questions, the best place to ask is
>>comp.infosystems.www.authoring.cgi, not here.
>>
>>Name: Randal L. Schwartz
>

Mel, I think you might come to rue your characterisation of Randals
recommendation as worthless ...

>                         Please try again with worthwhile advice if you have
>any.
>

A hostage to fortune, never mind it happens to all of us ...

>Milt
>(remove all CAPS from my e-addr)
>
OK

>x-no-archive: yes

Er what was the point of that ?
>

/J\


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

Date: Tue, 23 Mar 1999 07:53:48 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Checking Directories contents..
Message-Id: <MPG.116158ebe549e8609897ac@nntp.hpl.hp.com>

In article <36F7ABE3.24336B41@REMOVETHIS.technologist.com> on Tue, 23 
Mar 1999 14:57:39 +0000, Michael Cameron 
<Michael.Cameron@REMOVETHIS.technologist.com >says...
 ...
> if you only want plain files you can use map to create full paths and add
> another grep which includes a test on the file type, e.g.
> 
>              my @filelist = grep { -f } map {"$directory/$_" } grep {
> !/^\.\.?$/ } readdir(DIR);

Or even without a map and another grep:

   my @filelist = grep { !/^\.\.?$/ && -f "$directory/$_" }
       readdir(DIR);


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


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

Date: Tue, 23 Mar 1999 08:57:48 -0800
From: =?iso-8859-1?Q?d=E1na?= watanabe <dwatanab@uci.edu>
Subject: Re: Date/Time calculation: % through current month?
Message-Id: <36F7C7C0.1783D92F@uci.edu>

Try Time::Local

specifically the 'timelocal' function

you give it most of the output from the localtime function
and it gives you the number of seconds since 1970

so if you could do:

$sec=$min=$hour=0;
$day=1;
$month=2; #2=March
$year=1999; 

$march1st=timelocal($sec,$min,$hour,$day,$month,$year);
$april1st=timelocal($sec,$min,$hour,$day,$month+1,$year);
$now=time;

$equation=($now-$march1st)/($april1st-$march1st);


Tony Bowden wrote:

> This is quite simple once I work out how far into the current month it is...
> but actually finding that out is relatively tricky!
> 
> My basic logic is that I find out
>   a) how many seconds into the month it is
>   b) how many seconds are in this month
> 
> This obviously involves knowing
>   1) the date/time it is now
>   2) when this month started
>   3) how long this month is, _or_ 4) when next month starts
> 
> I figure that if I need to know (2) then it's easier to get (4) than
> worry about days_in_month type stuff to do 3, so I'm left with a basic
> equation of:
> 
>       now - start_of_month
>   -----------------------------
>   end_of_month - start_of_month


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

Date: 23 Mar 1999 09:41:40 -0600
From: Dale Henderson <dhenders@cpsgroup.com>
Subject: Re: Days in Month array
Message-Id: <877ls8fc23.fsf@camel.cpsgroup.com>

>>>>> "Charles" == Charles R Thompson <design@raincloud-studios.com> writes:

    Charles> I'm trying to build a timeline of days and dates when
    Charles> given a year. Leap years are messin with my code.

    Charles> How does one calculate if a given year is a leap year?

    Charles> CT

The way i've done this in the past is:

    my @lastday = (31,28,31,30,31,30,31,31,30,31,30,31); #last day of the month


    if ($mon==2 && ((!($inyear%4))&&(($inyear%100)||(!($inyear%400))))){
        #is this february and a leap year?
        $lastday=29;
    }
    else{
        $lastday=$lastday[$mon-1];
    }

probably the most unreadable suggestion i've seen so far. (But most
compact :)


-- 
Dale Henderson <mailto:dhenders@cpsgroup.com> 

"Imaginary universes are so much more beautiful than this stupidly-
constructed 'real' one..."  -- G. H. Hardy


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

Date: Tue, 23 Mar 1999 09:07:29 -0700
From: Gordon Haverland <haverlan@agric.gov.ab.ca>
To: Spencer <mgb23@vci.net>
Subject: Re: Extreme Newbie here needs help
Message-Id: <36F7BC41.C6A2D8C2@agric.gov.ab.ca>

Spencer wrote:
> 
> This may seem like a very stupid question but here goes.  I am a college
> student and like to develop basic static web pages and have developed
> one for my fathers company but i would like to add more to it with CGI
> scripting.  I was told that I could do this with the perl programming
> language ao I went out and bought the book Learning Perl by O`Reily
> publishing compnay.  Igot the book and started to read it but I am kinda
> lost.
> 
> First question, do I have to have a program or something to write with
> the perl language.

Like all languages, perl needs to be interpreted or compiled,
to produce instructions for the CPU.  The perl program
is what does this.  You have to write an ASCII text file
in the perl language, which perform the task you want
done.

> If so what program is it that I need.

You need the appropriate perl binary (executable), and an
editor that can produce an ordinary text file.

> Second question is, I am using windows 95, is perl only for unix and
> servers and stuff.

There do exist versions of perl for DOS and Windows.  I've
never used them (Windows versions).  One place to look
for help in what you are doing is
http://reference.perl.com/

The have sections there which specifically mention or
point to perl binaries for DOS and Windows, some of which
are commercial (you have to buy them).  There is also a
section there on CGI programming in perl.  Lots of other goodies.

Gordon Haverland


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

Date: 23 Mar 1999 16:24:26 GMT
From: Mikael Uvebrandt <d97-muv@d.kthKEiN_SPAM.se>
Subject: How do variable substitution on a string twice?
Message-Id: <7d8f7q$5ge$1@news.kth.se>

Is there any way to make perl do variable substitution on a string 
twice ("$a" = '$b' and "$b" = 'b_value', so "$a" = {insert magic 
here} = 'b_value')?

I have a line like this:
s/$searchstr/$replstr/g

Now, Perl will treat $replstr as double-quoted and do variable 
substitution on it. But suppose $replstr="$1" because I want to do 
something with the regex in $searchstr. What I want is for Perl to 
recognize $1 as a reference to the regex in $searchstr, instead of 
using '$1' literally as the replace string. Is there any way of 
tricking Perl into doing this?
I must have the search and replace strings in variables, because I 
don't know beforehand what they will be when the actual 
substitution is made.

Thankful for any ideas,
Micke


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

Date: Tue, 23 Mar 1999 12:34:29 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Mikael Uvebrandt <d97-muv@d.kthKEiN_SPAM.se>
Subject: Re: How do variable substitution on a string twice?
Message-Id: <36F7D0A5.3AD1F39F@giss.nasa.gov>

[courtesy copy of post sent to cited author]

Mikael Uvebrandt wrote:
> 
> Is there any way to make perl do variable substitution on a string
> twice ("$a" = '$b' and "$b" = 'b_value', so "$a" = {insert magic
> here} = 'b_value')?

check out perlfaq4: "How can I expand variables in text strings?"

but it sounds like you may be trying to do this:
"FAQ: Using a variable as a variable name"
http://www.dejanews.com/getdoc.xp?AN=437136474

	Jay Glascoe
-- 
	"I discount everything Djikstra has to say
	because he doesn't actually run his programs"

	--Rob Pike, on Djikstra's belief that bugs in
	  your program are a moral failure to prove your
	  program mathematically correct.


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

Date: Tue, 23 Mar 1999 17:51:12 GMT
From: Donny Widjaja <donny@impulsesoftware.com>
Subject: Re: HTTP:Request. POST method adding HTTP/1.0 to headerr
Message-Id: <36F7D514.C556E293@impulsesoftware.com>

I am also new with LWP module, so I am not sure if I can solve your
problem.
When I try to use a POST method, I set the content-type to
application/x-www-form-urlencoded.  
I will leave the content-length blank since this field is an optional,
and content-length represent the number of bytes in the entity-body. 
So, for your example, the content-length is NOT 2.

I hope this help.
If you need to get a good book about this topic, I recommend a "Web
Client Programming with Perl". 
http://www.amazon.com/exec/obidos/ASIN/156592214X/microsoftimageco

> I really don't want to use sockets....
> THIS    IS      MY      CODE
> $ua     =       new     LWP::UserAgent;
> $url="www.perl.com/cgi-bin/email-grabber/grabber";
> $request= new HTTP::Request("POST",$url);
> $request->header('Accept'=>'text/html');
> $request->header('Content-type'=>'text/html');
> $request->header('Content-length'=> 2);
> $content=<<Cont;
> NAME="emailaddr" VALUE="plf58\@sbh.com"
> Cont
> $request->content($content);
> print $request->as_string();
> my $response=$ua->request($request);
> 
> OPEN AND PRINT TO A FILE...


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

Date: Tue, 23 Mar 1999 11:07:51 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Odd/Even
Message-Id: <x3yr9qg6vfs.fsf@tigre.matrox.com>


comdog@computerdog.com (brian d foy) writes:

> you could use the % operator for modulo arithmetic
> 
>    $is_odd = $integer % 2 ? 1 : 0;

Well, that's equivalent to:

	$is_odd = $integer % 2;

It's probably also a bit faster, but nothing significant.

Ala



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

Date: Tue, 23 Mar 1999 09:19:05 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Perl WIN32 - How to return a DOS ErrorLevel?
Message-Id: <36F7CD09.80BF566@mail.cor.epa.gov>

Brian Moore wrote:
> 
> I know it seems simple, but having gone through the PERL for Win32 docs, I
> find nothing about returning the most basic of Windows cmd values, the
> ERRORLEVEL.

That's because only MS-DOS calls it the errorlevel.  That's the trouble with
indices.  You sometimes have to have an idea of what to look up, in order
to find what you want.  And every time I call the Psychic Friends Hotline,
they're no help either.  :-)
 
> I'm trying to use my Perl script within an existing (and complicated) DOS
> batch program, and have the batch program make decisions based on the Perl
> script results.   So I want the Perl script to return a DOS ERROLEVEL (this
> is the only way I know to reference results within a cmd shell, without
> having to write a file).  Any help is appreciated...

Take a look at the function exit.  It lets you exit the Perl program with a
return value that will be the errorlevel your DOS code sees.  Like this:

    exit 0 if $ans =~ /^[xX]/;    # lifted straight out of the camel book

But my best advice is this: seriously consider re-writing the entire batch
file as a Perl program.  I had a couple ghastly pieces of kludgy code that,
once I learned enough Perl to see what could be done, became much smaller,
much faster, much cleaner, and much better.  In fact, Perl let me easily 
extend the functionality of what had been a couple nasty little bits of
tripe.  I haven't written a shell script since.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 23 Mar 1999 17:06:48 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: Possible values for $^O?
Message-Id: <7d8hn1$5a3$1@nnrp1.dejanews.com>

In article <36F74C46.235805BB@datenrevision.de>,
  Philip Newton <Philip.Newton@datenrevision.de> wrote:
> Bart Lateur wrote:
> >
> > Philip Newton wrote:
> >
> > >Does $^O differentiate between e.g.
> > >Win95, Win98, WinNT, and Win2000?
> >
> > I think that $^O depends entirely on the Perl port, and NOT on the OS
> > itself.
> >
> > For example, Ilya's OS/2 port says it's "os2", even when run on DOS. It
> > looks like the Activestate port says "MSWin32", no matter what platform.
>
> In theory, all Perl ports can be built by fetching the CPAN source, no?
> So there must be some file in the distribution which detects the host
> operating system and tweaks some settings (is this the "hints" file?)
> So somewhere in the distribution, I assume there must be a file (or
> several files) which contain these values. Perhaps someone know which
> of the 2^n files in stable.tar.gz (or whatever) contain(s) the strings?
>

There is in fact a directory called hints, which contains a bunch of files
named things like 'solaris_2.sh'.  The Configure script uses lots of tricks
(mainly testing the existence of OS-specific files) to figure out which among
these most nearly resembles the operating system you're on, trims it down to
lose the '.sh' and the version info, and presents it as a default value for
osname.  The osname value goes into config.h and is linked into perl.  The
shell file is also run and supplies some other environment-specific stuff.

In my distribution, these are mostly Unix variants.  Most alien ports like
ActivePerl, MacPerl, VMS and Plan9 seem to do things a different way.  There
is a file for os2 though, so it's not ALL Unix.

--
Don Roby

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


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

Date: 23 Mar 1999 17:18:38 +0100
From: haakon.alstadheim@sds.no
Subject: Re: return codes in Win32 Perl
Message-Id: <upv60kwm9.fsf@sds.no>

Phil Mak <pmak@iname.com> writes:

> J|rgen,
> 
> I used both system ("del $filename");  and `del $filename`.  Neither of them
> work though.  When I use the system command, I get a return code of '256'.
> When I use the back-quote characters (i.e. `) I get a return code of '65280'.
> Any ideas?
> 
> Phil
Try 'perldoc -f system' first, it will tell you among other things:
            The return value is the exit status of the program as returned
            by the `wait()' call. To get the actual exit value divide by
            256.

Then try 'perl -e "print 256>>8"' from a command-prompt (or try
256/256, which also gives the same result) it prints "1", then try to
find documentation on the return values on internal commands of
cmd.exe or command.com, and you hit a wall.  Then try to guess. My
guess is you deleted 1 file, so del returned 1.

The other value, 65280, means del returned 256, which if you interpret
as a signed character is -1, this may be a special code indicating
error.

experiment like so:

C:\temp> perl -e "print 65280>>8"
255
C:\temp> perl -e "print unpack "c", pack "C", 65280>>8"
-1



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

Date: Tue, 23 Mar 1999 18:01:24 +0100
From: Henrik Hansen <henrik@arkitekt-maa.dk>
Subject: Sending HTTP Referer field using perl
Message-Id: <36F7C8E4.3E8C4AD4@arkitekt-maa.dk>

Hi.

Do anybody know how to get the REFERER field to work in the HTTP Header?

The problem is that it isn't logged to the Website's logfile.

Using a normal hyperlink in my page (www.my-website.dk):

  <a href="http://www.new-website.com">banner</a>

The logfile for new-website.com will show the www.my-website.dk in the
Referer field.
So this work as it should.

BUT I use a banner system which writes to a special log when a user
clicks on a banner
therefore I have to Redirect the user using Perl:

Like this:

PERL:
print "Referer: http://www.my-website.dk";
print "Location: http://www.new-website.com";

I have also tried:
print "Content-Base: http://www.my-website.com\r\n";
print "Location: http://www.new-website.dk/?www.new-website.com\n\n";

but when I look at logfile for new-website.com the Referer field is
empry?

How do another sites like yahoo and altavista do it?

Any suggestions ?



Henrik Schak Hansen
henrik@byggeinfo.dk



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

Date: Tue, 23 Mar 1999 09:28:20 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Want to learn Perl
Message-Id: <36F7CF34.41902A89@mail.cor.epa.gov>

ICG's wrote:
> In article <7crkdn$803$1@obsidian.us.dell.com>, "Spike White" <spike_YYwhiteYY@YYdellYY.com> wrote:
> >Get the "Learning Perl" book by O'Reilly (the Llama book) and the
> >"Programming Perl" book by O'Reilly (the Camel book).  The first
> >is a gentle intro, you can fly through it.  The second is a meaty
> >reference book (analogous to K&R in the C world).
> 
> Hmm.  I guess I need to look at the Camel book, I started off with the Rat
> book.  Most of it was geared towards Perl CGI anyway.

Do.  I also highly recommend the ram book, the Perl Cookbook.  This is
probably sick, but I was reading it last night as bedtime reading.  The 
code is great, and the discussions are very enlightening.

> >>I was looking for information on Websites or Books that may help me get
> >>started learning Perl.
> 
> There is a Perl executable for Win95 and NT, actually, a couple of them.
> Don't know where they are, but they're out there.

Run, don't walk, over to www.activestate.com and snatch up a copy of
their build 509 (version 5.005_02).  Installs easily, and has great
help docs.  html and also the traditional perldoc program.
 
> >>If anyone has comments on Java vs Perl please let me know, I know Java
> >>is the hot topic, but it is still pretty slow over the net.
> 
> Java has it's uses.  The hard part (well, sort of) is getting the code across
> to the client and hoping there is nothing wrong with the client's
> configuration.  Then you're stuck with the speed of the client's computer.
> At first, I hated the concept of Java.  But it's usefull for neat little
> tricks that are impossible in Perl.  Perl on the other hand, can do things
> that Java can't do.  (such as fingering 3 separate network access servers,
> doing a selective port scan across 15 IPs, manipulating the data and telling
> you the state of all the critical systems and services in an ISP, and the
> number of users <with logon names>)

You can do this in Perl too, you know.

Yes, Java does have its uses.  You can.. umm.. well, you might want to..
errm.. let's see...  Well, I'm sure I could think of something if you give 
me enough time...  :-)

Enough kidding.  Not only does Java has its uses, but Larry Wall has written
JPL, the Java-Perl Lingo, which lets you use both together.

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Tue, 23 Mar 1999 09:08:33 -0800
From: "David L. Cassell" <cassell@mail.cor.epa.gov>
Subject: Re: Win32:EventLog and problems capturing data
Message-Id: <36F7CA91.CD87C16F@mail.cor.epa.gov>

Craig Vitter wrote:
> Hello,

Howdy.
 
> I am working on a script to capture all of the warning and error messages in
> to send me any errors it finds on a nightly basis so I can keep tabs on what
> 
> to send me any errors it finds on a nightly basis so I can keep tabs on what
> is happening with each of my boxes. I derived the important parts of the code
> from examples in Dave Roth's book Windows NT Win32 Programming.
> 
> When I run the file it actually opens the event log, reads it, and e-mails me.
> 
> However it does not find any error or warning messages in the event log
> (although I have specifically created error messages in there to find). It
> does however calculate and correctly record the correct number of entries in
> the event log.
> 
> The following is the code I am using to read the System part of the event log:

Okay, let's take a look under the hood...
First, let me ask: did you call Perl withthe -w flag, and did you say
    use strict
at the top of your program?  I always do, because I make lots of embarrassing
typos and stuff...

> $SecPerDay = 7 * 24 * 60 * 60;
> $Now = time();
> $OneDayAgo = $Now - $SecPerDay;

I would have done this part with localtime() and Time::Local, but each to
his own.  There has been a thread about this recently.

> [a little snip to cut to the chase] 
>                         if( $Hash{EventType} == EVENTLOG_ERROR_TYPE ||
>                         $Hash{EventType} == EVENTLOG_WARNING_TYPE)

Hmmm.  If your error type and warning type are character strings, you
want to make the comparison using 'eq'.  Otherwise, you're forcing
a numerical comparison against a non-number.  No match.  Hence no
output.

> [a little more snipping here]

David
-- 
David L. Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: 12 Dec 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 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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