[18149] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 317 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 19 18:10:32 2001

Date: Mon, 19 Feb 2001 15:10:13 -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: <982624212-v10-i317@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 19 Feb 2001     Volume: 10 Number: 317

Today's topics:
        removing carriage return from a string <Waarddebon@chello.nl>
    Re: removing carriage return from a string <nospam@onasc@home.com>
    Re: removing carriage return from a string <sung@sung.yi.org>
    Re: removing carriage return from a string <ren@tivoli.com>
    Re: removing carriage return from a string <godzilla@stomp.stomp.tokyo>
    Re: simple question <kstep@pepsdesign.com>
    Re: Specifying the length of regular expression (Greg Bacon)
        term::readline gnu/stub current_history (News axion\)
    Re: term::readline gnu/stub current_history <joe+usenet@sunstarsys.com>
        This sending of mail works flawlesly... but... <ja@nee.snee>
    Re: This sending of mail works flawlesly... but... <Qeacostl@ilstu.edu>
    Re: three-part form submission using CGI.pm <bmb@ginger.libs.uga.edu>
        use of => <hpz@hpz.ath.cx>
    Re: use of => <joachim.rose@psi.ch>
    Re: use of => <bart.lateur@skynet.be>
    Re: use strict and require <todd@mrnoitall.com>
    Re: use strict and require <beable@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 19 Feb 2001 20:07:20 GMT
From: "Waarddebon" <Waarddebon@chello.nl>
Subject: removing carriage return from a string
Message-Id: <Y1fk6.1516610$%C1.19307888@Flipper>

How can I remove a carriage return from the end of a string ?




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

Date: Mon, 19 Feb 2001 20:21:12 GMT
From: "Brett Foster" <nospam@onasc@home.com>
Subject: Re: removing carriage return from a string
Message-Id: <Yefk6.40625$HG.9527200@news4.rdc1.on.home.com>

chomp($string) #Simply removes the last character if it is \n (or more
correctly $/)

and if you are reading from a file handle, do it all in one shot.
chomp (my $string = <STDIN>);#Define the variable $string in the current
scope, reads from the file handle and then chops of the last character if it
is \n.

Regards,
Brett Foster

"Waarddebon" <Waarddebon@chello.nl> wrote in message
news:Y1fk6.1516610$%C1.19307888@Flipper...
> How can I remove a carriage return from the end of a string ?
>
>




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

Date: Mon, 19 Feb 2001 20:46:55 GMT
From: fung <sung@sung.yi.org>
Subject: Re: removing carriage return from a string
Message-Id: <1i139t0db9a1rvkms6l9e8s15oj2pe889r@4ax.com>

chomp.
chomp($line);

for more info, perldoc -f chomp .

On Mon, 19 Feb 2001 20:07:20 GMT, "Waarddebon" <Waarddebon@chello.nl>
wrote:

>How can I remove a carriage return from the end of a string ?
>



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

Date: 19 Feb 2001 14:09:16 -0600
From: Ren Maddox <ren@tivoli.com>
Subject: Re: removing carriage return from a string
Message-Id: <m3ae7ibfkj.fsf@dhcp11-177.support.tivoli.com>

"Waarddebon" <Waarddebon@chello.nl> writes:

> How can I remove a carriage return from the end of a string ?

chomp $string;

See "perldoc -f chomp" or search for chomp in perlfunc(1).

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 19 Feb 2001 13:30:56 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: removing carriage return from a string
Message-Id: <3A919090.DF375690@stomp.stomp.tokyo>

Waarddebon wrote:
 
> How can I remove a carriage return from the end of a string ?

My presumption is you are referring to a standard
carriage return character " \r " rather than a 
newline character " \n " as is commonplace.

$string =~ tr/\r//d;

Use a " s " switch if you need single line treatment of input,

$string =~ tr/\r//sd;

These will remove only your carriage return characters
and leave your newline characters intact. Do not use
" chomp " if you wish to retain newline characters.

Godzilla!


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

Date: Mon, 19 Feb 2001 12:16:14 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: simple question
Message-Id: <96rkci$9k4$1@slb1.atl.mindspring.net>

"Waarddebon" <Waarddebon@chello.nl> wrote in message
news:wqak6.1514120$%C1.19200309@Flipper...
> How come this doesn't work out ?
>
> In my html file I have:
> <form action="http://oostwijk.hypermart.net/cgi-bin/rangeit.pl?mm&eu"
> method="post">
>
> These 2 parameters I want to read out with:
> $ARGV[0] =~ s/\W//g;
> $ARGV[1] =~ s/\D//g;
> But only the $ARGV[0] parameter contains a value namely mm.
> Why doesn't the $ARGV[1] get the second parameter eu ???

The code works perfectly.  The second substitution removes all non-digit
characters (\D) from $ARGV[1].  Since 'eu' contains no digits, it replaced
with an empty string.

Kurt Stephens





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

Date: Mon, 19 Feb 2001 17:53:03 -0000
From: gbacon@HiWAAY.net (Greg Bacon)
Subject: Re: Specifying the length of regular expression
Message-Id: <t92nbv22nllh2e@corp.supernews.com>

In article <3A9107AA.4294F72F@ot.com.au>,
    Ian Boreham  <ianb@ot.com.au> wrote:

: Greg Bacon wrote:
: 
: > : Yes you do; the original spec was length greater than ten.
: 
: Sigh. You didn't try it, did you? The lookahead expression is not anchored
: at the end, so it is sufficient for the lookahead to check that it matches
: the minimum number. The body of the expression will actually match the full
: string.

Umm...

      DB<1> $str = 'AAAABBCCCC'
    
      DB<2> x length $str
    0  10
      DB<3> print "Match!" if $str =~ /^(?=[ABC]{10,})A+B*C+$/
    Match!

: > ...and the 10 should be 11. :-)
: 
: Yes, you are right. I obviously didn't read the post carefully enough.

Please make up your mind! :-)

: > : When matching strings from non-regular languages, I find that
: > : verifying the match with additional checks, e.g.,
: > :
: > :     if (/^(A+B*C+)$/ && length($1) > 10) { ... }
: > :
: > : as Dominus wrote, makes for much clearer code than doing it all in the
: > : regular expression.
: 
: And I agree(d). However, you don't always have a choice, so it is nice to
: know how to do fancy things such as specifying the length, inverting
: matches, matching numerical ranges etc within a single regex.

When doesn't one have a choice?

I agree with you that these are all interesting questions from an
academic standpoint, but clarity is king in real code.  Please don't
construct the "you want everyone to dumb down their code" straw man
because it's not my point at all.  To me, explicit tests are much
clearer than limits that are implicit in the construction of a regular
expression.

Greg


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

Date: Mon, 19 Feb 2001 19:29:32 -0000
From: "Mark Hamlin \(News axion\)" <mark.hamlin@artdigital.co.uk>
Subject: term::readline gnu/stub current_history
Message-Id: <96rsgr$jj8$1@pheidippides.axion.bt.co.uk>

I'm using the above on a Solaris box.  I specify use Term::ReadLine, when I
call a history management command (other than addhistory) I get the
following

Can't locate object method "current_history" via package
"Term::ReadLine::Stub"

What do I need to do.

Mark




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

Date: 19 Feb 2001 15:05:05 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: term::readline gnu/stub current_history
Message-Id: <m37l2me8we.fsf@mumonkan.sunstarsys.com>

"Mark Hamlin \(News axion\)" <mark.hamlin@artdigital.co.uk> writes:

> I'm using the above on a Solaris box.  I specify use Term::ReadLine, 
> when I call a history management command (other than addhistory) I 
> get the following
> 
> Can't locate object method "current_history" via package
> "Term::ReadLine::Stub"
> 
> What do I need to do.

You need to post the offending code so people can reproduce 
the problem.

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: Mon, 19 Feb 2001 19:37:36 -0800
From: "Me" <ja@nee.snee>
Subject: This sending of mail works flawlesly... but...
Message-Id: <gyhZzHqmAHA.386@asd24-aux-005.raketnet.nl>

   use NET::SMTP;
   $smtp = Net::SMTP->new('serverip');
   $smtp->mail($ENV{'USER'});
   $smtp->to("$mail");
   $smtp->cc("$cc\@mydom.com");
   $smtp->data();

etc etc....

The cc doesn't work.
Why?

Thanks,

Me




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

Date: Mon, 19 Feb 2001 14:28:38 -0600
From: Erik <Qeacostl@ilstu.edu>
Subject: Re: This sending of mail works flawlesly... but...
Message-Id: <96rvl1$pq1$1@news.ilstu.edu>

Me:

When communicating with a server you always need to send \n at the 
end of a command or they will run together.

$smtp->mail($ENV{'USER'});
$smtp->to($mail);
$smtp->datasend("To $mail\n");
$smtp->cc("$cc\@mydom.com");
$smtp->data();

Should work

>    $smtp->mail($ENV{'USER'});
>    $smtp->to("$mail");
>    $smtp->cc("$cc\@mydom.com");
>    $smtp->data();
> 
> etc etc....
> 
> The cc doesn't work.
> Why?
> 
> Thanks,
> 
> Me
> 
> 

-- 
To reply by e-mail, remove the Q from my e-mail address.


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

Date: Mon, 19 Feb 2001 16:43:18 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: three-part form submission using CGI.pm
Message-Id: <Pine.A41.4.21.0102191635590.16492-100000@ginger.libs.uga.edu>

On 19 Feb 2001, Scott R. Godin wrote:

> In article 
> <Pine.A41.4.21.0102190944480.16492-100000@ginger.libs.uga.edu>, Brad 
> Baxter <bmb@ginger.libs.uga.edu> wrote:
> 
>  | >  | $fixee =~ s/(?:[\r\n]{2})+/<br><br>/g;
>  | > 
>  | > I haven't started experimenting with these forms yet -- does this work 
>  | > under 5.004? And, am I assuming correctly, that this would obviate the 
>  | > need for the final conversion, which you snipped from your response?
>  | 
>  | Um, yes ... I think.  You'll have to try it.  But then, as a 
>  | previous note pointed out, this may not be the real issue.
> 
> ok, I'll try it on some short stuff. 
> 
> as it turns out, this *was* in fact the issue, and not requiring the 
> other things that the respondent to which you refer was talking about. 
> It's the double-whammy of using a three-step single CGI script. My 
> biggest problem was not completely understanding what was happening to 
> the resultant output, which I now do (a return in the textarea field was 
> being converted into two somewhere during processing by CGI.pm, but via 
> &#13;&#10; which when converted BACK just prior to output, somehow 
> mysteriously becomes two \n's or two \r's ), and had coded those regexes 
> to catch. If your suggestions are more efficient (and can work for me 
> under 5.004), I believe I owe you some thanks. :)

Whether or not they are more efficient may be needlessly splitting
hairs.  But I would point out that my suggestions do not do exactly what
your original code does. Mine substitutes \r\r, \n\n, \r\n, or \n\r willy
nilly.  Presumably your data will be consistent with itself one way or
another.

Brad



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

Date: Mon, 19 Feb 2001 17:07:09 GMT
From: "Hpz" <hpz@hpz.ath.cx>
Subject: use of =>
Message-Id: <1pck6.8430$Vy2.818152@typhoon.mn.mediaone.net>

I am still learning perl and my books never game me a good explaination of
what "=>" does. my understanding is that it has the same effect as a comma,
but makes it easyer to look at what is going where. am i right?




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

Date: Mon, 19 Feb 2001 18:14:06 +0100
From: Joachim Rose <joachim.rose@psi.ch>
Subject: Re: use of =>
Message-Id: <3A91545E.F62B3583@psi.ch>

Yes, it has the same effect as a comma between key => value pairs in hashed
arrays.

Cheers,
Achim

Hpz wrote:
> 
> I am still learning perl and my books never game me a good explaination of
> what "=>" does. my understanding is that it has the same effect as a comma,
> but makes it easyer to look at what is going where. am i right?


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

Date: Mon, 19 Feb 2001 17:34:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: use of =>
Message-Id: <44m29t42e2g294jmm52n34a327cdms8b7l@4ax.com>

Hpz wrote:

>I am still learning perl and my books never game me a good explaination of
>what "=>" does. my understanding is that it has the same effect as a comma,
>but makes it easyer to look at what is going where. am i right?

Close enough. It also has the effect that if the thing on the left side
of it is a bareword, it automatically gets quoted (= used as literal
string). A bareword is the same pattern as what you'd normally use for
variable and sub names: starting with a letter or underscore, and
continuing with zero or more of letter, digit or underscore.

In the docs, open perlop and look for "comma operator". The last
paragraph describes "=>".

-- 
	Bart.


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

Date: Mon, 19 Feb 2001 11:11:57 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: use strict and require
Message-Id: <3A915241.682AA2D9@mrnoitall.com>



Beable van Polasm wrote:

> 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

 Why do that?
So that you don't have to do this with every global variable you've
created...

@EXPORT_OK = ($sendmail);

use Module::Name qw($sendmail);





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

Date: Mon, 19 Feb 2001 20:33:28 GMT
From: Beable van Polasm <beable@my-deja.com>
Subject: Re: use strict and require
Message-Id: <m3zofimnel.fsf@beable.van.polasm.bigpond.net.au>

Todd Anderson <todd@mrnoitall.com> writes:
>  Why do that?
> So that you don't have to do this with every global variable you've
> created...
> 
> @EXPORT_OK = ($sendmail);
> 
> use Module::Name qw($sendmail);

If you don't want to explicitly state what you want to import from
the module, you can use @EXPORT instead of @EXPORT_OK. Then it would
look like this:

@EXPORT = ($sendmail);
 ...
use Module::Name;

However, from perldoc perlmodlib:

       Select what to export.
           [...]
           Do NOT export anything else by default without a good
           reason!
           [...]
           Exports pollute the namespace of the module user.  If
           you must export try to use @EXPORT_OK in preference to
           @EXPORT and avoid short or common names to reduce the
           risk of name clashes.
           [...]
           As a general rule, if the module is trying to be
           object oriented then export nothing. If it's just a
           collection of functions then @EXPORT_OK anything but
           use @EXPORT with caution.

cheers
Beable van Polasm
-- 
         Come on Ref! Take the kendo sticks away! The guy's unconscious!
                    -- WCW Nitro Commentator
                        IQC 78189333
          http://members.nbci.com/_______/index.html


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

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


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