[22882] in Perl-Users-Digest
Perl-Users Digest, Issue: 5103 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 10 14:06:06 2003
Date: Tue, 10 Jun 2003 11:05:10 -0700 (PDT)
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, 10 Jun 2003 Volume: 10 Number: 5103
Today's topics:
Beginning a script in the background (Dave Ardrey)
Re: Beginning a script in the background <w.koenig@acm.org>
Re: Cannot modify integer negation (-) in predecrement (Go Perl)
date, week of the year info? (miao mao)
Re: date, week of the year info? <beaudet@cyber.kodak.com>
Re: date, week of the year info? <w.koenig@acm.org>
Re: Do yu know abetter way to do it ? <g4rry_short@zw4llet.com>
Re: Help with XML::Simple (Graham Smith)
Help! <marcusnm.news.invalid@web2news.net>
Re: How to I arrange for a socket connection to time ou (John Brock)
Indenturing words into lists (slash)
Per Object Private Attribs/Methods <hans@enova.ch>
Re: Per Object Private Attribs/Methods <nobull@mail.com>
Re: Perl CGI and Downloading Files - How? <usenet@expires082003.tinita.de>
Perl Matrix Filter Module like in Excel? Dennis@NoSpam.com
Regular expression (Ian)
Re: Returning a database array from a class <ubl@schaffhausen.de>
Re: Returning a database array from a class <nobull@mail.com>
Re: Search & Evaluate an array (Almir)
setOutput in Perl (big__smile)
stripping leading zeros thru multiple fields (MF)
Re: stripping leading zeros thru multiple fields <mbudash@sonic.net>
Re: Unusual Can't load fail (web only) - SOLVED <Mike@Army.ca>
Re: virtual x server for Tk <ddunham@redwood.taos.com>
Re: virtual x server for Tk <lusol@cube0.CC.Lehigh.EDU>
Re: Win32::ListView sample please?? (Kenjis Kaan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 10 Jun 2003 10:31:35 -0700
From: david.ardrey@analog.com (Dave Ardrey)
Subject: Beginning a script in the background
Message-Id: <ca2d7776.0306100931.7ad0f83@posting.google.com>
I posted this question yesterday but I may have been a little unclear
as to what I need. I understand how to, from within a script, start a
process in the background:
system("command &");
However, what I need is for my entire script to immediately go into
the background, as soon as I execute it from the unix command line.
I realize that I could have a tiny script that just does a system call
like above to the "real" script, but that's kind of gross.
Is there another way to do it?
------------------------------
Date: Tue, 10 Jun 2003 19:44:15 +0200
From: Winfried Koenig <w.koenig@acm.org>
Subject: Re: Beginning a script in the background
Message-Id: <3EE618EF.1080509@acm.org>
Dave Ardrey wrote:
> I posted this question yesterday but I may have been a little unclear
> as to what I need. I understand how to, from within a script, start a
> process in the background:
>
> system("command &");
>
> However, what I need is for my entire script to immediately go into
> the background, as soon as I execute it from the unix command line.
>
> I realize that I could have a tiny script that just does a system call
> like above to the "real" script, but that's kind of gross.
>
> Is there another way to do it?
yes, see:
perldoc -q daemon
perldoc -q background
Winfried Koenig
------------------------------
Date: 10 Jun 2003 09:01:24 -0700
From: puissant00@yahoo.com (Go Perl)
Subject: Re: Cannot modify integer negation (-) in predecrement (--)
Message-Id: <d3825316.0306100801.275911ab@posting.google.com>
Thanks for your thoughts guys,
Actually the mistake was i used-------------- at the beginning and the
end.
for example
---------------
my code for counting lines
--------------
i forgot to put # in front of ----------- and i could not see the
problem yesterday, then atlast i figured it out.
------------------------------
Date: 10 Jun 2003 08:32:05 -0700
From: yw149@yahoo.com (miao mao)
Subject: date, week of the year info?
Message-Id: <990eef2b.0306100732.4193b922@posting.google.com>
Hi, all,
we are using a train system here. one train is associate with one
week.
For example, this week is train 308, next week is train 309, the week
after is train 310, etc., etc.
my question is how I can calculate the current train number?
thanks!
YQ
------------------------------
Date: Tue, 10 Jun 2003 17:33:22 +0200
From: Jean-Luc BEAUDET <beaudet@cyber.kodak.com>
Subject: Re: date, week of the year info?
Message-Id: <3EE5FA42.2010608@cyber.kodak.com>
A good start is a Perl Module called:
Date::Calc
Try it, it's ease of use !
Hope this helps.
Jean-Luc B :-)
miao mao wrote:
>Hi, all,
>
>we are using a train system here. one train is associate with one
>week.
>For example, this week is train 308, next week is train 309, the week
>after is train 310, etc., etc.
>
>my question is how I can calculate the current train number?
>
>thanks!
>
>YQ
>
------------------------------
Date: Tue, 10 Jun 2003 18:09:43 +0200
From: Winfried Koenig <w.koenig@acm.org>
Subject: Re: date, week of the year info?
Message-Id: <3EE602C7.5010903@acm.org>
miao mao wrote:
> we are using a train system here. one train is associate with one
> week.
> For example, this week is train 308, next week is train 309, the week
> after is train 310, etc., etc.
>
> my question is how I can calculate the current train number?
Install Time::JulianDay and try:
use Time::JulianDay;
my $train = int(local_julian_day(time) / 7) - 350092;
print "$train\n";
Winfried Koenig
------------------------------
Date: Tue, 10 Jun 2003 17:36:05 +0000
From: Garry Short <g4rry_short@zw4llet.com>
Subject: Re: Do yu know abetter way to do it ?
Message-Id: <bc51hn$j3c$1$8302bc10@news.demon.co.uk>
Jean-Luc BEAUDET wrote:
> Hi all,
>
> I've got smth like
>
> $search_pattern = $d7tt[0]." ".$d7tt[2]." ".(sprintf '% 2s', $d7tt[1]);
> if ($read_line =~ m/^$search_pattern \d{2}:\d{2}:\d{2} MEST 2003/) {
> ../..
> }
>
> Is there a better way to write
> \d{2}:\d{2}:\d{2} # for time format to be detected
>
> Or better to affect $search_pattern the whole pattern to be match so
> that i can write:
>
> if ($read_line =~ m/$search_patern/ {
> ../..
> }
>
> Than you for yur help.
>
> Regards.
>
> Jean-Luc B :O)
Huh? Are you asking for a regex that will match the time in a string? Or do
you want to find the time, then determine whether it's 12 or 24hr format?
([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9] will match a 24hr time;
(1[012]|0?[1-9]):[0-5][0-9]:[0-5][0-9] (am|pm) will match 12hr time.
If you're trying to pull the time from a string, these will both work quite
happily.
The trouble with the \d{2}... pattern you're using is that invalid times
will still match, e.g. 25:99:70 will provide a valid match, but an invalid
time.
HTH,
Garry
------------------------------
Date: 10 Jun 2003 10:12:02 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Re: Help with XML::Simple
Message-Id: <98eb7f13.0306100912.1bcc753d@posting.google.com>
>
> Agreed. But I'll go another step further and say that and XPath
> implementation (like in XML::XPath or XML::LibXML) is even easier.
>
As a (lazy) windows user not ever going near a C++ compiler or make
commands, things are a little bit more restricted, I'm using
Activestate build 806 of Perl and rely on the modules that download
elegantly using a tool called 'PPM', the perl package manager, and
unfortunately a lot of XML packages just aren't available - even
XML::DOM is missing from the list of modules that I can simply install
now!
------------------------------
Date: Tue, 10 Jun 2003 17:29:40 +0200
From: "marcusNM" <marcusnm.news.invalid@web2news.net>
Subject: Help!
Message-Id: <38508N580@web2news.com>
I have no idea about perl... all I know is that I need a script that
will create a random custom serial number for the vb6 program that I
created... it will need to have a index file so it doesn't repeat any
serial numbers. I'll try to give you a basic idea of how it should work:
1) Person buys my program (but they can't use it until they register)
2) Person goes to my website to register
3) Perl Program creates custom serial number under the Person's name
4) My program searches my website for the Person's name (ie.
johnsmith.sn) and opens it for the serial number
If anyone could help, that would be wonderful!
Thanks In Advance,
Marcus
--
Direct access to this group with http://web2news.com
http://web2news.com/?comp.lang.perl.misc
------------------------------
Date: 10 Jun 2003 11:43:27 -0400
From: jbrock@panix.com (John Brock)
Subject: Re: How to I arrange for a socket connection to time out?
Message-Id: <bc4uav$jbr$1@panix2.panix.com>
In article <3EE544D8.75A12AEC@hotpop.com>,
Benjamin Goldberg <ben.goldberg@hotpop.com> wrote:
>John Brock wrote:
[...snip...]
>> Since I couldn't get syswrite to work at all, and since recv/send
>> seem to be socket-specific, I feel like I've done the right thing,
>> but I wonder if anyone could clarify what the differences are?
>>
>> Also, is there any reason to unbuffer the socket filehandle (using
>> the $| variable)? Does this even make sense?
>The $| variable doesn't "unbuffer" the socket -- instead, it causes
>every print() to be automatically followed by a flush. It has no other
>effect whatsoever.
Thank you for a very helpful response! I do have one comment.
You said that send() is very much like syswrite(), and I noticed
that send(), like syswrite(), returns the number of bytes written,
so I worried that I could occasionally run into partial sends, and
I would have to check for this and resend the unsent portion of
the buffer (which would be very annoying, especially as it will be
hard to test the code if the condition happens only rarely).
However neither the description of the send() function in Programming
Perl nor the man page for the underlying system call send(2) says
anything about partial sends (as do the corresponding descriptions
of syswrite() and write(2)), and in fact there is a send(2) error
code:
EMSGSIZE The message is too large be sent all at once,
as the socket requires.
which seems to make clear that the send is all or nothing.
One other question: Programming Perl's description of sysread()
say something about the user needing to be "prepared to handle the
problems (like interrupted syscalls) that standard I/O normally
handles for you". Do you have any idea what they are talking about?
And is it possible that using recv() instead of sysread() also makes
life easier in this respect?
--
John Brock
jbrock@panix.com
------------------------------
Date: 10 Jun 2003 09:15:51 -0700
From: satishi@gwu.edu (slash)
Subject: Indenturing words into lists
Message-Id: <30fe9f1e.0306100815.2a5d10a0@posting.google.com>
Hi,
I am new to Perl and am trying to come up with an indentured list for
my following output of another program, which uses the following
segment (thanks to Jay Tilton's earlier posting)
for( @sorted ) {
printf "%s\n%s, %s\n", (split)[0, 1, 3];
}
print for @sorted;
2002 patent
2002 system
4 equal
4 each
4 equal
4 on
4 june
4 2002
a having
a d
a second
a d
a signal
a d
abstract 2002
abstract physical
abstract architectures
abstract digital
abstract cells
abstract device
the output is essentially two columns of words. What I am trying to
get is the following:
2002
patent
system
4
equal
each
equal
on
june
2002
a
having
d
second
d
signal
d
abstract
2002
physical
architectures
digital
Any suggestions would be greatly appreciated!
Thanks,
Satish
------------------------------
Date: Tue, 10 Jun 2003 18:38:40 +0200
From: Hans Fuchs <hans@enova.ch>
Subject: Per Object Private Attribs/Methods
Message-Id: <Pine.LNX.4.55.0306101820230.370@merlin.nine.ch>
Hi
I made a class using per object private data. I wonder if I could improve
the class somehow? What bothers me most is: $obj_priv{$self}. Is there a
better way constructing a objects hash? Does $self, which is
"Class=HASH(0x..)", perfom good enough as hash-key?
Did I miss any other securty issue? I would like to use this in a multi
user environment, where users can program.
Best,
Hans
package Hello;
my $obj_priv = {};
sub new
{
my $class = shift;
my $self = {};
bless($self, $class);
$obj_priv{$self}->{private_attrib} = "Hello world";
# Not directly accessible attrib
$obj_priv{$self}->{private_method} = sub { print "Hello Priv\n";};
# Not directly accessible method
return $self;
}
sub access_priv_attrib()
# Access the variable via a wrapper method (ACLs could be checked?)
{
my $self = shift;
if(@_) { $obj_priv{$self}{private_attrib} = shift }
return $obj_priv{$self}{private_attrib};
}
sub Hello # Test my setting!
{
my $self = shift;
$obj_priv{$self}->{private_method}();
print $self->access_priv_attrib . "\n";
}
1;
------------------------------
Date: 10 Jun 2003 18:21:36 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Per Object Private Attribs/Methods
Message-Id: <u9y909yhjz.fsf@wcl-l.bham.ac.uk>
Hans Fuchs <hans@enova.ch> writes:
> I made a class using per object private data. I wonder if I could improve
> the class somehow? What bothers me most is: $obj_priv{$self}.
What bothers me is you din't use strict. This means that some parts
of your program are talking about %{$obj_priv} and other parts are
talking about %obj_priv and you didn't notice.
> Is there a
> better way constructing a objects hash?
Not really. You can use RefHash but it's not better.
> Does $self, which is
> "Class=HASH(0x..)", perfom good enough as hash-key?
Yes as long as your DESTROY deletes entries from %obj_priv.
> Did I miss any other securty issue?
Well, %obj_priv is a package variable so users can simply access it as
%Hello::obj_priv.
I suspect you really wanted to make %obj_priv lexical (rather than
defining and never using a lexical $obj_priv).
> I would like to use this in a multi user environment, where users
> can program.
Users can always choose to bypass your so-called security by simply
making their own modified Hello.pm.
If you want to execute untrusted user code you should look into Safe
and Safe::Hole modules.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 10 Jun 2003 15:40:58 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: Perl CGI and Downloading Files - How?
Message-Id: <bc4u6a$fjgg9$1@ID-24002.news.dfncis.de>
10ghz@radiate.com wrote:
> On Mon, 9 Jun 2003 23:52:07 +0200, "Alan J. Flavell" <flavell@mail.cern.ch>
> wrote:
>>And this still isn't a question about Perl, specifically.
> Did you understand the part where I mentioned "Using Perl"?
Q: Using a Cadillac Seville, what's the best way to go
from Washington to Chicago?
A: First, it's the same way it would be for a Ford Mustang. Second,
that depends on which Washington you mean. Third, it depends on
if you mean "shortest" or "quickest" way.
SCNR =)
tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Tue, 10 Jun 2003 11:45:33 -0500
From: Dennis@NoSpam.com
Subject: Perl Matrix Filter Module like in Excel?
Message-Id: <ig2cevc0q2d1s49cifqnrdf9evrq4rosou@4ax.com>
In Excel VBA you can filter any column of the spreadsheet, with commands like
top 10% of column A and bottom 5% of column B and only thus rows that satisfy
both conditions will show.
Is there a perl module that can do the same thing?
Thanks.
Dennis
------------------------------
Date: 10 Jun 2003 10:38:48 -0700
From: iang@optonline.com (Ian)
Subject: Regular expression
Message-Id: <e3cb452a.0306100938.177b22e8@posting.google.com>
I have the following working by a series of splits, I have tried to
obtain the correct regular expression that woould work.
Say I had the following input line:
UPDATE=June 3, 2003 {maybe a time here or not} OS=5.7 MEMORY=512 MB
{possibly more data following the KEY=VALUE notation.
I would like to parse it so that I create a hash such that
$hash{UPDATE} = "june 3, 2003....."
$hash{OS} = "5.7"
so on.
So ideally I would like to create a string such that I can say
%hash = ($string)
where string is (UPDATE,"June 3, 2003",OS,"5.7",MEMORY,512).
Can this be done as a single regex? if so how.
Thanks in advance.
------------------------------
Date: Tue, 10 Jun 2003 17:32:37 +0200
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Returning a database array from a class
Message-Id: <bc50r7$sf4$1@news.dtag.de>
Resident Drunk wrote:
>Excuse my terminology - I come from a J2EE background & I am more used
> to talking about MVC (which is actually what I am trying to mimic).
welcome on the good side
> sub handler {
> ......
> my $deptClass = MyOrg::Model::Dept->new(DEPT_KEY => "$foo");
> my $dept = $deptClass->view();
In MVC systems the model usually doen't know the model.
I have written a MVC Framework and there are details in my use.perl
journal which should give you some ideas for your implementation.
Unfortunately, it's not ready for CPAN yet:
http://use.perl.org/journal.pl?op=display&uid=1708&start=10
The articles start on April, 01, 2003
There are ready-made alternatives on CPAN, though:
http://search.cpan.org/author/MUENALAN/Class-MVC-0.01.06/MVC.pm
http://search.cpan.org/author/JERLBAUM/CGI-Application-3.1/Application.pm
among others
> ......
> }
> ###################
>
> I have the above working, what I want to do now is have a subroutine (and I
> would like advice on where to place this) that returns all the rows in the
> dept table in a structured array so I could access them with something like
> (and apologies if incorrect syntax)
>
> my @biglistofdepts = $deptClass->returnAll(); # < This would be a subroutine
> in my model
> foreach $dept (@biglistofdepts)
> {
> print "Name = ", $dept->{'dept_desc'}, " Employees = ",
> $dept->{'dept_employee_count'},"\n";
> }
>
>
> So my question is - what would the returnAll() subroutine look like (ignoing
> db stuff) and how do I reference $dept->{'dept_desc'},
> $dept->{'dept_employee_count'} in the returned array ?.
What you probably really want is an iterator over your data:
Maybe this example code might help you (assumes you are using DBI):
package My::DBObject;
sub new_iterator { # first column is my id
my($class,$sql) = @_;
my $id_column = 0;
my $sth = $class->run_sql($sql);
return sub {
my @row = $sth->fetchrow_array;
return unless @row;
return $class->new_from_id($row[$id_column])
}
}
sub run_sql {
my($class,$sql) = @_;
my $dbh = $class->dbh;
my $sth = $dbh->prepare($sql) or die "Execute failed :[$DBI::errstr]
sql: [$sql]";
$sth->execute or die "Execute failed :[$DBI::errstr]
sql: [$sql]";
return $sth;
}
you can now do something like that:
my $iterator = My::DBObject->new_iterator(q{ SELECT id FROM my_table });
while(my $object = $iterator->()) {
print $object->some_method;
}
Obviously, there is stuff on CPAN to help you do this much better, too.
Bye,
malte
------------------------------
Date: 10 Jun 2003 18:10:21 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Returning a database array from a class
Message-Id: <u93cihzwn6.fsf@wcl-l.bham.ac.uk>
"Resident Drunk" <makemineaschripple@houseofbooze.com> writes:
> -- If I have a table containing dept_key, dept_desc, dept_employee_count and
> I want a single dept from dept key I would use :
> sub new {
> my $class = shift;
> my %args = @_;
> my $self;
> $self = bless {}, $class;
> my $dept_key= $args{'DEPT_KEY'};
> $self->{'dept_desc'} = undef;
> $self->{'dept_employee_count'} = undef;
It is probably redundant to explicitly set these elements to undef.
> #
> # Get row from database and assign it like this
> $self->{'dept_desc'} = $r_row->[0];
> $self->{'dept_employee_count'} = $r_row->[1];
A slice would be more conventional:
@$self{'dept_desc','dept_employee_count'} = @$r_row;
>
> return $self;
> }
>
> sub view {
> # the object itself will work for the view
> return shift;
> }
> I have the above working, what I want to do now is have a subroutine (and I
> would like advice on where to place this) that returns all the rows in the
> dept table in a structured array so I could access them with something like
> (and apologies if incorrect syntax)
>
> my @biglistofdepts = $deptClass->returnAll(); # < This would be a subroutine
> in my model
> foreach $dept (@biglistofdepts)
> {
> print "Name = ", $dept->{'dept_desc'}, " Employees = ",
> $dept->{'dept_employee_count'},"\n";
> }
>
>
> So my question is - what would the returnAll() subroutine look like (ignoing
> db stuff)
Very much like new.
sub returnAll {
my $class = shift;
my %args = @_;
my @ret;
# Get each row row from database and push it like this
my %row_hash;
@row_hash{'dept_desc','dept_employee_count'} = @$r_row;
push @ret => \%row_hash;
return \@ret;
}
Of course, if your database interface is DBI you are just
re-inventing:
$dbh->selectall_arrayref('SELECT * FROM some_view',{Slice=>{}}};
> and how do I reference $dept->{'dept_desc'},
> $dept->{'dept_employee_count'} in the returned array ?.
You have the syntax correct if $dept is an unblessed hashref.
Of course you may decide that it fits your conceptual model for
returnAll() to return an array of blessed hashes...
push @ret => bless \%row_hash, $class;
... in that case although the syntax you use would still work it
would be conceptually incorrect. In that case you'd use
$dept->view->{dept_desc} etc.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 10 Jun 2003 09:53:24 -0700
From: almir_7@yahoo.com (Almir)
Subject: Re: Search & Evaluate an array
Message-Id: <72ddae16.0306100853.7237ab31@posting.google.com>
I guess i wanted some guidance with the following code. I wanted to
see if anyone could point me in right direction or notice a problem
with me code. I need to check the whole array for the previous
occurance of that barcode with same date. To count that recort the
time difference is got to be 20minutes, with everything in between
gets skipped.I did the same quiery twice first off to populate the
array, so that it can be searched at all by grep. Maybe someone has a
good example how to do this or a better idea, but i does have to be in
perl...thanx once again
$i=0;
$db->Sql("SELECT plog.Barcode, plog.Auth_Date, plog.Auth_Time FROM
plog WHERE(((plog.Auth_Date) Between #3/1/2003# And #3/31/2003#) AND
((plog.Key)=[key]))"); #distinct users for the month
if ($db->FetchRow())
{
($barcode, $mdate, $mtime) = $db->Data();
$code[$i] = $barcode;
$dates[$i] = $1 if $mdate =~ /((\d\d\d\d)-(\d\d)-(\d\d))/;
$times[$i] = $1 if $mtime =~ /(\d\d:\d\d:\d\d)/;
}
@bfound = 0;
@dfound = 0;
@tfound = 0;
$i=1;
$db->Sql("SELECT plog.Barcode, plog.Auth_Date, plog.Auth_Time FROM
plog WHERE(((plog.Auth_Date) Between #3/1/2003# And #3/31/2003#) AND
((plog.Key)=[key]))"); #distinct users for the month
while ($db->FetchRow())
{
($barcode, $mdate, $mtime) = $db->Data(); #read in data by
row
$adate = $1 if $mdate =~ /((\d\d\d\d)-(\d\d)-(\d\d))/;
$atime = $1 if $mtime =~ /(\d\d:\d\d:\d\d)/;
@patron = ($barcode, $adate, $atime);
print "@patron\n";
if (@bfound = grep /$barcode/, @code) #check if there is the
previous barcode occurance
{
if (@dfound = grep /$adate/, @dates) #check if there is
the previous date occurance
{
if ($tfound = grep /$atime/, @times) #check if
there is a previous time occurance
{
}
else
{
($hour, $min, $sec) = ($times[$tfound] =~
m/(\d+):(\d+):(\d+)/);
$checkoff = ((($hour * 60)*60) + ($min * 60) +
$sec); #convert the time in seconds
($ahour, $amin, $asec) = ($atime =~
m/(\d+):(\d+):(\d+)/);
$inseconds = ((($ahour * 60)*60) + ($amin *
60) + $asec); #convert the time in seconds
if ($inseconds != $checkoff) #check if the
time is equal
{
if ($inseconds >= $checkoff + 1200)
#check if the time is bigger
{
$i+=1;
$code[$i] = $barcode;
$dates[$i] = $adate;
$times[$i] = $atime;
$number+=1;
}
}
else
{
$i+=1;
}
}
}
else
{
$i+=1;
$code[$i] = $barcode;
$dates[$i] = $adate;
$times[$i] = $atime;
$number+=1;
}
}
else
{
$i+=1;
$code[$i] = $barcode;
$dates[$i] = $adate;
$times[$i] = $atime;
$number+=1;
}
}
print "Number of Sessions: $number\n"
------------------------------
Date: 10 Jun 2003 09:09:13 -0700
From: big__smile@hotmail.com (big__smile)
Subject: setOutput in Perl
Message-Id: <299205ff.0306100809.7b8512f8@posting.google.com>
hi ppl!!
i am trying to make an xml file with perl in a cgi script!!
(Got it!!)
now the xml output is being directed to another file but when i run
the cgi script it displays the xml bit (which i don't wanna c)
so i found this function called setOutput in perldoc XML::Writer
but i get an error saying that the subroutine is undefined!!
i use it on a line by itself
setOutput($output);
It compiles perfectly but stuffs ont he browser.
------------------------------
Date: 10 Jun 2003 10:23:49 -0700
From: mfabache@yahoo.com (MF)
Subject: stripping leading zeros thru multiple fields
Message-Id: <2855726c.0306100923.3d82edc@posting.google.com>
I've come up with the following (via searches and copying code) to
strip all leading zeros thru a date field, but I cannot figure how to
get to the 2nd field+
Expected data: "06/06/2003"
Expected output: "6/6/2003"
Current output: "6/06/2003)" # How can I tweak this?
Thanks,
Michael
----
use POSIX qw(strftime) ;
# $now_string = strftime "%m/%d/%Y", localtime;
$now_string = "06/06/2003"; # for testing porposies
print "$now_string\n";
$now_string =~ s/0(\d+)/$1/; #strip leading zero off of MONTH, now
need DAY
print "$now_string\n";
------------------------------
Date: Tue, 10 Jun 2003 18:00:04 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: stripping leading zeros thru multiple fields
Message-Id: <mbudash-184D3F.11001410062003@typhoon.sonic.net>
In article <2855726c.0306100923.3d82edc@posting.google.com>,
mfabache@yahoo.com (MF) wrote:
> I've come up with the following (via searches and copying code) to
> strip all leading zeros thru a date field, but I cannot figure how to
> get to the 2nd field+
>
> Expected data: "06/06/2003"
> Expected output: "6/6/2003"
> Current output: "6/06/2003)" # How can I tweak this?
>
> Thanks,
> Michael
> ----
>
> use POSIX qw(strftime) ;
> # $now_string = strftime "%m/%d/%Y", localtime;
> $now_string = "06/06/2003"; # for testing porposies
> print "$now_string\n";
>
> $now_string =~ s/0(\d+)/$1/; #strip leading zero off of MONTH, now
> need DAY
> print "$now_string\n";
start with the g modifier on your substitution regex:
$now_string =~ s/0(\d+)/$1/g; # 'g' for 'global'
oh, but that affects the year, too:
output: 6/6/203
so let's be more specific:
$now_string =~ s{0(\d+(/|$))}{$1}g;
ahhh, there it is:
output: 6/6/2003
--
Michael Budash
------------------------------
Date: Tue, 10 Jun 2003 12:04:46 -0400
From: "Mike Bobbitt" <Mike@Army.ca>
Subject: Re: Unusual Can't load fail (web only) - SOLVED
Message-Id: <bc4vj1$fqs$1@news.storm.ca>
Well, after all this chasing around, I finally got it. I had 3 perl
binaries:
/usr/local/bin/perl
/usr/bin/perl
/bin/perl
One (/usr/bin/perl) was used by the web environment and had an @INC of
/usr/lib/perl5... /bin/perl was a symlink to
/usr/local/bin/perl, which was used by the command line and has an @INC of
/usr/local/lib/perl5... So all I've done was move /usr/bin/perl to perl.old
and symlink /usr/bin/perl to /usr/local/bin/perl. Now scripts work as
expected!
I can't believe I didn't check that first!
Oh well, thanks for your help all, things are now working great.
Cheers
------------------------------
Date: Tue, 10 Jun 2003 17:00:51 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: virtual x server for Tk
Message-Id: <79oFa.2559$_P2.130646217@newssvr21.news.prodigy.com>
Chip <chip@no-spam-afcoms.com> wrote:
> I am trying to use the Tk module with perl when I telnet
> into my server from a remote location and keep getting
> the following error:
> <snip>
> couldn't connect to display ":0"
> at /usr/lib/perl5/site_perl/5.8.0/i386-linux/Tk/MainWindow.pm
> </snip>
> I have installed the Tk-800.0024.tar.gz and can run the scripts
> from the server with the KDE 3.1 desktop so I know the scripts
> and the Tk module are working correctly.
> All the information I have found on google points to running a
> virtual x server but I can't seem to find anything on how to set
> it up.
It is unclear to me from your post what your intention is. Do you want
to see TK output on the screen in front of you? You say you used
'telnet' to reach the server, but telnet is insufficient to carry back
the graphical information.
You might be able to run (or already be running) an X server in front of
you (at your remote location). If so, you could probably set the
DISPLAY properly on the machine so the TK program knows where to send
the output.
None of this really has anything in particular to do with perl. It just
sounds like normal X traffic.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: 10 Jun 2003 17:14:46 GMT
From: Steve Lidie <lusol@cube0.CC.Lehigh.EDU>
Subject: Re: virtual x server for Tk
Message-Id: <bc53m6$fc6@fidoii.CC.Lehigh.EDU>
Darren Dunham <ddunham@redwood.taos.com> wrote:
> Chip <chip@no-spam-afcoms.com> wrote:
>> I am trying to use the Tk module with perl when I telnet
>> into my server from a remote location and keep getting
>> the following error:
>
>> <snip>
>> couldn't connect to display ":0"
>> at /usr/lib/perl5/site_perl/5.8.0/i386-linux/Tk/MainWindow.pm
>> </snip>
>
>> I have installed the Tk-800.0024.tar.gz and can run the scripts
>> from the server with the KDE 3.1 desktop so I know the scripts
>> and the Tk module are working correctly.
>
>> All the information I have found on google points to running a
>> virtual x server but I can't seem to find anything on how to set
>> it up.
>
> It is unclear to me from your post what your intention is. Do you want
> to see TK output on the screen in front of you? You say you used
> 'telnet' to reach the server, but telnet is insufficient to carry back
> the graphical information.
>
> You might be able to run (or already be running) an X server in front of
> you (at your remote location). If so, you could probably set the
> DISPLAY properly on the machine so the TK program knows where to send
> the output.
Use an ssh client instead and DISPLAY will be handled automatically. For
furthere help, use comp.lang.perl.tk, please.
>
> None of this really has anything in particular to do with perl. It just
> sounds like normal X traffic.
>
------------------------------
Date: 10 Jun 2003 10:21:35 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: Re: Win32::ListView sample please??
Message-Id: <6a8ba9f8.0306100921.5d203f53@posting.google.com>
"Mothra" <mothra@nowhereatall.com> wrote in message news:<3ee5e083$1@usenet.ugs.com>...
> Hi Kenjis,
>
> "Kenjis Kaan" <tivolinewbie@canada.com> wrote in message
> news:6a8ba9f8.0306092248.78b6263c@posting.google.com...
> > Hi, I am trying to create a listview program but no matter what I do
> > its is not working. I wonder if its because of the activestate perl
> > (5.6.1) I am using. I can open up a win32 window but the listview
> > just isn't what I wanted.
>
> [snipped]
>
> What is ListView? I checked CPAN and found no ListView.
>
> Mothra
Win32::GUI
from which you can create a ListView thing.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5103
***************************************