Re: Regex question

2002-03-10 Thread fliptop

Scot Robnett wrote:

 Hey y'all, I got over my brain cramp and thought I'd share with the group in
 case it helps anyone trying to do something similar. I was making it way too
 complicated. All I needed was:
 
 if($email !~ /\w+@\w+\.\w{2,4}/)
 {
  # error stuff here
 }


have you considered using email::valid?

http://search.cpan.org/search?dist=Email-Valid


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Regex question

2002-03-10 Thread Rene Verharen

At 10-3-2002 09:36 -0500, fliptop wrote:

Hey y'all, I got over my brain cramp and thought I'd share with the group in
case it helps anyone trying to do something similar. I was making it way too
complicated. All I needed was:
if($email !~ /\w+@\w+\.\w{2,4}/)
{
  # error stuff here
}


have you considered using email::valid?

http://search.cpan.org/search?dist=Email-Valid

Is there also a module or another way to test the existence of an email 
address ?



Kind regards,



Rene Verharen


Please DO NOT reply to me personally.  I'll get my copy from the list.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Regex question

2002-03-10 Thread Scot Robnett

I don't think you can check for the existence of an e-mail address without
actually attempting to send mail to it. You can ping or traceroute a domain,
but only the mail server associated with it knows if the username is valid
or not. If this is wrong, somebody with information please reply to the
list - it might be on the 'wish list' for a lot of people, including me. :)

Scot Robnett
inSite Internet Solutions
[EMAIL PROTECTED]
www.insiteful.tv






Is there also a module or another way to test the existence of an email
address ?


Kind regards,
Rene Verharen

Please DO NOT reply to me personally.  I'll get my copy from the list.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.325 / Virus Database: 182 - Release Date: 2/19/2002


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: changing the defualt nobody@somecomputer.com (mailx)

2002-03-10 Thread Rob Roudebush


 I'm using mailx from within a script, so I can't use it interactively open (MFH, | 
mailx -s 'Subject' [EMAIL PROTECTED])
print MFH end; blah blah blah... end close MFH;
Should I just be using mail? Do you know what the switch or option is for From: 
someoneelse?
  Rob Helmer [EMAIL PROTECTED] wrote: On Fri, Mar 08, 2002 at 06:05:07PM -0800, Rob 
Roudebush wrote:
 
 My CGI script shoots out an automated e-mail using mailx. Is there any way to change 
the nobody?
 -Rob

Hi Rob,


Yes, you can change the From: header.

Are you actually constructing an email and passing it to
mailx? You should, specify the To:, From:, Subject: headers,
then pass it to mail ( is there any reason to use mailx? It's
supposed to be for interactive use.



Thanks,
Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!


Re: Writing to beginning of file

2002-03-10 Thread Jon Molin

Troy May wrote:
 
 Hello,
 
 How do you write to the beginning of a file?  I see only 3 options to open a
 file:  to read, to overwrite, and to append to the end of the file.
 

If you think about the file as an array with one char on each index:
my @string = split (/|/, this is a test);
now $string[0] eq 't', if you want to insert a char before that you (or
a build in function) will have to make the array 1 index larger, move
everything ahead one step and set the first char to whatever you want it
to be.
The same goes for files, you can open a new file, print what you want to
have first, append the old file and rename it to the old filename. Or
you can use the build in functios for it (look at -i flag in 'perldoc
perlrun').

/jon

 I tried seeking to the beginning before the write, but it doesn't work.
 Seek must only work for a read.
 
 Any ideas?
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Writing to beginning of file

2002-03-10 Thread John W. Krahn

Troy May wrote:
 
 Hello,

Hello,

 How do you write to the beginning of a file?  I see only 3 options to open a
 file:  to read, to overwrite, and to append to the end of the file.
 
 I tried seeking to the beginning before the write, but it doesn't work.
 Seek must only work for a read.
 
 Any ideas?


perl -pi -e's/^/Put this at the beginning\n/ if $. == 1' yourfile.txt



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: suidperl problem

2002-03-10 Thread Johannes Franken

On Sat, Mar 09, 2002 at 12:37:23AM +0100, Patrik Schaub [FMS] wrote:
 the script needs to have root rights in order to do this,
 but it will be used by another user. suidperl seems to be
 the only way to achive this.

What about sudo ?

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




AW: suidperl problem

2002-03-10 Thread Patrik Schaub [FMS]

hi johannes,

could be a sollution - thanks

but i really wonder why a perl script which is
setuid root and setguid root wont't do a simple

`/etc/init.d/hylafax restart`

for example.

(it`s not a tainting problem)

patrik

-Ursprungliche Nachricht-
Von: Johannes Franken [mailto:[EMAIL PROTECTED]]
Gesendet: Sonntag, 10. Marz 2002 12:33
An: Perl-Beginner
Betreff: Re: suidperl problem


On Sat, Mar 09, 2002 at 12:37:23AM +0100, Patrik Schaub [FMS] wrote:
 the script needs to have root rights in order to do this,
 but it will be used by another user. suidperl seems to be
 the only way to achive this.

What about sudo ?

-- 
Johannes Franken
 
Professional unix/network development
mailto:[EMAIL PROTECTED]
http://www.jfranken.de/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Win32::API module

2002-03-10 Thread Thomas Whitney

If you wish to use nmake.exe, you need to download it.
It is available at.
ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe. You can get tar and
gzip from http://www.itribe.net/virtunix/.

I recently had the same problem and (thanks ot those whe pointed me in the
right direction) downloading nmake fixed it.

Thomas Whitney


 Does anyone know how to install the Win32::API module onto a
 Win2K professional system? I found this module on cpan but the
 instructions call for 'make' and 'make' is not available on Win32.
 Thanks.






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




split// question

2002-03-10 Thread Karsten Borgwaldt

Hi all,

i have a problem to split data of a file.
The data has the following structure :

key=value
key2=value2


When reading this file, there's no problem, but if I want to split the
lines...

This is the sourcecode:

open(file,  foo.bar);
@myArray = file;
close(file);
foreach (@myArray) {($1, $2, $3) = split /=/; $list{$1}=$3;}

it seems to work, but if I add this line:

foreach $item (keys(%list)) {print $item $list{$item}\n;}

it does not print anything.

please help!!!

Karsten


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: split// question

2002-03-10 Thread Jeff 'japhy' Pinyan

On Mar 10, Karsten Borgwaldt said:

key=value
key2=value2


This is the sourcecode:

I can assure you it isn't; your code assigns to $1, $2, and $3 -- you
can't do that.

open(file,  foo.bar);

If you had warnings on, you'd be told that filehandles should be written
in uppercase for safety.

  open FILE,  foo.bar;

@myArray = file;
close(file);
foreach (@myArray) {($1, $2, $3) = split /=/; $list{$1}=$3;}

There's no need to read the file into an array and then loop over the
array.  Why not do:

  while (FILE) {
chomp;  # remove the newline;
my ($field, $value) = split /=/;
$data{$field} = $value;
  }

The reason your code breaks is because you are misunderstanding
split(); it does NOT return what the regex matched.

  split /=/, a=b

does not return (a, =, b).  It returns (a, b).

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for Regular Expressions in Perl published by Manning, in 2002 **
stu what does y/// stand for?  tenderpuss why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: split// question

2002-03-10 Thread Jonathan E. Paton

 The reason your code breaks is because you are
 misunderstanding split(); it does NOT return what
 the regex matched.
 
   split /=/, a=b
 
 does not return (a, =, b).  It returns (a, b).

Unless of course you write split as:

split /(=)/, a=b;

But you rarely, if ever, need to do something like that.

Jonathan Paton

__
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Writing to beginning of file

2002-03-10 Thread Elaine -HFB- Ashton

Troy May [[EMAIL PROTECTED]] quoth:
*Hello,
*
*How do you write to the beginning of a file?  I see only 3 options to open a
*file:  to read, to overwrite, and to append to the end of the file.
*
*I tried seeking to the beginning before the write, but it doesn't work.
*Seek must only work for a read.
*
*Any ideas?

The FAQ should be your first and second idea, always. perldoc perlfaq5 or
see the 2nd question in
http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq5.html

e.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: suidperl problem

2002-03-10 Thread Elaine -HFB- Ashton

Patrik Schaub [FMS] [[EMAIL PROTECTED]] quoth:
*hi johannes,
*
*could be a sollution - thanks
*
*but i really wonder why a perl script which is
*setuid root and setguid root wont't do a simple

Check the filesystem and make sure your SA hasn't gone and done the wise
thing of mounting the volume -nosuid. If your're the SA then try
truss/trace/dtrace/etc. to see what's happening. 

e.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Connecting to a Database

2002-03-10 Thread Thomas Whitney

Hi,
 I am trying to open a database connection and having a problem--it will NOT
open.
Here is the code that I am using.

# security is the name of the database.
#user_data is the name of the access table
 $path = $Server-MapPath(security.mdb);
 $data = driver={Microsoft Access Driver (*.mdb)};database= . $path;
 $Conn = $Server-CreateObject(ADODB.Connection);

# above goes fine
# then next line dies

 $Conn-Open($data) ||  die Cannot Open;
 $RS = $Conn-Execute(SELECT * FROM user_data );

If I leave out the || die statement,
when I try to access the Fields method with this code

 foreach my $field (Win32::OLE::in($RS-Fields)) {

I get this

 Can't call method Fields on unblessed reference.

Now, I know the driver is good because the following vbscript code Works
!!!.

data_source = DRIVER={Microsoft Access Driver (*.mdb)};DBQ= 
Server.MapPath(data/security.mdb)
Set con = Server.CreateObject(ADODB.Connection)
con.Open data_source

Anyone have any idea what I am doing wrong??
You help would be appreciated.

Thanks,
Thomas Whitney

Just for misc. informatinon
Ths following is from the MSDN ADO docs on the OPEN method

' Open a connection without using a Data Source Name (DSN)
   Set Cnxn1 = New ADODB.Connection
   Cnxn1.ConnectionString = driver={SQL
Server};server=srv;uid=sa;pwd=pwd;database=Pubs
   Cnxn1.ConnectionTimeout = 30
   Cnxn1.Open





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Finding words between words...

2002-03-10 Thread Daniel Falkenberg

Hello all,

I have some text here that I have placed in a string.  I want to be able
to extract words between text of my choice.  For example in the
string...

$string = Hello world In: crud all Your.;

($mytext) = $string =~ /In:(.*)Your/;

The above works fine but how can I tell my regex to stop as soon as it
finds these words.  For example if in the string...

$string = Hello world In: crud all Your. hello again In: crud aagin
Your at the...;

The regex above will go crazy?

Any Ideas,

Thx,

Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Connecting to a Database

2002-03-10 Thread Thomas Whitney

You can disregard the previous message -- I finally got to work, (by sheer
tiral and error).  If any is interested, let me know and I will send the
code that woks.



Thomas Whitney [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,
  I am trying to open a database connection and having a problem--it will
NOT
 open.
 Here is the code that I am using.

 # security is the name of the database.
 #user_data is the name of the access table
  $path = $Server-MapPath(security.mdb);
  $data = driver={Microsoft Access Driver (*.mdb)};database= . $path;
  $Conn = $Server-CreateObject(ADODB.Connection);

 # above goes fine
 # then next line dies

  $Conn-Open($data) ||  die Cannot Open;
  $RS = $Conn-Execute(SELECT * FROM user_data );

 If I leave out the || die statement,
 when I try to access the Fields method with this code

  foreach my $field (Win32::OLE::in($RS-Fields)) {

 I get this

  Can't call method Fields on unblessed reference.

 Now, I know the driver is good because the following vbscript code Works
 !!!.

 data_source = DRIVER={Microsoft Access Driver (*.mdb)};DBQ= 
 Server.MapPath(data/security.mdb)
 Set con = Server.CreateObject(ADODB.Connection)
 con.Open data_source

 Anyone have any idea what I am doing wrong??
 You help would be appreciated.

 Thanks,
 Thomas Whitney

 Just for misc. informatinon
 Ths following is from the MSDN ADO docs on the OPEN method

 ' Open a connection without using a Data Source Name (DSN)
Set Cnxn1 = New ADODB.Connection
Cnxn1.ConnectionString = driver={SQL
 Server};server=srv;uid=sa;pwd=pwd;database=Pubs
Cnxn1.ConnectionTimeout = 30
Cnxn1.Open







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




what if or next if...?

2002-03-10 Thread Daniel Falkenberg

G'day all,

Just wondering if some one can help me with the folloing problem...?

Basically I have a variable that will change at regular intervals.  The
varible may look like this...

$var = Crud Crud Call Distance: UNfasdfasdfasdfasdfasdn alternative.
(fasdfsda) SuperZone region: Gawler Call Distance:;

($locat) = $content =~ /Located at:(.*)Call /);
print $locat;

SO that will print everything between the VERY last Call Distance.  Some
times there will not be a second Call Distance located in $var and
instead $var will look something like the following...

$var = crud crud Crud;  # I.e there is no Call Distance in $var.

How can I get my code to check all possible outcomes?  Would I do
something like the following...

nextif (($locat) = $content =~ /Located at:(.*)Call /)) {
  print $locat;
nextif (($locat) = $content =~ /(.*)Call Distance/)) {
  print $locat;
}

Kind Regards,

Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Stripping everything after words found

2002-03-10 Thread Daniel Falkenberg

Hey All,

If I have a string that looks like the following...

$string = Crud I want Call Distance more crud skdafj 343sad55434 ;

How would I go about getting rid of everything after the Call distance
and including the Call Distance?  Would it be somthing like the
following...?

($test) = $string =~ /(.*)Call Distance\+swd/;

I.e and strip and thing with words, numerals or white space.

Kind regards,

Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Stripping everything after words found

2002-03-10 Thread bob ackerman

how about:
($test) = $string =~ /(.*Call Distance)/;

On Sunday, March 10, 2002, at 08:27  PM, Daniel Falkenberg wrote:

 $string = Crud I want Call Distance more crud skdafj 343sad55434 ;

 How would I go about getting rid of everything after the Call distance
 and including the Call Distance?



Re: Stripping everything after words found

2002-03-10 Thread bob ackerman

oh - you didn't want to include 'Call Distance'?
then:
($test) = $string =~ /(.*)Call Distance/;

would only capture text up to 'Call Distance'. Needn't worry about rest of 
string.

On Sunday, March 10, 2002, at 08:54  PM, bob ackerman wrote:

 how about:
 ($test) = $string =~ /(.*Call Distance)/;

 On Sunday, March 10, 2002, at 08:27  PM, Daniel Falkenberg wrote:

 $string = Crud I want Call Distance more crud skdafj 343sad55434 ;

 How would I go about getting rid of everything after the Call distance
 and including the Call Distance?



RE: Stripping everything after words found

2002-03-10 Thread Daniel Falkenberg

Bob,

This is what I had in the first place (($test) = $string =~ /(.*)Call
Distance/;).  All I want to do is extract EVERYTHING before the first
instance of Call Distance:.  From there using the same regular
expression I need to remove EVERYTHING after Call Distance:. Including
Call Distance:.  So if I had the string...

$string = Kind Crud Call Distance: hell world Crud Call Distance:;

Using a regex.  I should end up with only *Kind Crud* and that is all.

Any ideas?

Kind regards,

Dan

-Original Message-
From: bob ackerman [mailto:[EMAIL PROTECTED]]
Sent: Monday, 11 March 2002 3:47 PM
To: Daniel Falkenberg
Cc: [EMAIL PROTECTED]
Subject: Re: Stripping everything after words found


oh - you didn't want to include 'Call Distance'? 
then: 
($test) = $string =~ /(.*)Call Distance/; 


would only capture text up to 'Call Distance'. Needn't worry about rest
of string. 


On Sunday, March 10, 2002, at 08:54 PM, bob ackerman wrote: 


how about: 
($test) = $string =~ /(.*Call Distance)/; 


On Sunday, March 10, 2002, at 08:27 PM, Daniel Falkenberg wrote: 


$string = Crud I want Call Distance more crud skdafj 343sad55434 ; 


How would I go about getting rid of everything after the Call distance 
and including the Call Distance? 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Stripping everything after words found

2002-03-10 Thread Tanton Gibbs

You want to extract the LEAST possible...use

$string =~ s/^(.*?)Call Distance/$1/;

Tanton
- Original Message - 
From: Daniel Falkenberg [EMAIL PROTECTED]
To: bob ackerman [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Monday, March 11, 2002 12:26 AM
Subject: RE: Stripping everything after words found


 Bob,
 
 This is what I had in the first place (($test) = $string =~ /(.*)Call
 Distance/;).  All I want to do is extract EVERYTHING before the first
 instance of Call Distance:.  From there using the same regular
 expression I need to remove EVERYTHING after Call Distance:. Including
 Call Distance:.  So if I had the string...
 
 $string = Kind Crud Call Distance: hell world Crud Call Distance:;
 
 Using a regex.  I should end up with only *Kind Crud* and that is all.
 
 Any ideas?
 
 Kind regards,
 
 Dan
 
 -Original Message-
 From: bob ackerman [mailto:[EMAIL PROTECTED]]
 Sent: Monday, 11 March 2002 3:47 PM
 To: Daniel Falkenberg
 Cc: [EMAIL PROTECTED]
 Subject: Re: Stripping everything after words found
 
 
 oh - you didn't want to include 'Call Distance'? 
 then: 
 ($test) = $string =~ /(.*)Call Distance/; 
 
 
 would only capture text up to 'Call Distance'. Needn't worry about rest
 of string. 
 
 
 On Sunday, March 10, 2002, at 08:54 PM, bob ackerman wrote: 
 
 
 how about: 
 ($test) = $string =~ /(.*Call Distance)/; 
 
 
 On Sunday, March 10, 2002, at 08:27 PM, Daniel Falkenberg wrote: 
 
 
 $string = Crud I want Call Distance more crud skdafj 343sad55434 ; 
 
 
 How would I go about getting rid of everything after the Call distance 
 and including the Call Distance? 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




uploading files

2002-03-10 Thread Mariusz

Hi,

I wrote this simple script to upload files, but when I substitute param('uploadfile') 
with the actual path in double quotes it doesn't work that way. However, it works 
perfectly fine if I use the form to submit the path of the file through an html form 
(the way it is below). Can anyone help?

my $file = param('uploadfile');

open(UPLOAD, ../employees/schedule.html) || Error();
my ($data,$length,$chunk);
while ($chunk = read ($file, $data, 1024)){
 print UPLOAD $data;
}
close(UPLOAD);


Thanks,
Mariusz