regular expression

2002-05-17 Thread ChaoZ InferNo
hi all, i am working to split the data in my array as follows but ended up clueless, hoope some of u can help. @text # contains values of a phone directory $text[0] contains john=012345678 $phone1 = ? let say i wanted to grab just the values'012345678'. how should i go on truncating the value

truncating carrier return character(s)

2002-05-17 Thread ChaoZ InferNo
It seems that when i am working with network programming, the input from the client will contain carrier return characters which the server interpreted as 2 carrier-return, how do i truncate the end carrier return characters? kindly advice... ... thanks!

Re: regular expression

2002-05-17 Thread Shawn
Hey Chaoz, #!/usr/bin/perl use strict; open(FILE,'); close(FILE); for(@text) { /(d+)$/; # Match only the numbers at the end of the string # and store them in '$1' to be printed out on the # next line followed by a new line character print $1,"\n"; } exit; shawn -

RE: regular expression

2002-05-17 Thread David Gray
> > for(@text) { > /(d+)$/; # Match only the numbers at the end of the string ^^ this should actually be (\d+) I would actually conditionally print also, like so: print $1 if /(\d+)$/; And depending on the size of the file, instead of reading the whole thing into memory wi

Re: regular expression

2002-05-17 Thread fliptop
ChaoZ InferNo wrote: > @text # contains values of a phone directory > $text[0] contains john=012345678 > > $phone1 = ? > > let say i wanted to grab just the values'012345678'. if the format of $text[0] is always name=number you can use split instead of a regex. perldoc -f split -- To uns

Re: regular expression

2002-05-17 Thread ChaoZ Inferno
Actually, the content of the file looks something like:- name=john id=12345 password=12345 colour=blue I am trying to grab the value field of each line and assigned it to be a variable. I tried the regular expressions, but seems like the syntax is wrong or something, @file = ; #small file anywa

RE: regular expression

2002-05-17 Thread Scot Robnett
Regular expressions are overkill for what you're trying to do. It seems like using 'split' should do exactly what you need. #!/usr/bin/perl -W use strict; open(IN,"; close(IN); for(@list) { chomp; my($field,$value) = split(/=/,$_); # split each line on '=' print "Your $field is $value. \n";

Re: regular expression

2002-05-17 Thread Shawn
Ok, first, thanks for the correction and input David... I agree 100% with what you say. Secondly, am I just crazy, or doesn't split USE regex? Since this is the second mention the regex is overkill, and that split will work, I am a bit confused... When you can say $var=split(/=|:/); it tell

RE: regular expression vs split

2002-05-17 Thread Brian
Curious, but I've always thought that regex was much quicker then split for situations such as this... I'd always figured that split was basically a (and the regex for this is probably wrong, but you can get the jist of it) /[^($delimiter | end of string)/ with a dumping of the match minus the

Re: regular expression

2002-05-17 Thread Shawn
> Actually, the content of the file looks something like:- > name=john > id=12345 > password=12345 > colour=blue Ok, how about this then... This is based on the fact that name, id, password, colour appear for every record whether they have a value or not, and that none of the values after the '

RE: regular expression

2002-05-17 Thread Joel Hughes
...it certainly looks like a regex to me -Original Message- From: Shawn [mailto:[EMAIL PROTECTED]] Sent: 17 May 2002 16:03 To: Scot Robnett; ChaoZ Inferno; [EMAIL PROTECTED] Subject: Re: regular expression Ok, first, thanks for the correction and input David... I agree 100% with what y

RE: regular expression vs split

2002-05-17 Thread Scot Robnett
I don't believe that a regex would be faster in an instance like this, but someone please correct me if I'm wrong. It seems that it would add (albeit a very minimal amount) processing overhead to apply a regular expression to each line rather than using the built-in split function on it, depending

Re: regular expression

2002-05-17 Thread John Brooking
I just happened to write exactly this the other day, as a generic configuration file reader. Here's the basics: sub readINI {# argument: filename my %params; open( INIFILE, $_[0] ) || die "Could not open $_[0]\n"; while() { if(! /^#/ ) { # Allow comments chomp;

What's up with CPAN?

2002-05-17 Thread Scot Robnett
Anybody else having trouble reaching search.cpan.org or wait.cpan.org today? I can get to the main site, but I can't get to module documentation. Scot R. --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.351 / Virus Database: 197

Re: Send mail question

2002-05-17 Thread eric-perl
On Fri, 10 May 2002, fliptop wrote: > Lance Prais wrote: > > If I am going to sendmail from an Internet using CGI does anyone know all > > the modules I will need to install? This may answer all my questions. > > i use mime::lite and it works great and is simple to use. Ditto. -- Eric P. Los