On 4/5/12 Thu Apr 5, 2012 1:34 PM, "Somu" scribbled:
> Hello everyone,
>
> #this code works for any valid input
> #
> use strict;
> use warnings;
>
> print "\n\n\tEnter directory : ";
> my $path = <>;
> chomp($path); #but if this line is eliminated, it
> shows d driv
I'm usually the last person to say this (in fact I think it is the first time I've
ever ever felt the need to say this) but "RTFM".
If you can't find this on your own you are either too lazy to warrant help, or too
dumb to absorb the help that is given.
You Wrote:
--
What is chomp ?
On Tue, 26 Jun 2001, Stéphane JEAN BAPTISTE wrote:
> What is chomp ?
It removes a trailing newline from a string:
chomp($line = );
This retrieves a line form an open filehandle and removes the trailing
newline (\n) from the end. Actually, it chomps off whatever $/ is set to,
but it is usually
At 16:34 26.06.2001 +0200, Stéphane JEAN BAPTISTE wrote:
>What is chomp ?
>
>tks
It chops off the new line/return character when reading in a file. It's
kind of magical, in that in changes the character it looks for depending on
the system its run on.
Aaron Craig
Programming
iSoftitler.com
Hello Stéphane,
Tuesday, June 26, 2001, Stéphane JEAN BAPTISTE
<[EMAIL PROTECTED]> wrote:
SJB> What is chomp ?
see output of
perldoc -f chomp
Best wishes,
Maximmailto:[EMAIL PROTECTED]
OUCH!
some people just need a gentle slap to get them going.. kind of like a
newborn ;) slap them on the arse to get them breathing.
This was overkill ;) more like a boot to the skull!
take it easy bubba :)
> I'm usually the last person to say this (in fact I think it is
> the first time I've
\n is not the same as newline. Newline is (in ascii) character 0x0A.
\n is the end of line sequence for the target OS (LF on UNIX, CRLF on
Win32, CR on Mac, "END_OF_LINE" on some mythical OS, etc.). This has
bitten me in the past when I wrote code on a Linux box (\n = LF) and
gave it someone on
--- "Ronald J. Yacketta" <[EMAIL PROTECTED]> wrote:
> OUCH!
>
> some people just need a gentle slap to get them going.. kind of like
> a newborn ;) slap them on the arse to get them breathing.
>
> This was overkill ;) more like a boot to the skull!
> take it easy bubba :)
And after all the goo
I think this is a very contradictory answer.. since if we were to RTFF
(last F for FAQ) we would know not to answer in this way. It is not
useful.
The person asking the question should look at section 2.7 of the FAQ.
The person giving this answer should look at 2.6.
Both should look at section 4.
At 11:03 26.06.2001 -0400, Kevin Meltzer wrote:
>I think this is a very contradictory answer.. since if we were to RTFF
>(last F for FAQ) we would know not to answer in this way. It is not
>useful.
Which FAQ? (seriously) :)
Aaron Craig
Programming
iSoftitler.com
http://learn.perl.org/beginners-faq
I just went there and read it for the first time too ;)
-Original Message-
From: Aaron Craig [mailto:[EMAIL PROTECTED]]
Sent: 26 June 2001 16:07
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: chomp ?
At 11:03 26.06.2001 -0400, Kevin
On Tue, Jun 26, 2001 at 05:07:22PM +0200, Aaron Craig ([EMAIL PROTECTED]) spew-ed
forth:
> At 11:03 26.06.2001 -0400, Kevin Meltzer wrote:
> >I think this is a very contradictory answer.. since if we were to RTFF
> >(last F for FAQ) we would know not to answer in this way. It is not
> >useful.
>
On Tue, 26 Jun 2001, Aaron Craig wrote:
> At 11:03 26.06.2001 -0400, Kevin Meltzer wrote:
> >I think this is a very contradictory answer.. since if we were to RTFF
> >(last F for FAQ) we would know not to answer in this way. It is not
> >useful.
>
> Which FAQ? (seriously) :)
The F-ing one!
The
04
To: Chris Hedemark
Cc: [EMAIL PROTECTED]
Subject: Re: chomp ?
I think this is a very contradictory answer.. since if we were to RTFF
(last F for FAQ) we would know not to answer in this way. It is not
useful.
The person asking the question should look at section 2.7 of the FAQ.
The person giving
Ok, this is not an RTFM post!
The easiest way to find out what a particular command does is with the
perldoc program.
On the system that has Perl installed, please type the following:
perldoc -f chomp
You will get the documentation for this function! Easy huh?!!!
Give that a read, then if y
would have given my more typical answer.
Chris Hedemark - Hillsborough, NC
http://yonderway.com
- Original Message -
From: "Ronald J. Yacketta" <[EMAIL PROTECTED]>
To: "Chris Hedemark" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, June 26, 20
No,
chomp removes any "\n" at the end of a string.
see perldoc -f chomp
Rod
-Original Message-
From: Purshottam Chandak [mailto:[EMAIL PROTECTED]]
Sent: 19 December 2001 08:05
To: [EMAIL PROTECTED]
Subject: chomp
If I type,
$date = 19990417;
chomp $date; -
will every variable c
On Sunday 29 August 2010 14:15:52 Kaushal Shriyan wrote:
> Hi
>
> Can someone please explain me with an example of the usage chomp ()
> builtin function in perl.
Yes, here you go. Let's suppose you want to write a small grep programs that
only prints all lines ending with the character "\". You
On Sun, Aug 29, 2010 at 07:15, Kaushal Shriyan wrote:
> Hi
>
> Can someone please explain me with an example of the usage chomp ()
> builtin function in perl.
snip
The chomp function removes whatever is in the $/ variable from the
argument passed in (or $_ if no argument is passed in). The defau
On Sun, Aug 29, 2010 at 6:11 PM, Chas. Owens wrote:
> On Sun, Aug 29, 2010 at 07:15, Kaushal Shriyan
> wrote:
>> Hi
>>
>> Can someone please explain me with an example of the usage chomp ()
>> builtin function in perl.
> snip
>
> The chomp function removes whatever is in the $/ variable from the
On Sun, Aug 29, 2010 at 09:23, Kaushal Shriyan wrote:
> On Sun, Aug 29, 2010 at 6:11 PM, Chas. Owens wrote:
>> On Sun, Aug 29, 2010 at 07:15, Kaushal Shriyan
>> wrote:
>>> Hi
>>>
>>> Can someone please explain me with an example of the usage chomp ()
>>> builtin function in perl.
>> snip
>>
>>
On Sun, Aug 29, 2010 at 7:06 PM, Chas. Owens wrote:
> On Sun, Aug 29, 2010 at 09:23, Kaushal Shriyan
> wrote:
>> On Sun, Aug 29, 2010 at 6:11 PM, Chas. Owens wrote:
>>> On Sun, Aug 29, 2010 at 07:15, Kaushal Shriyan
>>> wrote:
Hi
Can someone please explain me with an example of
On Sun, Aug 29, 2010 at 09:41, Kaushal Shriyan wrote:
snip
> Thanks a lot Chas. Understood now.
> Also what does $_ default variable means exactly, any example would
> really help me understand it
snip
The default variable is set or read by many Perl 5 functions. For
instance, if you use the rea
On Sun, Aug 29, 2010 at 7:58 PM, Chas. Owens wrote:
> On Sun, Aug 29, 2010 at 09:41, Kaushal Shriyan
> wrote:
> snip
>> Thanks a lot Chas. Understood now.
>> Also what does $_ default variable means exactly, any example would
>> really help me understand it
> snip
>
> The default variable is set
At 8:17 PM +0530 8/29/10, Kaushal Shriyan wrote:
I am referring to http://www.perl.org/books/beginning-perl/. so I am
planning to read upto chapter 10. is it recommended to even go beyond
chapter 10.
Please suggest.
I have not read that online resource, but looking at the contents I
would re
On 10-11-08 04:04 PM, Bobby wrote:
I'm having issues with printing out the content of a Database's HTML
text field; I wanted to chomp out the carriage returns of the
$html_content(see below) so that I could print it out all in one line
into a text file ($output). I've tried chomp() but it doesn't
You could try doing this with a regex:
$html_content =~ s/\n//g;
This would look for any new-line ("\n") and replace it with nothing. The g
at the end tells it to do this globally, so all instances of \n would be
removed.
On Mon, Nov 8, 2010 at 4:04 PM, Bobby wrote:
> Hi,
>
> I'm having issue
Awsome, regex worked! My head was stuck on chomp...Thanks Sheppy.
From: Sheppy R
To: Bobby
Cc: beginners@perl.org
Sent: Mon, November 8, 2010 2:32:13 PM
Subject: Re: Chomp help...
You could try doing this with a regex:
$html_content =~ s/\n//g;
This would
y
> Cc: beginners@perl.org
> Sent: Mon, November 8, 2010 2:32:13 PM
> Subject: Re: Chomp help...
>
> You could try doing this with a regex:
>
> $html_content =~ s/\n//g;
>
> This would look for any new-line ("\n") and replace it with nothing. The g
> at
> the e
Hello,
The chomp function will chomp off the last character
if its a new line.
Spaces wont be truncated by chomp.
Regards
Nishanth
> Hello
>
> I am wondering how the chomp function works. I am
> looking to see how
> I can truncate new line and/or carriage returns from
> a string. Will
> chom
On Wednesday 26 April 2006 22:51, AndrewMcHorney wrote:
> Hello
Hey Andrew
>
> I am wondering how the chomp function works. I am looking to see how
> I can truncate new line and/or carriage returns from a string. Will
> chomp do nothing if there are no carriage return or line feed at the
> end. If
AndrewMcHorney wrote:
> Hello
Hello,
> I am wondering how the chomp function works. I am looking to see how I
> can truncate new line and/or carriage returns from a string. Will chomp
> do nothing if there are no carriage return or line feed at the end. If
> the end of the string has a space will
On Wed, 2006-26-04 at 23:07 -0700, Jaime Murillo wrote:
> The good way to learn how a function works is to use the perldoc utility.
A good way to learn how a function works is to write a small program to
test it. There is nothing like hands-on experience.
--
__END__
Just my 0.0002 million
On Thu, Apr 27, 2006 at 07:25:15AM -0400, Mr. Shawn H. Corey wrote:
> On Wed, 2006-26-04 at 23:07 -0700, Jaime Murillo wrote:
> > The good way to learn how a function works is to use the perldoc utility.
>
> A good way to learn how a function works is to write a small program to
> test it. There i
to carry a cat by its tail learns something that
will always be useful and which will never grow dim or doubtful."
Mark Twain
-Original Message-
From: Chad Perrin [mailto:[EMAIL PROTECTED]
Sent: Thursday, April 27, 2006 7:55 AM
Great article! Thanks for the reference.
-r
> -Original Message-
> From: Chad Perrin [mailto:[EMAIL PROTECTED]
> >
> > A good way to learn how a function works is to write a small program to
> > test it. There is nothing like hands-on experience.
>
> . . . or "Apply the T.I.T.S. principl
> ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes:
"Mr> On Wed, 2006-26-04 at 23:07 -0700, Jaime Murillo wrote:
>> The good way to learn how a function works is to use the perldoc utility.
"Mr> A good way to learn how a function works is to write a small program to
"Mr> test it. There
> -Original Message-
> From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 27 April, 2006 10:18
> To: beginners@perl.org
> Subject: Re: Chomp method
>
>
> For example, almost no amount of experimentation will stumble across
> how chomp actual
> -Original Message-
> From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]
>
> For example, almost no amount of experimentation will stumble across
> how chomp actually removes $/, not just "\n".
But that's exactly why you need to try it and see. The more a document
spends on the arcane de
> "Russ" == Russ Foster <[EMAIL PROTECTED]> writes:
Russ> But that's exactly why you need to try it and see. The more a document
Russ> spends on the arcane details of a function (which perldoc does), the more
Russ> likely a beginner would get lost in those details and find some other
source
R
> -Original Message-
> From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]
>
> However, you didn't challenge my point. You merely made a different
> point.
> It is *not* sufficient to merely experiment. Reading the reference doc is
> mandatory for complete understanding.
That's because I
On 4/27/06, Russ Foster <[EMAIL PROTECTED]> wrote:
> Instead of the perldoc chomp example of:
It sounds as if you have ideas on how to improve the Perl
documentation. I heartily encourage you to contribute your
improvements by means of the perlbug program, which comes with Perl. A
patch to the .p
> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
>
> > Instead of the perldoc chomp example of:
>
> It sounds as if you have ideas on how to improve the Perl
> documentation. I heartily encourage you to contribute your
> improvements by means of the p
On Thu, 2006-27-04 at 08:18 -0700, Randal L. Schwartz wrote:
> > ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes:
> "Mr> A good way to learn how a function works is to write a small program to
> "Mr> test it. There is nothing like hands-on experience.
>
> Unless your experience doesn't
On Thu, Apr 27, 2006 at 08:23:52AM -0400, [EMAIL PROTECTED] wrote:
>
> Although the "try it and see" approach is fun and intellectually
> challenging, it really isn't productive for everyone. For example, I
> wouldn't like to be paying a contractor who is getting paid per hour to
> do a lot of "tr
> ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes:
"Mr> Everyone should compliment their reading with experimentation and their
"Mr> experimentation with reading.
Do you mean "complement", or do you mean that you should say kind words
about your reading? :)
--
Randal L. Schwartz - St
On Fri, 2006-28-04 at 07:33 -0700, Randal L. Schwartz wrote:
> > ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes:
>
> "Mr> Everyone should compliment their reading with experimentation and their
> "Mr> experimentation with reading.
>
> Do you mean "complement", or do you mean that you
On Fri, Apr 28, 2006 at 11:05:23AM -0400, Mr. Shawn H. Corey wrote:
> On Fri, 2006-28-04 at 07:33 -0700, Randal L. Schwartz wrote:
> > > ""Mr" == "Mr Shawn H Corey" <[EMAIL PROTECTED]> writes:
> >
> > "Mr> Everyone should compliment their reading with experimentation and their
> > "Mr> experim
Hello Jennifer,
Tuesday, August 21, 2001, Jennifer Pan <[EMAIL PROTECTED]> wrote:
JP> I have a file :
JP> #myfile.txt
JP> a b c d
JP> a c s g
JP> g o y g
JP> _END_
JP> I wrote a perl script to put each line into a list;
JP> #/usr/bin/perl -
On Fri, 14 Sep 2001, siren jones wrote:
> What is happening here?
>
> $date = `/bin/date + %y%m%d`;
> print "$date";
>
> prints
> >20010914
> >
>
> But if I add:
>
> $a = chomp($date);
> print "$a";
>
>
> it prints
> >
Because you aren't using chomp the way it's supposed to be used. Try
this:
On Sep 14, siren jones said:
>$date = `/bin/date + %y%m%d`;
There's really no need to be calling an external system command to get the
date. Perl has its own function, localtime(), and you can use the
POSIX::strftime() function to use date-like formatting instructions (the
%y and %m stuff).
>$
Hi Kaushal,
Yes you are right if you have a hardcoded line of text in your script you
know if there is a "\n" or not at the end.
Now imagine you are reading a bunch of data from a text file created from
user input or some unknown script... who knows how much weird things are
there at the end of t
I find chomp() usefull for processing a file, or other input (eg keyboard).
#!/usr/bin/perl
use strict;
use warnings;
while(<>) {
print "$_"; # $_ has a newline attached, either from file or STDIN
chmop;
doSomethingWithTheString($_);
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For addi
> Hi,
>
Hello,
> so where does the chomp operator plays its role, can some one
> explain me here with a sample of code.
>
> Thanks and Regards
>
> Kaushal
>
One place where chomp() comes in handy is when you're reading from a
file.
Usually a line read from a file will have a newline at the
On Thu, 17 Nov 2005 10:10:17 +0800, The Ghost <[EMAIL PROTECTED]> wrote:
I have some code that chomps a variable, but the variable still seems to
have a newline. But if I chop it I am rid of the newline. What's going
on with that string?
Perhaps that newline is Windows specific (like \
On Saturday, June 8, 2002, at 04:47 , David T-G wrote:
[..]
>
> The files were written in DOS format (\r\n or, I am more inclined to
> think, \n\r) and chomp doesn't work; instead I have to
>
> ...
> while (<>)
> {
> ...
> chop ; chop ; # strip \n\r (no c
Hi, all --
...and then David T-G said...
%
...
% I can't modify $fullpath because I'll use it later, but for parsing I
% don't need the leading "/mp3/" part, and the only way I've found to get
% rid of it elegantly is
%
% ...
% @working = split(/\//,$fullpath) ;# cut path
On Sat, 8 Jun 2002, David T-G wrote:
> % I can't modify $fullpath because I'll use it later, but for parsing I
> % don't need the leading "/mp3/" part, and the only way I've found to get
> % rid of it elegantly is
> %
> % ...
> % @working = split(/\//,$fullpath) ; # cut path in
On Sun, 9 Jun 2002, Elias Assmann wrote:
> be two lines, so how about this: @working = m'/mp3(/[^/]+)+';?
So much for posting code without trying it... This isn't working, but
it isn't obvious to me why, and I don't have time right now :-(
Elias
--
Gefängnis für Hans Mustermann wegen
Oh my, what a bad day for my poor little brain... Sorry for all that
confusion.
On Sun, 9 Jun 2002, David T-G wrote:
> Elias, et al --
>
> ...and then Elias Assmann said...
>
> % be two lines, so how about this: @working = m'/mp3(/[^/]+)+';?
It seems I have suffered a misconception about what
drieux, et al --
...and then drieux said...
%
% On Saturday, June 8, 2002, at 04:47 , David T-G wrote:
% [..]
% >
...
% >...
% >chop ; chop ;# strip \n\r (no chomp here)
...
%
% that is way too weird - since that means that what
% ever dos app you were using
On Saturday, June 8, 2002, at 08:13 , David T-G wrote:
> drieux, et al --
> ...and then drieux said...
> % On Saturday, June 8, 2002, at 04:47 , David T-G wrote:
[..]
> % >...
> % >chop ; chop ; # strip \n\r (no chomp here)
> ...
> %
> % that is way too weird - si
drieux, et al --
...and then drieux said...
%
% On Saturday, June 8, 2002, at 08:13 , David T-G wrote:
% >drieux, et al --
% >...and then drieux said...
% >% On Saturday, June 8, 2002, at 04:47 , David T-G wrote:
...
% >
% >Tell me about the standard... Should perl happily chomp either a UNIX o
Elias --
...and then Elias Assmann said...
%
% On Sun, 9 Jun 2002, Elias Assmann wrote:
%
% > be two lines, so how about this: @working = m'/mp3(/[^/]+)+';?
%
% So much for posting code without trying it... This isn't working, but
*grin*
% it isn't obvious to me why, and I don't have time r
Elias, et al --
...and then Elias Assmann said...
%
% On Sat, 8 Jun 2002, David T-G wrote:
%
% > % I can't modify $fullpath because I'll use it later, but for parsing I
% > % don't need the leading "/mp3/" part, and the only way I've found to get
...
% > While it may not be a perfect solution,
Elias, et al --
...and then Elias Assmann said...
%
% Oh my, what a bad day for my poor little brain... Sorry for all that
% confusion.
*grin* No problem; it made me check my answers :-)
%
% On Sun, 9 Jun 2002, David T-G wrote:
%
% > ...and then Elias Assmann said...
% >
% > % be two lines
Elias Assmann
Subject: Re: shifting solved (was "Re: chomp-ing DOS lines, shifting,
and a variable variable")
Elias, et al --
and then Elias Assmann said...
%
% Oh my, what a bad day for my poor little brain... Sorry for all that
% confusion.
*grin* No problem; it made me c
Timothy, et al --
...and then Timothy Johnson said...
%
% I can't test this where I am right now, but would something like this work?
%
% @working = split /\//,($fullpath =~ m|/mp3/(.+)|); #changed match delimiter
I'm surprised to find that it does, but I'm glad I tested it. I thought
that ma
Timothy, et al --
...and then David T-G said...
%
% ...and then Timothy Johnson said...
% %
% % I can't test this where I am right now, but would something like this work?
% %
% % @working = split /\//,($fullpath =~ m|/mp3/(.+)|); #changed match delimiter
%
% I'm surprised to find that it doe
Try this:
@working = split(/\//,($fullpath =~ m:/mp3/(.+):)[0]);
-Original Message-
From: David T-G [mailto:[EMAIL PROTECTED]]
Sent: Sunday, June 09, 2002 1:43 PM
To: perl beginners
Cc: Timothy Johnson
Subject: Re: shifting solved (was "Re: chomp-ing DOS lines, shifting,
and a variabl
Timothy, et al --
...and then Timothy Johnson said...
%
% Ok, I finally got a chance to test it, and the problem with my code is that
% split expects a scalar as the second argument. This does work:
%
% ($temp) = $fullpath =~ m:/mp3/(.+):;
% @working = split /\//,$temp;
%
% because it is
ject: Re: shifting solved (was "Re: chomp-ing DOS lines, shifting, and a
variable variable")
Timothy, et al --
and then Timothy Johnson said...
%
% Ok, I finally got a chance to test it, and the problem with my code is
that
% split expects a scalar as the second argument. T
Timothy, et al --
...and then Timothy Johnson said...
%
% David->"Hmmm... OK, so that explains it, but I still don't get it... So
% the match is going to spit out a scalar but in order to use it you have to
% capture it in a list context?"
%
% No, actually the opposite. The match returns a l
73 matches
Mail list logo