Re: regex to match a range of numbers?

2006-06-07 Thread Anthony Ettinger
You can simply split on whitespace. http://perl-e.chovy.com/sample/date-parse On 6/7/06, Joshua Colson <[EMAIL PROTECTED]> wrote: I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand

Re: regex to match a range of numbers

2006-06-07 Thread John W. Krahn
Joshua Colson wrote: > On Wed, 2006-06-07 at 16:20 -0600, Jeremy Vinding wrote: >>Joshua Colson wrote: >>>print $3 if $date =~ m{(Wed)\s(Jun)\s{1,2}([1..31])}; >>> >>I believe you'd have to use alternation. >> >>for example, something like: >>/(0?[1-9]|[12][0-9]|3[01])/ >>or >>/([012]?[1-9]|[1-3]0|

Re: regex to match a range of numbers

2006-06-07 Thread Dr.Ruud
Joshua Colson schreef: > I'm trying to parse a date from a file and I would like to know how to > match a range of numbers with a regex? For example, the days of the > month 1..31. I understand that there are numerous modules that can do > the work for me, this is as much for my own learning as an

regex to match a range of numbers?

2006-06-07 Thread Joshua Colson
I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as anything. Thanks. --

RE: defaults

2006-06-07 Thread Timothy Johnson
-Original Message- From: Bryan R Harris [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 07, 2006 4:43 PM To: Beginners Perl Subject: Re: defaults > > > Take this (lame) example of an RSVP to an invitation: > > ** > $_ = "Bill, 3"; # name, number

Re: defaults

2006-06-07 Thread Bryan R Harris
> Bryan R Harris wrote: >> >> Can someone explain what: >> >> $pi ||= 3; >> >> ...means? I just saw it in Programming Perl (pp 540), but it doesn't >> explain it. Thx! > > || is the logical OR operator (see perldoc perlop) which says that if $pi is > TRUE then keep the current value of $pi

Re: regex to match a range of numbers

2006-06-07 Thread Joshua Colson
On Thu, 2006-06-08 at 00:55 +0200, Flemming Greve Skovengaard wrote: > If you are just going to print the day number and you have other dates in a > similar format why not just use: > > print +(split /\s+/, $date)[2]; Well, in this particular instance, I am. However, there have been at least a f

Re: regex to match a range of numbers

2006-06-07 Thread Joshua Colson
On Wed, 2006-06-07 at 15:55 -0700, John W. Krahn wrote: > print $1 if $date =~ m{ > Wed > \s > Jun > \s\s? > ( [1-9] | [1-2]\d | 3[0-1] ) > \s > }x; >

Re: regex to match a range of numbers

2006-06-07 Thread Joshua Colson
On Wed, 2006-06-07 at 16:20 -0600, Jeremy Vinding wrote: > Joshua Colson wrote: > > > > print $3 if $date =~ m{(Wed)\s(Jun)\s{1,2}([1..31])}; > > > I believe you'd have to use alternation. > > for example, something like: > /(0?[1-9]|[12][0-9]|3[01])/ > or > /([012]?[1-9]|[1-3]0|31)/ That does

Re: regex to match a range of numbers

2006-06-07 Thread John W. Krahn
Joshua Colson wrote: > I'm trying to parse a date from a file and I would like to know how to > match a range of numbers with a regex? For example, the days of the > month 1..31. I understand that there are numerous modules that can do > the work for me, this is as much for my own learning as anyth

Re: regex to match a range of numbers

2006-06-07 Thread Flemming Greve Skovengaard
Joshua Colson wrote: I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as anything.

Re: Can't locate object method - weirdness

2006-06-07 Thread Graeme McLaren
Hi there .. thank you for your reply - I managed to get it fixed. Not sure its the greatest class ever but it works. Thanks again, G :) From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]> To: beginners@perl.org Subject: Re: Can't locate object method - weirdness Date: Wed, 07 Jun 2006

Re: reading Perl syntax

2006-06-07 Thread reader
"Mr. Shawn H. Corey" <[EMAIL PROTECTED]> writes: > my $args = shift Subroutine: sub new { my $class = shift; my $self = bless {}, $class; my $args = shift; $self->{file} = $args->{file}; $self->{is_reversed} = $args->{reversed} ? 1 : 0; $self->_read_file($self->{file}); $self->{filt

Re: Search for a Word in a file

2006-06-07 Thread John W. Krahn
anu p wrote: > Hi All, Hello, > I have a requirement where I need to check if a word > exists in a text file and if so, get the whole line of > text which contains the word. I also need to split the > line on space. > > Example: > >1 1 0 0 P 6/6 > - > Code: > >

regex to match a range of numbers

2006-06-07 Thread Joshua Colson
I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as anything. Thanks. --

Re: defaults

2006-06-07 Thread John W. Krahn
Randal L. Schwartz wrote: >>"Bryan" == Bryan R Harris <[EMAIL PROTECTED]> writes: > > Bryan> Is there an "&&=" also? How about "or="? > > There's an &&=, and I thought I'd never use it. > > However, one day, I realized that I needed to "normalize" the "true/false" > value of a variable, bec

Re: help Data dirven script

2006-06-07 Thread Paul Johnson
On Wed, Jun 07, 2006 at 01:18:53PM +0530, Manjula Gowda wrote: > Dear all, > > > >Iam trying to a write a script to test one login screen. To this screen i > >want to drive different data pls can anybody help me write perl scipt for > >data driven testing. > > > >Its very urgent.Thanks in advance

Re: reading Perl syntax

2006-06-07 Thread Mr. Shawn H. Corey
On Wed, 2006-07-06 at 16:16 -0500, [EMAIL PROTECTED] wrote: > Well I didn't learn a thing from that either: > my $args = shift; This is the line you should be interested in. Could you show the subroutine it is in? Also add after it: use Data::Dumper; print Dumper $args; > $self->{file} =

Re: reading Perl syntax

2006-06-07 Thread reader
"Mr. Shawn H. Corey" <[EMAIL PROTECTED]> writes: > perl -n -e "/\bargs\b/ && print" lib/Database.pm Well I didn't learn a thing from that either: my $args = shift; $self->{file} = $args->{file}; $self->{is_reversed} = $args->{reversed} ? 1 : 0; if (defined $args->{views}) $self->{view

How to create a new browser window using CGI

2006-06-07 Thread chen li
Dear all, How can I add a line (lines) to the following script so that I can show the results on a new browser window after I press the submit button? Thanks, Li #!c:/Perl/bin/perl.exe use warnings; use strict; use CGI; my $query_obj=CGI->new(); #creat webpage print $query_obj->header; print

Re: Can't locate object method - weirdness

2006-06-07 Thread Adriano Ferreira
Graeme, (Send your messages to the list beginners@perl.org so that more people can help you out.) I still don't know where your problem is. The files you sent look ok, with some remarks: em_log.pm should contain the statement "package SI::eventmaster::em_log;" rather than "package em_log;

Re: Can't locate object method - weirdness

2006-06-07 Thread Tom Phoenix
On 6/7/06, Graeme McLaren <[EMAIL PROTECTED]> wrote: Can't locate object method "dbh" via package "em_log" at in my class I have: sub dbh{ Is it, really and truly, in the correct class? And your class is named "em_log", in all lower case? (This method isn't inherited, is it?) Generally, P

Re: Can't locate object method - weirdness

2006-06-07 Thread Mr. Shawn H. Corey
On Wed, 2006-07-06 at 15:50 +0100, Graeme McLaren wrote: > Hi all, I have a weird error: > > Can't locate object method "dbh" via package "em_log" at > /path/log.cgi line 15. > > > line 15 is the second of these two lines: > > my $log = em_log->new; > $log->dbh($dbh); > > > in my class I hav

Re: defaults

2006-06-07 Thread Randal L. Schwartz
> "Bryan" == Bryan R Harris <[EMAIL PROTECTED]> writes: Bryan> Is there an "&&=" also? How about "or="? There's an &&=, and I thought I'd never use it. However, one day, I realized that I needed to "normalize" the "true/false" value of a variable, because I wanted to reduce all possible tru

Re: Can't locate object method - weirdness

2006-06-07 Thread Adriano Ferreira
On 6/7/06, Graeme McLaren <[EMAIL PROTECTED]> wrote: Hi there, thanks for your reply, here is my constructor: sub new{ my ($class) = @_; my $self = { _table => undef, _id => undef, # this refers to the column named "pkey_updated_record" in the log table _dbh => u

Re: Can't locate object method - weirdness

2006-06-07 Thread Adriano Ferreira
On 6/7/06, Graeme McLaren <[EMAIL PROTECTED]> wrote: Hi all, I have a weird error: Can't locate object method "dbh" via package "em_log" at /path/log.cgi line 15. line 15 is the second of these two lines: my $log = em_log->new; $log->dbh($dbh); Does your code define a suitable new() ? The b

RE: reading Perl syntax

2006-06-07 Thread Christian, Ed
> > Merely referencing a key in a hash sets it into the hash, > though with a > > value of undef. > > This turns out not to be the case. In Perl, merely referencing a key > in a hash doesn't change the hash. Some non-Perl hash implementations > do change the hash in those circumstances, though, s

Can't locate object method - weirdness

2006-06-07 Thread Graeme McLaren
Hi all, I have a weird error: Can't locate object method "dbh" via package "em_log" at /path/log.cgi line 15. line 15 is the second of these two lines: my $log = em_log->new; $log->dbh($dbh); in my class I have: sub dbh{ my $self = shift; my $dbh = shift; $self->{_dbh} = $dbh i

Re: Search for a Word in a file

2006-06-07 Thread Adriano Ferreira
It seems like I did not read enough of your message to give you a sensible answer to your problem. # write a function to do what the one-liner did, but stopping at the first row sub find_first { my $regex = shift; local @ARGV = @_; while (<>) { retu

Re: Search for a Word in a file

2006-06-07 Thread Adriano Ferreira
This one-liner works a bit like a (Unix) grep: perl -n -e 'print if //' temp.txt and is probably efficient enough for most cases. On 6/7/06, anu p <[EMAIL PROTECTED]> wrote: Hi All, I have a requirement where I need to check if a word exists in a text file and if so, get the whole line of t

Search for a Word in a file

2006-06-07 Thread anu p
Hi All, I have a requirement where I need to check if a word exists in a text file and if so, get the whole line of text which contains the word. I also need to split the line on space. Example: 1 1 0 0 P 6/6 - Code: open (FIN, "temp.txt") || die "Cannot open file

RE: reading Perl syntax

2006-06-07 Thread Ron Goral
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of > Tom Phoenix > Sent: Wednesday, 07 June, 2006 08:00 > To: Ron Goral > Cc: beginners@perl.org > Subject: Re: reading Perl syntax > > > On 6/7/06, Ron Goral <[EMAIL PROTECTED]> wrote: > > > Merely referen

RE: reading Perl syntax

2006-06-07 Thread Mr. Shawn H. Corey
On Wed, 2006-07-06 at 07:49 -0500, Ron Goral wrote: > Merely referencing a key in a hash sets it into the hash, though with a > value of undef. No, it does not. You have to actually assign it a value for the key to appear. The value you assign it may be undef, but Data::Dumper will only show the k

Re: reading Perl syntax

2006-06-07 Thread Tom Phoenix
On 6/7/06, Ron Goral <[EMAIL PROTECTED]> wrote: Merely referencing a key in a hash sets it into the hash, though with a value of undef. This turns out not to be the case. In Perl, merely referencing a key in a hash doesn't change the hash. Some non-Perl hash implementations do change the hash

RE: reading Perl syntax

2006-06-07 Thread Ron Goral
> -Original Message- > From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] > Sent: Wednesday, 07 June, 2006 07:16 > To: beginners@perl.org > Subject: Re: reading Perl syntax > > > On Tue, 2006-06-06 at 22:23 -0500, [EMAIL PROTECTED] wrote: > > 46: $self->{file} = $args->{file}; > > This i

Re: using shared lib?

2006-06-07 Thread Mr. Shawn H. Corey
On Wed, 2006-07-06 at 13:40 +0700, Beast wrote: > Hello all, > > Just curious, is it possible to use shared library in perl? > Suppose I want to use libexample.so and doesn't want to invoke the > client command using system() > > TIA. > Yes, it's possible but not easy. See perldocs:

Re: reading Perl syntax

2006-06-07 Thread Mr. Shawn H. Corey
On Tue, 2006-06-06 at 22:23 -0500, [EMAIL PROTECTED] wrote: > 46: $self->{file} = $args->{file}; This is the line were $self->{file} is set to undef. > 48: $self->_read_file($self->{file}); > > ** => 214: my $file = shift; And here $file is set to $self->{file}, which is undef So what is $a

Re: help Data dirven script

2006-06-07 Thread Manjula Gowda
Dear all, Iam trying to a write a script to test one login screen. To this screen i want to drive different data pls can anybody help me write perl scipt for data driven testing. Its very urgent.Thanks in advance Thanks & Regards Manjula