[17844] in Perl-Users-Digest
Perl-Users Digest, Issue: 4 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 6 00:05:35 2001
Date: Fri, 5 Jan 2001 21:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978757507-v10-i4@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 5 Jan 2001 Volume: 10 Number: 4
Today's topics:
Re: &sub vs. sub() style? (Martien Verbruggen)
Re: &sub vs. sub() style? (Tad McClellan)
[ANNOUNCE] Data::Iterator v.0.021 <h.camp@scm.de>
A Socket Server Problem <schelling@bluewin.ch>
Re: displaying a gif from a cgi... tohann@my-deja.com
Formatting numbers inside perl-generated html <brill@hfhmn.org>
Re: Formatting numbers inside perl-generated html <vmurphy@Cisco.Com>
Re: Formatting numbers inside perl-generated html egwong@netcom.com
Re: Formatting numbers inside perl-generated html (Tad McClellan)
Re: How do I get 'print $the_stuff' to not print 'I see <bwh@indra.com>
Re: NAMES OF ARRAYS (Honza Pazdziora)
Re: NAMES OF ARRAYS <uri@sysarch.com>
Re: Net::Telnet and --More-- (H Chosta)
Re: New to perl question about traversing directories a <bart.lateur@skynet.be>
Newbie question on Subs <hafateltec@hotmail.com>
Re: Newbie question on Subs <xzrgpnys@yvtugubhfrovm.pbz>
Perl PATH problems sugaking@my-deja.com
Re: problem with DST conversion in Time::Local (Honza Pazdziora)
Re: Remote Controll other windows software by Perl gungeek@my-deja.com
Re: Running setuid Perl scripts (Garry Williams)
Re: Segmented Mac OS X dev tools (Martien Verbruggen)
Re: Segmented Mac OS X dev tools (Abigail)
sending numbers??? <b0l4549@cs.tamu.edu>
Re: sending numbers??? (Greg Bacon)
Trouble with Interpolation <xzrgpnys@yvtugubhfrovm.pbz>
Re: Trouble with Interpolation (Martien Verbruggen)
Re: Using variable with metacharacters in regex (Tad McClellan)
Win32 User 2obvious@my-deja.com
Re: Win32 User <bart.lateur@skynet.be>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 6 Jan 2001 10:18:16 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: &sub vs. sub() style?
Message-Id: <slrn95clho.suo.mgjv@martien.heliotrope.home>
On Fri, 05 Jan 2001 14:49:00 -0800,
John Callender <jbc@west.net> wrote:
> I'm currently working on some beginning-programmer-oriented Perl
> documentation. In my materials I've been invoking subroutines
> with a leading ampersand (&sub), but I've been told that doing so
> looks very Perl4-ish, and that I should instead invoke such
> subroutines like sub(). This was presented to me as being mainly
> an aesthetic/style type of issue, though I suppose there also
> might be more substantive concerns behind the objection.
You need to read the perlsub documentation. It explains the differences
in calling semantics. The presence or absense of ampersand or brackets
gives different semantics to each form.
To call subroutines:
NAME(LIST); # & is optional with parentheses.
NAME LIST; # Parentheses optional if predeclared/imported.
&NAME(LIST); # Circumvent prototypes.
&NAME; # Makes current @_ visible to called subroutine.
However, in many cases you won't notice the difference. Read the body
of perlsub to get more info.
Martien
--
Martien Verbruggen |
Interactive Media Division | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
Date: Fri, 5 Jan 2001 19:19:51 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: &sub vs. sub() style?
Message-Id: <slrn95cp57.qqt.tadmc@magna.metronet.com>
John Callender <jbc@west.net> wrote:
>I'm currently working on some beginning-programmer-oriented Perl
>documentation. In my materials I've been invoking subroutines
>with a leading ampersand (&sub), but I've been told that doing so
>looks very Perl4-ish, and that I should instead invoke such
>subroutines like sub(). This was presented to me as being mainly
>an aesthetic/style type of issue, though I suppose there also
>might be more substantive concerns behind the objection.
^^^^^^^^^^^^^^^^^^^^
Yes, they can have different semantics, as perlsub says.
[ _I_ always use sub() instead of &sub, but we're not talking
about people like me.
]
>But it seems to me that there might be some value, at
>least for a very-early-stages learner unfamiliar with many of
>Perl's built-in functions, in keeping the ampersand to
>disambiguate invocations of a user-defined subroutine from
>invocations of a built-in function.
Randal thinks the same thing. The above is taught in
Stonehenge's Learning Perl course, stated in nearly
the same words even.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 2 Jan 2001 17:22:51 +0100
From: "H. Camphausen" <h.camp@scm.de>
Subject: [ANNOUNCE] Data::Iterator v.0.021
Message-Id: <t5co7op131ada3@corp.supernews.com>
Hi all,
I've just uploaded an update of the Perl module Data::Iterator to CPAN.
This is a bugfix release.
Enhancements in this version (0.021):
- Squashed a bug preventing iteration over array objects if data
path is given
- Cleaned up some "Use of uninitialized value..."-warnings
- Example code corrected
The module can be found at CPAN (search for Data::Iterator), or get it
from
http://www.creagen.de/downloads/Data-Iterator-0.021.zip
>From the module's readme:
Iterator.pm is an object orientated (plain) Perl module to
iterate over complex data structures (LoL, LoH, HoL, HoH etc.).
While Perl's built-in functions foreach(), each(), keys() and
values() handle just a given level of a structure, Iterator digs
deeper - handling a structure like an one-dimensional hash.
For each element of a nested data structure the symbolic name
("data path"), The Value - as is! - plus some additional
information are retrieved.
That is, Iterator provides an unified syntax for simple handling
of data sources of different types.
Iterator does not alter the referenced structure, though values
may be explicitly modified by the user.
mfg, Hartmut
--
CREAGEN Computerkram Fon: 06422/850527
Hartmut Camphausen Fax: 06422/850528
Am kleinen Born 1 E-Mail: h.camp@creagen.de
35287 Amöneburg WWW: http://www.creagen.de
------------------------------
Date: Sat, 06 Jan 2001 03:57:37 +0100
From: Bernhard Schelling <schelling@bluewin.ch>
Subject: A Socket Server Problem
Message-Id: <3A5689A1.7754F2A0@bluewin.ch>
Hi all!
I have a Perl socket server connecting with a httpclient.
I need a longer multipart connection, but thats not the problem.
How do I know, when a client disconnects? (closes his browser)
My program just doesn't know, when the socket connection isn't open
anymore. My program can close the connection at any time, and the
browser puts up a messagbox. I tried everything from $handle->connected
over $handle->opened to create a new select and a can-read with
timeout... nothing worked :-(
I hope someone can help me.
Thanks a lot!
bye
------------------------------
Date: Sat, 06 Jan 2001 02:58:36 GMT
From: tohann@my-deja.com
Subject: Re: displaying a gif from a cgi...
Message-Id: <9361kq$oo7$1@nnrp1.deja.com>
In article <slrn95b703.nsr.abigail@tsathoggua.rlyeh.net>,
abigail@foad.org wrote:
> Eric Bohlman (ebohlman@omsdev.com) wrote on MMDCLXXXIV September
MCMXCIII
> in <URL:news:933qaq$llt$1@bob.news.rcn.net>:
> :} tohann@my-deja.com wrote:
> :} > Hello. I'm trying to display a gif image returned from a cgi
program to
> :} > an <IMG SRC=... tag. I can display an image from my own server
just
> :} > fine, but when I try to display an image from another server, it
doesn't
> :} > show. Is there some slick way to do this? Here's the code I'm
using...
> :}
> :} > The HTML that calls the cgi:
> :} > <IMG
SRC="http://www.myserver.com/cgi-bin/banners.cgi?action=banner">
> :}
> :} > and the portion of the cgi that displays the image:
> :} > #
> :} > open(GIF, $bannerFileName)
> :} > or die("OPEN FAILED: $! => $bannerFileName");
> :} > #
> :} > binmode GIF;
> :} > #
> :} > undef $/;
> :} > my $image = <GIF>;
> :} > #
> :} > close GIF;
> :} > #
> :} > print $query->header(-type=>"image/gif"), $image;
> :}
> :} > Like I said, $bannerFileName will either point to a gif on my
server, or
> :} > one offsite. I'm relatively new to the cgi processing, and I'm
> :} > guessing that that's my problem. I can't treat gifs on my server
and
> :} > offsite gifs as the same.
> :}
> :} Your problem is that you've forgotten that URLs are not file names
and
> :} that Perl's file IO works only with actual *files*.
>
> Perhaps Perl's file IO works only with files, but neither open, print
or
> <> restrict themselves to files. You have read "man perlopentut" I
presume?
> It's true that open can't deal with URLs (at least, not yet), but that
> isn't because open only works on files.
>
> Abigail
> --
> perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'
Thank you both for your replies, the LWP::Simple worked perfectly. Do
you know of any good Perl books or websites I could get/use for
reference?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 03 Jan 2001 11:22:04 -0600
From: "Daniel J. Brill" <brill@hfhmn.org>
Subject: Formatting numbers inside perl-generated html
Message-Id: <3A535FBB.E3A6E204@hfhmn.org>
Hi,
I've looked over the faqs, dejanews, and my library of perl books, and
haven't seen how to format numbers that will be embedded in
perl-generated html. I've seen lots of examples on how to generate
various print formats, but none that show how to put these into html.
I'm writing a script that keeps track of inventory. For example, I want
to print out $round_total as $1,234,567.89, instead of $1234567.89. How
would I get the commas in place in this block of html?
(Is it somehow possible to save the formatted number to a new variable
and then embed that in the html?)
print qq~
<body background="$background_picture">
<h2 align = "center">Vital Inventory Statistics</h2>
<br>
<hr>
<br>
The cheapest item costs \$$round_min <br>
The most expensive item costs \$$round_max <br>
The average price is \$$round_avg <br>
There are $total_number_of_items items in the warehouse <br>
The total value of all items is \$$round_total <br>
<br>
<hr>
<br>
~;
Thanks for any help that anyone can offer.
Dan Brill
brill@hfhmn.org
------------------------------
Date: 05 Jan 2001 21:29:00 -0500
From: Vinny Murphy <vmurphy@Cisco.Com>
Subject: Re: Formatting numbers inside perl-generated html
Message-Id: <u4rzde7mb.fsf@Cisco.Com>
>>>>> "Daniel" == Daniel J Brill <brill@hfhmn.org> writes:
Daniel> Hi, I've looked over the faqs, dejanews, and my library of
Daniel> perl books, and haven't seen how to format numbers that will
Daniel> be embedded in perl-generated html. I've seen lots of
Daniel> examples on how to generate various print formats, but none
Daniel> that show how to put these into html.
Daniel> I'm writing a script that keeps track of inventory. For
Daniel> example, I want to print out $round_total as $1,234,567.89,
Daniel> instead of $1234567.89. How would I get the commas in place
Daniel> in this block of html?
Look at the faqs.
perldoc -q "How can I output my numbers with commas added"
HTH.
--Vinny
------------------------------
Date: Sat, 06 Jan 2001 02:45:01 GMT
From: egwong@netcom.com
Subject: Re: Formatting numbers inside perl-generated html
Message-Id: <NEv56.36949$bw.2403040@news.flash.net>
Hi Dan.
Daniel J. Brill <brill@hfhmn.org> wrote:
> Hi,
> I've looked over the faqs, dejanews, and my library of perl books, and
> haven't seen how to format numbers that will be embedded in
> perl-generated html. I've seen lots of examples on how to generate
> various print formats, but none that show how to put these into html.
What makes you think that printing html is different than printing
any other sort of text?
> I'm writing a script that keeps track of inventory. For example, I want
> to print out $round_total as $1,234,567.89, instead of $1234567.89. How
> would I get the commas in place in this block of html?
It's in the faq.
% perldoc -q "How can I output numbers with commas added?"
> (Is it somehow possible to save the formatted number to a new variable
> and then embed that in the html?)
That sounds like a very good idea.
my $commafied_round_min = commify( $round_min ); # commify() in the faq
> print qq~
> <body background="$background_picture">
> <h2 align = "center">Vital Inventory Statistics</h2>
> <br>
> <hr>
> <br>
> The cheapest item costs \$$round_min <br>
> The most expensive item costs \$$round_max <br>
> The average price is \$$round_avg <br>
> There are $total_number_of_items items in the warehouse <br>
> The total value of all items is \$$round_total <br>
> <br>
> <hr>
> <br>
> ~;
------------------------------
Date: Fri, 5 Jan 2001 19:52:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Formatting numbers inside perl-generated html
Message-Id: <slrn95cr27.qqt.tadmc@magna.metronet.com>
Daniel J. Brill <brill@hfhmn.org> wrote:
>
>I've looked over the faqs, dejanews, and my library of perl books, and
>haven't seen how to format numbers that will be embedded in
>perl-generated html.
The "it is HTML" aspect has nothing to do with it. Perl does
not know (or need to) that it is HTML.
It is not "HTML" to Perl. It is a "double quoted string" to Perl.
>I've seen lots of examples on how to generate
>various print formats, but none that show how to put these into html.
^^^^^^^^^
You mean into a double quoted string.
>I'm writing a script that keeps track of inventory. For example, I want
>to print out $round_total as $1,234,567.89, instead of $1234567.89. How
>would I get the commas in place in this block of html?
You need to execute code for that. You cannot execute code
in a double quoted string (well, you can. But it is so distastful
to me that I am not going to show you how).
The code is as given in the answer to this Perl FAQ:
"How can I output my numbers with commas added?"
You can only interpolate variables in double quoted strings, so...
>(Is it somehow possible to save the formatted number to a new variable
>and then embed that in the html?)
...you can do exactly that :-)
But it doesn't even need to be a new variable:
$round_total = commify($round_total);
>print qq~
>The total value of all items is \$$round_total <br>
>~;
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 06 Jan 2001 00:31:04 GMT
From: Bruce <bwh@indra.com>
Subject: Re: How do I get 'print $the_stuff' to not print 'I see $i trees'?
Message-Id: <935p09$i3j$1@nnrp1.deja.com>
In article <3A5648A2.717E38DA@yvtugubhfrovm.pbz>,
xzrgpnys@yvtugubhfrovm.pbz wrote:
> Here's the part of the code that matters:
> *******
> $option_line = "<option ";
> unless ($contents{print_option} == 0) { $option_line .=
> 'value="$i"';}
The ''' is preventing $i from being expanded. Use the perl meta-quoting
structure to preserve embedded quoting, sort of like this:
# Preserve the embedded double-quotes by using the qq//
# meta-quote.
$option_line .= qq/value="$1"/
> $option_line .= '>$i' . "$newlinechar";
and like this:
# No meta-quotes needed here as no embedded quotes
# need to be preserved.
$option_line = ">$i"
HTHYO.
Peace.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 4 Jan 2001 20:00:30 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: NAMES OF ARRAYS
Message-Id: <G6nM8u.8zy@news.muni.cz>
On Thu, 04 Jan 2001 18:10:05 GMT, saumya_mittal@my-deja.com <saumya_mittal@my-deja.com> wrote:
> I wanted to find out whether there is ANY WAY of dynamically assigning
> names to arrays (for eg. I want to be able to say something like
> @($var), where $var holds the name of the array). Can I do this in any
> way ? Pls help
Nearly there:
@{$var}
or
@$var
for short. See:
@array = ( 'jezek', 'krtek' );
$name = 'array';
print "@$name\n";
and also
perldoc perlref
to learn more about references.
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: Sat, 06 Jan 2001 04:52:17 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: NAMES OF ARRAYS
Message-Id: <x7y9wp705c.fsf@home.sysarch.com>
>>>>> "HP" == Honza Pazdziora <adelton@fi.muni.cz> writes:
HP> On Thu, 04 Jan 2001 18:10:05 GMT, saumya_mittal@my-deja.com <saumya_mittal@my-deja.com> wrote:
>> I wanted to find out whether there is ANY WAY of dynamically assigning
>> names to arrays (for eg. I want to be able to say something like
>> @($var), where $var holds the name of the array). Can I do this in any
>> way ? Pls help
HP> @{$var}
HP> or
HP> @$var
BEGONE YOU EVIL SPAWN FROM HELL!
:)
there have been several answers to this query, all of which said not to
use symrefs. and we always get some wag who shows how to use them. that
is why i wrote the above in caps. please DO NOT show newbies how to use
symrefs. there is NO REASON to use them in ordinary perl code. NONE
WHATSOEVER!!
HP> perldoc perlref
HP> to learn more about references.
^
hard/real
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 06 Jan 2001 02:43:09 -0000
From: h0c2000@yahoo.com (H Chosta)
Subject: Re: Net::Telnet and --More--
Message-Id: <t5d1htamg83b71@corp.supernews.com>
In article <t5cadgp531d44a@corp.supernews.com>, neil@alaweb.com says...
>It hangs....I was using @array=$this_session->cmd("who") but changed it to
>this to hopefully work out getting around the --More-- that the Cisco router
>is sending back ... and waiting for a <SPACE> as input to continue....
>
>I have looked at the input.log ... and it is the --More-- that is causing
>the problems.....
>
I had a similar issue with Cabletron routers. After trying to get it
working for an hour, I gave up and had my script shut off page
scrolling, get whatever, and then turn scrolling back on and log off.
There was probably a better way to do it, but it worked for me.
Henry
------------------------------
Date: Sat, 06 Jan 2001 01:12:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: New to perl question about traversing directories and searching for files.
Message-Id: <6tqc5t0ltdronlajfibp4vihetu8uiq8mg@4ax.com>
cputek1@my-deja.com wrote:
>I need to search for files with a certain extention
>(.exe, .dll, .jar, .class) in a directory and all sub directories.
>From there I need to move those files out to another directory
>maintaining the path. I also need to save that directory/filename into
>a an output file so that I can remove the binary from our repository
>using the output file as the dataset.
>the following script (taken from Perl book)...
>
>#!/usr/bin/perl -lw
># fdirs - find all directories
>@ARGV = qw(.) unless @ARGV;
>use File::Find ();
>sub find(&@) { &File::Find::find }
>*name = *File::Find::name;
>find { print $name if -d } @ARGV;
>
>but getting it to search for the extentions in those directoryies is
>another issue.
It's dead easy. For each file, $_ is the file's basename, and
$File::Find::name the full path. All you need to do, is filter out those
files that contain the right extension, including the dot, at the end of
their name. So:
use File::Find;
find sub {
if(-f && /\.(exe|dll|jar|class)$/i) {
print "$File::Find::name\n";
}
}, 'c:/windows'; # for example
This will list all DLL, EXE, JAR and CLASS files under c:/windows (on a
PC).
Copying the file (using File::Copy) shouldn't be a problem, although
you'll have to find a way to find the relative path to the source's
root, and you might have to create the subdirectories on the receiving
side before doing the copy. First things first.
I'm not sure this works on your platform, but it works on mine (Win32):
only ONCE, will the sub for find() be called with a file called '.', and
that is for each argument directory, in the example 'c:/windows'. That's
the time to store the pathname, or at least its length, and you'll need
to replace it with the destination root in order to get the destination
directory for the copied file.
And second: you need to create each subdir in turn in order to
succesfully copy the files.
This script here seems to be working:
use File::Find;
use File::Copy;
my $root;
my $destroot = 'c:/my documents/test';
# make sure this directory already exists
find sub {
if($_ eq '.') {
$root = $File::Find::name;
} elsif(-f && /\.(vbx)$/i) {
# copy each .VBX file
print "$File::Find::name\n";
my $dest = substr($File::Find::name, length($root)+1);
# drop the source root
my @dest = split /[\/\\:]/, $dest; pop @dest; # subdirs
local $" = '/';
for my $i (0 .. $#dest) {
# create each subdir, if it doesn't already exist
mkdir "$destroot/@dest[0..$i]", 0777;
}
copy $_, "$destroot/$dest"
or print "Cannot copy file: $!\n";
}
}, 'c:/windows';
--
Bart.
------------------------------
Date: Sat, 6 Jan 2001 10:05:22 +1000
From: "Mike McPherson" <hafateltec@hotmail.com>
Subject: Newbie question on Subs
Message-Id: <935no6$g6r$1@brokaw.wa.com>
I am obviosly a newbie to perl. Can somebody please help me out on this
one.
What I want this sub to do is simple:
1. Sombody imputs a URL in either xxx.xxx.xxx.xxx or http://www.whatever.com
format
2. If they do not input anything by just hitting retrun for $Webaddress I
want it to loop back up to the line above it again and reask untill they
fill it out?
sub getwebparams {
print "\nPlease input the URL (Use xxx.xxx.xxx.xxx or www.whatever.com
Format)\n";
$Webaddress = <STDIN>;
unless
ined($Webaddress)){
print "\nYou must enter a value\n";
return &getparams;
}
print "\nPlease enter the port for the website. ie. 80\n";
$Webport = <STDIN>;
}
Thanks in advance
------------------------------
Date: 06 Jan 2001 00:32:51 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Re: Newbie question on Subs
Message-Id: <3A56684B.4E2E3574@yvtugubhfrovm.pbz>
> I am obviosly a newbie to perl. Can somebody please help me out on this
> one.
> What I want this sub to do is simple:
> 1. Sombody imputs a URL in either xxx.xxx.xxx.xxx or http://www.whatever.com
> format
> 2. If they do not input anything by just hitting retrun for $Webaddress I
> want it to loop back up to the line above it again and reask untill they
> fill it out?
This works for me:
#!/usr/bin/perl
$myvar="\n";
while ($myvar eq "\n") { $myvar = <STDIN>; }
print "You said, $myvar";
--
Kevin Metcalf
(Carbon Ocelot)
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: Sat, 06 Jan 2001 02:17:20 GMT
From: sugaking@my-deja.com
Subject: Perl PATH problems
Message-Id: <935v7c$mu6$1@nnrp1.deja.com>
I installed Perl here on my win2k machine. I know during
installation it adds Perl to the path, and it did. After a shutdown I
come back to play with perl and I get:
C:\>perl
'perl' is not recognized as an internal or external command,
operable program or batch file.
Any solutions or cause to this? Thanks, appreciate any help.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Thu, 4 Jan 2001 19:55:01 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: problem with DST conversion in Time::Local
Message-Id: <G6nLzp.n15@news.muni.cz>
On Thu, 04 Jan 2001 10:43:18 -0600, Greg Economides <econ@tamu.edu> wrote:
>
> I've been using Time::Local (timegm and localtime) to do conversions
> from GMT to local time. The code has been working fine for a year, but
> now seems to have a problem. It looks like the module is missing the
> fact that DST starts on 1 April 2001 this year. All of the conversions
> that I do show that it incorrectly subtracts 6 hours
> from DST during April 1 - April 7 (GMT-6 is for CST and GMT-5 for CDT).
> Then, from 8 April on, it correctly subtracts 5 hours.
>
> Here's the significant line of code:
>
> @tarray=localtime(timegm(0,$min,$hour,$day,$mon,$yr));
>
> Are any of you finding this problem?
No.
How the system (and Perl) behaves on your local system depends on your
local setting. That local setting says when the DST starts and when
it ends.
For example on my IRIX 6.2 machine, it's the file /etc/TIMEZONE and
the TZ environment variable that specify the behaviour, my Linux
machine has /etc/localtime and TZ to do the same ...
If the configuration is incorrect, your date(1) command will not work
either. You need to setup your system correctly to make date work
alright, the Perl will start behaving magically. ;-)
Yours,
--
------------------------------------------------------------------------
Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
.project: Perl, DBI, Oracle, MySQL, auth. WWW servers, MTB, Spain.
Petition for a Software Patent Free Europe http://petition.eurolinux.org
------------------------------------------------------------------------
------------------------------
Date: Sat, 06 Jan 2001 00:43:58 GMT
From: gungeek@my-deja.com
Subject: Re: Remote Controll other windows software by Perl
Message-Id: <935poc$ikl$1@nnrp1.deja.com>
In article <934g1a$ci3$1@nnrp1.deja.com>,
Ronald J.H. Rood <ronr@my-deja.com> wrote:
>
> Question remains:
> how can one run an application on a remote NT or windows machine ? I
We use Symantec PCAnywhere, but that does more than just command-line
stuff. It's a full remote GUI.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 06 Jan 2001 00:21:24 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Running setuid Perl scripts
Message-Id: <8yt56.29$Qm5.2407@eagle.america.net>
On Fri, 05 Jan 2001 16:51:01 +0000, Thomas Edmond
<tomedmond@lucent.com> wrote:
[snip]
>The suid is causing me great problems - the perl script bombs out
>with fatal errors due to "Insecure $ENV{PATH}..." problems.
What's wrong with setting the PATH as suggested in perldiag?
Insecure $ENV{%s} while running %s
(F) You can't use system(), exec(), or a piped open in a
setuid or setgid script if any of `$ENV{PATH}',
`$ENV{IFS}', `$ENV{CDPATH}', `$ENV{ENV}' or
`$ENV{BASH_ENV}' are derived from data supplied (or
potentially supplied) by the user. The script must set
the path to a known value, using trustworthy data. See
the perlsec manpage.
--
Garry Williams
------------------------------
Date: Sat, 6 Jan 2001 09:58:30 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Segmented Mac OS X dev tools
Message-Id: <slrn95ckcm.suo.mgjv@martien.heliotrope.home>
On 05 Jan 2001 21:58:55 GMT,
Peter Seebach <seebs@plethora.net> wrote:
> In article <933jhs$8e2$1@charm.magnus.acs.ohio-state.edu>,
> Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>>??? What makes a program a "Unix program"?
>
> Being a standard feature of Unix-like systems.
Yes, maybe. But, is the whole set of GNU tools ported to a non-Unix
system still a unix suite of programs? What about cygwin? But I really
don't want to continue this part of that discussion, since it's offtopic
in all the groups in the headers.
>>If latter is true, then binmode is a NOP, so the whole discussion
>>would be void.
>
> Probably, and my guess is that the original file was actually corrupt before
> he started. Well, truncated anyway; "corrupt" would have gotten a CRC error
> in all probability.
If we all agreed to suspend this discussion until the OP actually shows
some code (see my earlier post in this thread for the request), maybe we
could say something sensible about it.
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 6 Jan 2001 00:17:12 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Segmented Mac OS X dev tools
Message-Id: <slrn95cp08.d6q.abigail@tsathoggua.rlyeh.net>
Martien Verbruggen (mgjv@tradingpost.com.au) wrote on MMDCLXXXIV
September MCMXCIII in <URL:news:slrn95ckcm.suo.mgjv@martien.heliotrope.home>:
)) On 05 Jan 2001 21:58:55 GMT,
)) Peter Seebach <seebs@plethora.net> wrote:
)) > In article <933jhs$8e2$1@charm.magnus.acs.ohio-state.edu>,
)) > Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
)) >>??? What makes a program a "Unix program"?
)) >
)) > Being a standard feature of Unix-like systems.
))
)) Yes, maybe. But, is the whole set of GNU tools ported to a non-Unix
)) system still a unix suite of programs? What about cygwin?
Do you think that sushi is a Japanese dish? Even when it's available
in Australia?
Abigail
--
print 74.117.115.116.32.97.110.111.116.104.101.114.
32.80.101.114.108.32.72.97.99.107.101.114.10;
------------------------------
Date: Fri, 5 Jan 2001 17:38:01 -0600
From: Bin - Lu <b0l4549@cs.tamu.edu>
Subject: sending numbers???
Message-Id: <Pine.SOL.4.10.10101051711190.25935-100000@robert>
I'm trying to send number type variables through socket. But it seems that
the number is always converted to characters and then sent to the other
side. Although I know that I can use FreezeThaw to convert them back to
numbers at the other side, it's not an efficient way because, say 1000,
the integer may only needs 4 bytes but four characters 1,0,0,0 would need
16 bytes - that's why I want to stick to numbers in the whole process of
sending.
I'm stuck to this problem. Please help! Thanks much!
Bin
------------------------------
Date: Sat, 06 Jan 2001 00:30:16 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: sending numbers???
Message-Id: <t5cpoop1jgcnee@corp.supernews.com>
In article <Pine.SOL.4.10.10101051711190.25935-100000@robert>,
Bin - Lu <b0l4549@cs.tamu.edu> wrote:
: I'm trying to send number type variables through socket. But it
: seems that the number is always converted to characters and then
: sent to the other side. Although I know that I can use FreezeThaw
: to convert them back to numbers at the other side, it's not an
: efficient way because, say 1000, the integer may only needs 4 bytes
: but four characters 1,0,0,0 would need 16 bytes - that's why I want
: to stick to numbers in the whole process of sending.
If your connection is eight-bit clean, then you might consider playing
with BER compressed integers. (You didn't say whether you're slinging
around strictly integers.) Consider:
$in = 1000;
$xmit = pack "w", 1000;
$out = unpack "w", $xmit;
print "in = [$in]\n",
"out = [$out]\n",
'length($xmit) = ', length($xmit), "\n";
The perlfunc documentation on pack() has the following to say about
BER compressed integers:
[A BER compressed integer's] bytes represent an unsigned integer in
base 128, most significant digit first, with as few digits as
possible. Bit eight (the high bit) is set on each byte except the
last.
If this doesn't help, maybe you should be more specific about the
definition of "number type variables". All things considered, though,
ASCII isn't such a bad code for information interchange.
Greg
--
Got Mole problems?
Call Avogadro: 6.02 x 10^23
------------------------------
Date: 06 Jan 2001 00:28:04 GMT
From: kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz>
Subject: Trouble with Interpolation
Message-Id: <3A56672B.5E52B2B7@yvtugubhfrovm.pbz>
I posted this under a different header, and got no responses. I think
this is the category this falls into...
Here's the part of the code that matters:
*******
$option_line = "<option ";
unless ($contents{print_option} == 0) { $option_line .=
'value="$i"';}
$newlinechar=$contents{newlinechar};
if ($newlinechar eq "ret") {$newlinechar="\n";}
unless ($contents{extra} eq "") {$option_line .= " $contents{extra}"; }
$option_line .= '>$i' . "$newlinechar";
$countfrom=$contents{countfrom};
$countto=$contents{countto};
$countto++;
for ($i=$countfrom; $i<$countto; $i++){
print /$option_line/e;
}
*******
I want the user to be able to include $i in the $contents{extra} field,
and have it it print correctly in the for loop. Right now, it prints:
<option value="$i" [FMP-if:Q_Display_Order.eq.$i]selected[/FMP-if]>$i
instead of:
<option value="45" [FMP-if:Q_Display_Order.eq.45]selected[/FMP-if]>45
Anyone know how to get this to expand correctly? I couldn't find
anything in the camel book (probably because I didn't know what to look
for. Any help?
Thanks!
--
Kevin Metcalf
(Carbon Ocelot)
email: xzrgpnys@yvtugubhfrovm.pbz
Huh? http://www.flactem.com/utils/rot13.html
------------------------------
Date: Sat, 6 Jan 2001 11:52:20 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Trouble with Interpolation
Message-Id: <slrn95cr24.suo.mgjv@martien.heliotrope.home>
On 06 Jan 2001 00:28:04 GMT,
kevin metcalf <xzrgpnys@yvtugubhfrovm.pbz> wrote:
> I posted this under a different header, and got no responses. I think
> this is the category this falls into...
>
> Here's the part of the code that matters:
> *******
> $option_line = "<option ";
> unless ($contents{print_option} == 0) { $option_line .=
> 'value="$i"';}
$option_line = "value=\"$i\"";
or a bit cleaner:
$option_line = qq{value="$i"};
Read about the quote and quote-like operators in perlop, and other stuff
in perldata under scalar value constructors.
> Anyone know how to get this to expand correctly? I couldn't find
> anything in the camel book (probably because I didn't know what to look
> for. Any help?
In the Camel (3rd ed.) this is discussed on pp 60-64.
Martien
--
Martien Verbruggen | The problem with sharks is that they
Interactive Media Division | are too large to get to the shallow
Commercial Dynamics Pty. Ltd. | end of the gene pool. -- Scott R.
NSW, Australia | Godin
------------------------------
Date: Fri, 5 Jan 2001 19:42:51 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using variable with metacharacters in regex
Message-Id: <slrn95cqgb.qqt.tadmc@magna.metronet.com>
menditto@my-deja.com <menditto@my-deja.com> wrote:
>Can you include metacharacters in a variable, used in a regex? For
>example:
>
>my $s = "abcdef";
>my @re = ( "^ab*", "^\s$", ... );
^ ^^
^ ^^ syntax error after taking out the comma/ellipsis
^
^ a vanishing backslash char there...
Using single quotes will make that much less error prone
(it would have avoided *both* of those problems...)
>foreach my $i ( @re ) {
> if( $s =~ /$i/i ) { print "s=\'$s\' matches pattern \'$i\'\n" }
> else { }
>}
Please do not post pseudo code.
Post real code (preferrably code that we can execute).
>I get the following error:
I don't, I get syntax errors.
>"/*/: ?+*{} follows nothing in regexp at foo.pl line N, <IN> line L"
We can't help you first because we do not have code that
behaves as you describe.
We can't help you second because the message is about one of
your patterns, and you haven't shown them all.
>when I attempt to match against lines from file <IN> instead of $s, as
>shown above.
Why dance around with hard-coded vs. read-from-filehandle, when
you can just really read from a filehandle? It has the added
benefit of providing data to run with the program you provide.
Please see perldata.pod (search for: __DATA__), then you can
include some example "file contents" right in your Perl
source code.
---------------
#!/usr/bin/perl
use strict;
while ( <DATA> ) {
print;
}
__DATA__
line one
line two
line three
---------------
>PerlFAQ 6.8 "How can I quote a variable to use in a regex?" doesn't
>really help me.
Thank you for looking before posting, we all appreciate it.
>Please help!
Help us help you.
Give us a program _that we can run_ and we can surely help you fix it.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 06 Jan 2001 02:33:46 GMT
From: 2obvious@my-deja.com
Subject: Win32 User
Message-Id: <93606a$non$1@nnrp1.deja.com>
I'm writing a Perl script on Windows 98 and I have a couple of basic
questions.
How can I make my script open a file in its native program? For
instance, how can I make my script open .doc file in Word?
I can't figure out how to keep the DOS window that my scripts run in
open when I make mistakes coding. I attach <STDIN> to the bottom of
all my scripts, but this is only helpful when my scripts are
interpreted correctly.
--E.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Sat, 06 Jan 2001 02:46:51 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Win32 User
Message-Id: <sj1d5tg10q7c7b134f9ku3sv1f9lcp38kj@4ax.com>
2obvious@my-deja.com wrote:
>How can I make my script open a file in its native program? For
>instance, how can I make my script open .doc file in Word?
Through "start", which is a program in the windows directory.
exec('start', 'somefile.doc');
And alternative would be to use the ShellExecute API call, through the
Win32::API module. Gee, I must have answered this before. If all else
fails, check DejaNews. (<http://www.deja.com/home_ps.shtml>)
>I can't figure out how to keep the DOS window that my scripts run in
>open when I make mistakes coding. I attach <STDIN> to the bottom of
>all my scripts, but this is only helpful when my scripts are
>interpreted correctly.
Put it in an END BLOCK.
END {
<STDIN>
}
--
Bart.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 4
************************************