[18143] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 311 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 18 14:11:00 2001

Date: Sun, 18 Feb 2001 11:10:12 -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: <982523412-v10-i311@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 18 Feb 2001     Volume: 10 Number: 311

Today's topics:
        Regular Expression. (tim leung)
    Re: Regular Expression. <iltzu@sci.invalid>
    Re: Regular Expression <joe+usenet@sunstarsys.com>
        sending html along with mail <ja@nee.snee>
    Re: sending html along with mail (Afkamm)
    Re: sending html along with mail <dave@dave.org.uk>
        Stat and dir test help needed <afshin.akbari@sympatico.ca>
    Re: Stat and dir test help needed (Steven Smolinski)
    Re: translating crlf in a string <bwalton@rochester.rr.com>
    Re: translating crlf in a string <no@email.com>
    Re: translating crlf in a string (Garry Williams)
    Re: use Net::FTP; fails <dplu.mail@ifrance.com>
    Re: use strict and require <beable@my-deja.com>
    Re: When is an array @f allowed in a string? <bertilow@chello.se>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 18 Feb 2001 07:26:54 GMT
From: m_010@yahoo.com (tim leung)
Subject: Regular Expression.
Message-Id: <3a8f7930.14048500@enews.newsguy.com>

Hi,
Could any one give me some hint on how to write a regular expression
that checks a field in a HTML Form.

1) The field contains a string of one or more version numbers
2) If the field has more than 1 version number, then needs a comma and
space to separate the version.
3) Version number must be separate by 3 dots  (e.g. 1.1.1.1 )

Examples:
3.12.0.256 (ok)
1.0.0.0, 3.12.1.256, 2.2.2.2   (ok)
1.0.22     (not ok)
1.0.0.0, 3.12.1.256  (ok)

how can I must sure the version string is in the form of :
version# ( \,\s version# )*  

which means a vesrion# followed by 0 or more (, vesrion#)

thanks



------------------------------

Date: 18 Feb 2001 16:53:46 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Regular Expression.
Message-Id: <982514378.24661@itz.pp.sci.fi>

In article <3a8f7930.14048500@enews.newsguy.com>, tim leung wrote:
>Could any one give me some hint on how to write a regular expression
>that checks a field in a HTML Form.
>
>1) The field contains a string of one or more version numbers
>2) If the field has more than 1 version number, then needs a comma and
>space to separate the version.
>3) Version number must be separate by 3 dots  (e.g. 1.1.1.1 )
>
>how can I must sure the version string is in the form of :
>version# ( \,\s version# )*  

Yep, you're right.  I'm not sure what's keeping you from making the
final step to a working regexp, but here it is:

  /^\d+\.\d+\.\d+\.\d+(, \d+\.\d+\.\d+\.\d+)*$/

Hmm.. pretty repetitive.  It could be made shorter:

  /^\d+(\.\d+){3}(, \d+(\.\d+){3})*$/

If I were you, however, I wouldn't trust the users to type exactly one
space after and none before the comma:

  /^\d+(\.\d+){3}(\s*,\s*\d+(\.\d+){3})*$/

Replace the second \s* with \s+ if you want at least one space.  I'd
also probably allow leading and trailing whitespace:

  /^\s*\d+(\.\d+){3}\s*(,\s*\d+(\.\d+){3}\s*)*$/

Hmm.. I have to admit an intermediate variable would make that more
readable:

  my $version = qr/\s*\d+\.\d+\.\d+\.\d+\s*/;
  my $field   = qr/^$version(,$version)*$/;

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"Still, the sex industry is no stranger than the laws people come up with
 to restrict it."             -- John Kensmark in rec.arts.sf.composition

Please ignore Godzilla and its pseudonyms - do not feed the troll.


------------------------------

Date: 18 Feb 2001 03:38:03 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Regular Expression
Message-Id: <m3k86ofkt0.fsf@mumonkan.sunstarsys.com>

m_010@yahoo.com (tim leung) writes:

> 1) The field contains a string of one or more version numbers
> 2) If the field has more than 1 version number, then needs a comma and
> space to separate the version.
> 3) Version number must be separate by 3 dots  (e.g. 1.1.1.1 )
> 
> Examples:
> 3.12.0.256 (ok)
> 1.0.0.0, 3.12.1.256, 2.2.2.2   (ok)
> 1.0.22     (not ok)
> 1.0.0.0, 3.12.1.256  (ok)
> 
> how can I must sure the version string is in the form of :
> version# ( \,\s version# )*  
> 
> which means a vesrion# followed by 0 or more (, vesrion#)


TMTOWTDI, but it seems more natural for me to split the entries 
by commas and then test each version number separately. This will 
need some tweaking to deal with cases like "1.2.3." and ".2.3.9," 
but it handles the ones you've listed alright.


    my @data = split /,\s+/;              # split $_ by comma+space
    my @ok = grep /(?:[.]\d+){3}/, @data; # only keep valid entries


The good entries will lie in @ok; and these two lines can be
combined into one:

    my @ok = grep /(?:[.]\d+){3}/, split /,\s+/;

HTH

Joe Schaefer
-- 
%ENV=(); $A="\rr jpeurls ht\ba \rcankotehe"x666;END{ system
"$^X -wT $0 $^S";print"r\n"}sub foo{$_=pop||exit;/$_/;print
eval 'BEGIN{$^H='. ($^H+=666) .'}$_[-(()=$A=~//g)+$[]';}@_=
reverse$A=~/./g;&foo while$ARGV[0]=~//g;#evil mess for *nix


------------------------------

Date: Sun, 18 Feb 2001 12:00:29 -0800
From: "Me" <ja@nee.snee>
Subject: sending html along with mail
Message-Id: <wEctujZmAHA.364@asd24-aux-005.raketnet.nl>

Hi Group,

And how does one send mail...was a question I got my answers on over a year
ago.
But now... How does one send a page with it.
I would like to send WORKING links, so need to be able to send HTML with the
text.
Anyone? OR AnyFaq?
I am on 5.004 on NT/Apache if this matters.

Thanks,

Me




------------------------------

Date: Sun, 18 Feb 2001 13:54:36 GMT
From: afkamm@bigfoot.com (Afkamm)
Subject: Re: sending html along with mail
Message-Id: <Xns904C8D5CADAE9afkfoot@193.38.113.6>

On the 18 Feb 2001 in comp.lang.perl.misc, Me wrote the following in
a hurry. 

>Hi Group,
>
>And how does one send mail...was a question I got my answers on over
>a year ago.
>But now... How does one send a page with it.
>I would like to send WORKING links, so need to be able to send HTML
>with the text.
>Anyone? OR AnyFaq?
>I am on 5.004 on NT/Apache if this matters.
>

Hmm, don't quote me or anything, but i think you're looking for 
something similar to what is below. Notice the text/html in the fifth 
line.

open MAIL, "| $mailprog -t";
print MAIL "To: $fields{'email'}($fields{'name'})\n";
print MAIL "From: $adminmail ($adminname)\n";
print MAIL "Subject: $subjectline\n";
print MAIL "Content-Type: text/html; charset=iso-8859-1\n";
print MAIL "<x-html><body>Dear $fields{'name'},\n\n";

You can play with that until someone comes alone with a more 100% 
correct answer <g>

Marc :-)



------------------------------

Date: Sun, 18 Feb 2001 16:10:45 +0000
From: Dave Cross <dave@dave.org.uk>
Subject: Re: sending html along with mail
Message-Id: <20tv8tkk27kpab5k1udrk2hr1v0sp9ldpb@4ax.com>

On Sun, 18 Feb 2001 12:00:29 -0800, "Me" <ja@nee.snee> wrote:

>Hi Group,
>
>And how does one send mail...was a question I got my answers on over a year
>ago.
>But now... How does one send a page with it.
>I would like to send WORKING links, so need to be able to send HTML with the
>text.
>Anyone? OR AnyFaq?
>I am on 5.004 on NT/Apache if this matters.

You send mail using modules from the Mail-Tools bundle that you can
get from CPAN <http://seach.cpan.org>.

You don't necessarily have to send HTML in order to send links. Most
mail clients these days will recognise HTTP links in mail text and
will activate them in some way. If you _really_ want to send HTML
mail, then _please_ create a valid MIME message using MIME::Lite of
the MIME-Tools modules. Don't just rely on the broken behavior of
certain popular mail clients which will interpret any HTML in a mail.

Cheers,

Dave...

-- 
<http://www.dave.org.uk>  SMS: sms@dave.org.uk


------------------------------

Date: Sun, 18 Feb 2001 16:02:16 GMT
From: afshin akbari <afshin.akbari@sympatico.ca>
Subject: Stat and dir test help needed
Message-Id: <3A901DF6.4A1FAE55@sympatico.ca>

All,

I have souple of questions about dir tests and wornder if someone could
help me with the following questions.

1) can you use "stat" function on DIRECTORIES as well as FILES ??
=A0=A0=A0 If the anser is YES, do you have to have the dir. open before "=
stat"

=A0=A0=A0 can return anything ????

2) I tried to test on a dir (-w $directoryName) it seems that I have
=A0=A0=A0 to have the dir open before I could get the correct result ????=

=A0=A0=A0 Has anyone seen this ?
=A0

Thanks for your time,

aa-



------------------------------

Date: Sun, 18 Feb 2001 16:54:05 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: Stat and dir test help needed
Message-Id: <slrn990408.tt.sjs@ragnar.stevens.gulch>

afshin akbari <afshin.akbari@sympatico.ca> wrote:
> 1) can you use "stat" function on DIRECTORIES as well as FILES ??

Yes.

> If the anser is YES, do you have to have the dir. open before "
> stat" can return anything ????

No.

> 2) I tried to test on a dir (-w $directoryName) it seems that I have
> =A0=A0=A0 to have the dir open before I could get the correct result ????=

No.

$ mkdir temp
$ perl -e 'print -w q[temp], qq[\n]'
1
$ perl -e 'print stat q[temp], qq[\n]'
780118716877250010003598251962398251962398251962340960
$

It sounds like your problems are different than you think.  But no one
can help you unless you post the problematic code (preferably in ascii,
this time).

Steve
-- 
Steven Smolinski => http://www.steven.cx/


------------------------------

Date: Sun, 18 Feb 2001 16:05:09 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: translating crlf in a string
Message-Id: <3A8FF3B9.57C63DB3@rochester.rr.com>

Frank Miller wrote:
 ...
> Is there a way in Perl to print the ascii value of each character in a
> string? That way I can scan it to see exactly what Perl has stored.

You can use the ord function to determine the numeric collating sequence
value of the first character of a string.  So maybe something like:

     printf '%02x.',ord for (split //,$string);
     print "\n";

would work.

> 
> FrankM
-- 
Bob Walton


------------------------------

Date: Sun, 18 Feb 2001 17:46:40 GMT
From: "Frank Miller" <no@email.com>
Subject: Re: translating crlf in a string
Message-Id: <4UTj6.440337$U46.12979845@news1.sttls1.wa.home.com>

"Bob Walton" <bwalton@rochester.rr.com> wrote in message
news:3A8FF3B9.57C63DB3@rochester.rr.com...
> Frank Miller wrote:
> ...
> > Is there a way in Perl to print the ascii value of each character in a
> > string? That way I can scan it to see exactly what Perl has stored.
>
> You can use the ord function to determine the numeric collating sequence
> value of the first character of a string.  So maybe something like:
>
>      printf '%02x.',ord for (split file://,$string);
>      print "\n";
>


Thanks for all the help.  I found the problem.  typo.  agh!  $note should
have been $notes.  I would have assumed that perl -w would have caught the
undefined ref, but maybe =~ works differently.

FrankM





------------------------------

Date: Sun, 18 Feb 2001 19:03:55 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: translating crlf in a string
Message-Id: <v0Vj6.140$gw.9109@eagle.america.net>

On Sun, 18 Feb 2001 17:46:40 GMT, Frank Miller <no@email.com> wrote:
>
>Thanks for all the help.  I found the problem.  typo.  agh!  $note should
>have been $notes.  I would have assumed that perl -w would have caught the
>undefined ref, but maybe =~ works differently.

No.  It doesn't: 

  $ perl -we '$x=~/\r/'
  Name "main::x" used only once: possible typo at -e line 1.
  Use of uninitialized value in pattern match (m//) at -e line 1.
  $ 

Also, use strict: 

  $ perl -Mstrict -we '$x=~/\r/'
  Global symbol "$x" requires explicit package name at -e line 1.
  Execution of -e aborted due to compilation errors.
  $ perl -Mstrict -we 'my $x=~/\r/'
  Use of uninitialized value in pattern match (m//) at -e line 1.
  $

These two things can save a lot of time by having perl do all the work
of finding your typos and lots of other mistakes.  They can even save
postings on Usenet.  :-)  

-- 
Garry Williams


------------------------------

Date: Sun, 18 Feb 2001 14:44:14 +0100
From: "dplu.mail" <dplu.mail@ifrance.com>
Subject: Re: use Net::FTP; fails
Message-Id: <96ojji$m94$1@wanadoo.fr>

Hi

Why don't use the Win32::Internet and all the function of http and ftp
included ?

for myself it works perfectly like

use Win32::Internet;
our $ITZ = new Win32::Internet();

    # parametres pour multimania
    $host = "ftp.multimania.com";
    $user = "my user";
    $pass = "my password";

    # cree et ouvre la connection ftp
    $ITZ->FTP($FTPTZ, $host, $user, $pass);
    if(!$FTPTZ) {
        ($num, $text) = $ITZ->Error();
        print "<BR>*** Erreur TZLINK : [$num] $text </BR>\n";
    } else {
        $FTPTZ->Binary();
        &crepagetzlink ($_[0] ) ;
        $result = $FTPTZ->Put("indextz.htm","index.htm");
        $err = $FTPTZ->Error();
        print "  Resultat sur le serveur de '$host' :<B> $err </B></BR>\n"
if ! $result;
        affiche_message ( "La page à bien etee transfere sur le serveur
$host ", "00FF00" ) if  $result;
        $FTPTZ->Close();
    }
    $ITZ->Close();
} ;

with something like that it work everytime

hope this will help you

regards

"David Akers" <David@TheAkers.com> a écrit dans le message news:
3a8f6e51@news.dsldesigns.com...
> I have a perl script that does some HTML parsing then posts the page to a
> web server using FTP.
>
> On my development machine (using activestate perl) it works fine
>
> On my production server the use statement fails.  I built both machines
and
> perl installs, and they are
> identical.  (Windows '98, Apache, Activestate Perl) -- Yes, I know windows
> '98 and production are
> mutually exclusive...
>
> I imagine I have a problem with the perl install or the .om module in
> question.
>
> I am not sure if I need to look for Net.pm (thinking the ::FTP is a parm)
or
> if I am looking for FTP.pm
>
> The following script will fail
> #!c:/perl/bin/perl.exe
> use Net::FTP;
>
> Any thoughts will be most helpful.
>
> David
>
>
>
>




------------------------------

Date: Sun, 18 Feb 2001 12:07:27 GMT
From: Beable van Polasm <beable@my-deja.com>
Subject: Re: use strict and require
Message-Id: <m366i8qk1i.fsf@beable.van.polasm.bigpond.net.au>

Todd Anderson <todd@mrnoitall.com> writes:
> Beable van Polasm wrote:
> > So for example, in your module you could put:
> >     ...
> >     @EXPORT_OK = ($sendmail);
> >     ...
> > And in your program you can put:
> >
> > ...
> > use Module::Name qw($sendmail);
> > ...
> >
> 
> Question for Beable van Polasm...
> Could I do tbis:
> 
>   @EXPORT_OK = (
> $sendmail="usr/lib/sendmail";
> $var2="definition2";
> $var3="definition3";
> $var4="definition4";
> );

I looked at that, and I thought "Huh? That won't work!". So I tried
it out, and I couldn't get it to work:

"$sendmail" is not exported by the Module::Variables module at
 ./test_module line 5
Can't continue after import errors at ./test_module line 5
BEGIN failed--compilation aborted at ./test_module line 5.

Do you know how to make it work? Why would you want to do that anyway?

cheers
Beable van Polasm
-- 
Tabs are 8 characters. They are NOT adjustable. Never have been, never
will be. Anybody who thinks tabs are anything but 8 chars apart is just
wrong. It's that simple. -- Linus Torvalds
IQC 78189333                  http://members.nbci.com/_______/index.html


------------------------------

Date: Sun, 18 Feb 2001 18:23:51 GMT
From: "Bertilo Wennergren" <bertilow@chello.se>
Subject: Re: When is an array @f allowed in a string?
Message-Id: <XqUj6.996$MU.10868@nntp1.chello.se>

Tad McClellan:

> >Thanks also to those who suggested "use diagnostics" and "use strict";
> >I should probably get into that habit.
>    ^^^^^^

> No "should" about it.

> You *must* get into the habit of "use strict".

That sounds a bit un-Perlish to me. "use strict" is really good, but
"must"?

This is from the first chapter of a very famous book. I read it just 
yesterday:

  You certainly _may_ call the 'exit' function explicitly if you wish,
  just as you _may_ declare some of your variables, or even _force_
  yourself to declare all your variables. But it's your choice. With
  Perl you're free to do The Right Thing, however you care to define it.

Is this not true any more?

> I have seen people lose jobs for lack of it...

With such a company policy Perl seems not to be the appropriate tool 
to use. Or am I wrong?

-- 
#####################################################################
                         Bertilo Wennergren
                 <http://purl.oclc.org/net/bertilo>
                        <bertilow@chello.se>
#####################################################################



------------------------------

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 311
**************************************


home help back first fref pref prev next nref lref last post