[25391] in Perl-Users-Digest
Perl-Users Digest, Issue: 7636 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 12 14:05:30 2005
Date: Wed, 12 Jan 2005 11:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 12 Jan 2005 Volume: 10 Number: 7636
Today's topics:
Re: [OT] ISO book on CGI design xhoster@gmail.com
Re: [OT] ISO book on CGI design <spamtrap@dot-app.org>
Adding a delimiter inbetween number characters and lett toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and <mritty@gmail.com>
Re: Adding a delimiter inbetween number characters and toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and <sbryce@scottbryce.com>
Re: Adding a delimiter inbetween number characters and <mritty@gmail.com>
Re: Adding a delimiter inbetween number characters and toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and <spamtrap@dot-app.org>
Re: Adding a delimiter inbetween number characters and <sbryce@scottbryce.com>
Re: Adding a delimiter inbetween number characters and <mritty@gmail.com>
Re: Adding a delimiter inbetween number characters and <sbryce@scottbryce.com>
Re: Adding a delimiter inbetween number characters and <spamtrap@dot-app.org>
Re: Adding a delimiter inbetween number characters and <nobull@mail.com>
Re: Adding a delimiter inbetween number characters and <jgibson@mail.arc.nasa.gov>
Re: Adding a delimiter inbetween number characters and toomanyjoes@mail.utexas.edu
Re: Adding a delimiter inbetween number characters and <spamtrap@dot-app.org>
Re: angle operator, backticks, and redirection <whitey@newmail.net>
Re: angle operator, backticks, and redirection <spamtrap@dot-app.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jan 2005 17:15:01 GMT
From: xhoster@gmail.com
Subject: Re: [OT] ISO book on CGI design
Message-Id: <20050112121501.067$4G@newsreader.com>
kj <socyl@987jk.com.invalid> wrote:
> In <etowtujr3n1.fsf@wilson.emschwar> Eric Schwartz <emschwar@fc.hp.com>
> writes:
>
> >kj <socyl@987jk.com.invalid> writes:
> >> For some reason that I can't quite figure out, my CGI projects are
> >> far less readable and maintainable than the rest of my coding
> >> projects. I've developed several awful, unmaintainable,
> >> for-internal-use-only CGI projects (using Perl, CGI.pm, and JavaScript
> >> exclusively) over the last 4 years now, and it's about time I
> >> learned to do it right.
>
> >The #1 rule of All Time, when doing web-based apps, is:
>
> >1) Use templates to generate your HTML!
>
> >I don't care if you use Template Toolkit, Mason, Amrita (a very nifty
> >templating system in Ruby), or what, but if you use a templating
> >solution, you will be happy, and babies will smile when you walk by,
> >women will want to be you, men will want to be with you (or
> >vice-versa). If not, then it will be chaos and insanity! Dogs and
> >cats living together! Madness, I tell you, MADNESS!!!
>
> Madness pretty much describes my code, and I agree that it has
> something to do with generating all the HTML dynamically with
> CGI.pm.
>
> So the consensus (of 2) seems to be "templates". I'll look into
> them.
Yes, that does seem to be the consensus. Which makes me wonder--
I generate all my html with either CGI.pm or simple print statements, and
I haven't had encountered madness (well, not from this cause, anyway). But
I just use very spartan html forms and reports. What kind of madness am I
heading for? Are the problems averted by using templating system only
apparent in fancy-pants pages, or I have just been lucky so far?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 12 Jan 2005 12:49:10 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: [OT] ISO book on CGI design
Message-Id: <Z-OdnVVZPtWF_njcRVn-tw@adelphia.com>
xhoster@gmail.com wrote:
> I just use very spartan html forms and reports. What kind of madness am I
> heading for? Are the problems averted by using templating system only
> apparent in fancy-pants pages, or I have just been lucky so far?
For smaller jobs where one person wears all the hats, it's not so critical -
at that point, it's mostly just an issue of learning good habits that will
be useful to you later on.
But, when the site grows larger and it comes time to split your work between
a designer and a programmer, and maybe a copy editor as well, then having a
clean separation between components is an absolute must.
A simplistic view of that situation might be that the copy editor and
designer do their jobs, then hand off the result to the developer to code
the HTML and logic. It rarely (if ever) works out like that. Once the
interactivity is added, design problems become apparent that weren't
obvious in the static prototype - and once the design problems are taken
care of, the copy needs to be modified to reflect them. Of course, the new
design and copy demands some changes in the back end...
And so it goes, back and forth, for days at a time - sometimes weeks or even
months. If you have three people, all trying to get their work done by
passing around and making changes to a single document, it's an exercise in
herding cats. It's *much* easier when each person has their own document to
work on.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 12 Jan 2005 08:25:31 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105547131.040521.234390@f14g2000cwb.googlegroups.com>
Hi,
I just posted a message on deleting newline characters in perl.
I used this code to do that:
perl -pe "chomp;print $/ if $.>1 and /^\d/" file1 > file2
I ended up with a new text file in this format:
1sampletextsampletextsamplet22tsampletextsampletextsampletext
2sampletextsampletextsampletextsam56etextsampletextsampletext
3sampletextsampletextsampletextsampletextsampletextsampletext
8sampletextsampletextsampletex765mpletextsampletextsampletext
9sampletextsampletextsampletextsampletextsampletextsampletext
15sampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsample324tsampletextsampletext
...
Now what I want is to add a delimiter inbetween the number at the
beginning of the line and the text. The number however could be any
number of digits long. So for instance if I use a "/" as a delimiter
the text would look like this.
1/sampletextsampletextsamplet22tsampletextsampletextsampletext
2/sampletextsampletextsampletextsam56etextsampletextsampletext
3/sampletextsampletextsampletextsampletextsampletextsampletext
8/sampletextsampletextsampletex765mpletextsampletextsampletext
9/sampletextsampletextsampletextsampletextsampletextsampletext
15/sampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsample324tsampletextsampletext
This way I can go from a text file to Excel and then into a database.
Could anyone help me with this?
Thanks,
Joe
------------------------------
Date: Wed, 12 Jan 2005 16:58:51 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <fHcFd.8010$eb.958@trndny06>
<toomanyjoes@mail.utexas.edu> wrote in message
news:1105547131.040521.234390@f14g2000cwb.googlegroups.com...
> I ended up with a new text file in this format:
>
> 1sampletextsampletextsamplet22tsampletextsampletextsampletext
> 2sampletextsampletextsampletextsam56etextsampletextsampletext
> 3sampletextsampletextsampletextsampletextsampletextsampletext
> 8sampletextsampletextsampletex765mpletextsampletextsampletext
> 9sampletextsampletextsampletextsampletextsampletextsampletext
>
15sampletextsampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletextsample324tsampletextsampletext
> ...
>
> Now what I want is to add a delimiter inbetween the number at the
> beginning of the line and the text. The number however could be any
> number of digits long. So for instance if I use a "/" as a delimiter
> the text would look like this.
>
> 1/sampletextsampletextsamplet22tsampletextsampletextsampletext
> 2/sampletextsampletextsampletextsam56etextsampletextsampletext
> 3/sampletextsampletextsampletextsampletextsampletextsampletext
> 8/sampletextsampletextsampletex765mpletextsampletextsampletext
> 9/sampletextsampletextsampletextsampletextsampletextsampletext
>
15/sampletextsampletextsampletextsampletextsampletextsampletextsampletex
tsampletextsampletextsample324tsampletextsampletext
>
> This way I can go from a text file to Excel and then into a database.
> Could anyone help me with this?
This is a trivial operation using regular expressions and
search-and-replace. I suggest you read up:
perldoc perlretut
perldoc perlrequick
perldoc perlre
Paul Lalli
------------------------------
Date: 12 Jan 2005 09:31:43 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105551103.624840.303390@c13g2000cwb.googlegroups.com>
Anyone can feel free to post helpful messages despite Paul Lalli's
post. I realize it is trivial, I'm not a Perl programmer, and I am
reading up, but my project is waiting for this one simple task to be
completed before moving on so the faster I figure this out the better.
Paul if its so easy why not code to do it? I suggest you read up on
newsgroup etiquette.
------------------------------
Date: 12 Jan 2005 09:32:09 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105551129.560260.305130@c13g2000cwb.googlegroups.com>
Anyone can feel free to post helpful messages despite Paul Lalli's
post. I realize it is trivial, I'm not a Perl programmer, and I am
reading up, but my project is waiting for this one simple task to be
completed before moving on so the faster I figure this out the better.
Paul if its so easy why not post code to do it? I suggest YOU read up
on newsgroup etiquette.
------------------------------
Date: Wed, 12 Jan 2005 10:41:02 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <p82dnVb_9pm8_HjcRVn-og@comcast.com>
toomanyjoes@mail.utexas.edu wrote:
> Anyone can feel free to post helpful messages despite Paul Lalli's
> post. I realize it is trivial, I'm not a Perl programmer, and I am
> reading up, but my project is waiting for this one simple task to be
> completed before moving on so the faster I figure this out the better.
> Paul if its so easy why not post code to do it? I suggest YOU read up
> on newsgroup etiquette.
Paul gave you good advice. You can learn more from the docs than you can
learn from blindly copying code. Paul showed you exactly where to read
in the docs.
Perhaps you should read the posting guidelines for this group. Now that
you have insulted Paul, you are probably on your own.
------------------------------
Date: Wed, 12 Jan 2005 18:02:40 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <4DdFd.8011$eb.7207@trndny06>
<toomanyjoes@mail.utexas.edu> wrote in message
news:1105551129.560260.305130@c13g2000cwb.googlegroups.com...
> Anyone can feel free to post helpful messages despite Paul Lalli's
> post.
My post was extremely helpful.
> I realize it is trivial, I'm not a Perl programmer, and I am
> reading up, but my project is waiting for this one simple task to be
> completed before moving on
The failure of your project coordinator to hire correct staff is not
justification for asking this group to do your project's work for you.
> so the faster I figure this out the better.
The better for you, perhaps. The better for the rest of the people
reading this group, not so much, no.
> Paul if its so easy why not post code to do it?
Because I *know* how to do it. I am not the one who needs to learn.
> I suggest YOU read up on newsgroup etiquette.
Really? Would that etiquette include such things as posting the same
message twice? Would it include not reading the posting guidelines for
the group? Would it include not quoting the material your are
responding to?
Please do go read those guidelines. Then try to understand that this is
not a group where it is acceptable to ask "Someone please do this for
me." This is a group where beginners are encouraged to ask for help or
understanding when it comes to *learning* the Perl language.
Paul Lalli
------------------------------
Date: 12 Jan 2005 10:07:10 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105553230.477052.134080@c13g2000cwb.googlegroups.com>
In spite of Scotts message anyone can feel free to post useful
information. Scott, I already knew about those references. I've been
going through them. My post did not violate any rules for this group, I
have read those too. I am not new to newgroups, only to the Perl
language. You guys could make someone new here a little more
comfortable posting questions. Rather than more people telling me how
little I know about Perl, I would be much oblidged to anyone who can
post a little snippet of code for me.
------------------------------
Date: 12 Jan 2005 10:08:27 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105553307.453168.139420@c13g2000cwb.googlegroups.com>
In spite of Scotts message anyone can feel free to post useful
information. Scott, I already knew about those references. I've been
going through them. My post did not violate any rules for this group, I
have read those too. I am not new to newgroups, only to the Perl
language. You guys could make someone new here a little more
comfortable posting questions. Rather than more people telling me how
little I know about Perl, I would be much oblidged to anyone who can
post a little snippet of code for me.
------------------------------
Date: 12 Jan 2005 10:18:35 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105553915.762548.182620@c13g2000cwb.googlegroups.com>
I'm not going to let my temper get the better of me Paul, like you just
did. Showing the passion of your emotions is very unattractive in
groups like this. Perhaps my "project coordinator" hired the wrong
"staff", true. But the facts are:
1) I have to get this done
2) Your post was of no help to me
3) I still need help
I hope you will accept an apology for insulting you. I have read the
guidelines for this group. I've been posting on these groups for over
10 years back when it was DejaNews and it has and probably will remain
a forum to ask people to write code for you, many people learn this way.
------------------------------
Date: Wed, 12 Jan 2005 13:20:08 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <apidnaZ8_4HE93jcRVn-3A@adelphia.com>
toomanyjoes@mail.utexas.edu wrote:
> In spite of Scotts message anyone can feel free to post useful
> information.
You can keep parroting that cute little catch-phrase of yours all you want -
the fact remains that the people you're berating *did* post useful
information.
Frankly, given your attitude, I'd imagine it's the last useful information
you'll get from this group.
> You guys could make someone new here a little more
> comfortable posting questions.
Making people comfortable posting questions not our goal here. Our goal is
to make people comfortable with the docs, so they don't have to post
questions.
To put it another way, if you've come looking for free fish, you're in the
wrong place. We give fishing lessons here.
> I would be much oblidged to anyone who can
> post a little snippet of code for me.
If you want code written to spec, email me privately for my consulting
rates.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Wed, 12 Jan 2005 11:23:07 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <7fWdnbHf7_9i93jcRVn-vA@comcast.com>
toomanyjoes@mail.utexas.edu wrote:
> My post did not violate any rules for this group, I have read those
> too.
But the posting guidelines said:
> First make a short (less than 20-30 lines) and *complete* program
> that illustrates the problem you are having. People should be able to
> run your program by copy/pasting the code from your article.
------------------------------
Date: Wed, 12 Jan 2005 18:30:27 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <71eFd.8014$eb.606@trndny06>
<toomanyjoes@mail.utexas.edu> wrote in message
news:1105553915.762548.182620@c13g2000cwb.googlegroups.com...
> I'm not going to let my temper get the better of me Paul, like you
just
> did.
You continue to not following the posting guidelines, so I don't know
exactly what you're referring to. I'm not aware of exhibiting any
temper in my posts.
> Showing the passion of your emotions is very unattractive in
> groups like this. Perhaps my "project coordinator" hired the wrong
> "staff", true. But the facts are:
>
> 1) I have to get this done
Which remains not our problem.
> 2) Your post was of no help to me
Of course it was. It just wasn't the help you wanted.
> 3) I still need help
You've been given help. You choose not to accept it.
> I hope you will accept an apology for insulting you.
You can't offern an apology for insulting me in the same message in
which you continue to insult me. It doesn't work that way. Thanks for
the attempt, however.
> I have read the guidelines for this group.
And yet, have chosen not to follow them. That's actually worse than not
reading them, in my mind.
> I've been posting on these groups for over
> 10 years back when it was DejaNews
I don't know which groups you're referring to, but they don't include
this one.
> and it has and probably will remain
> a forum to ask people to write code for you, many people learn this
way.
No. It isn't, and it won't. Please search the archives of this group.
See how well previous requests for "write this for me" have been
received.
If you want code written for you, I'd be happy to help. Feel free to
respond privately and we can discuss my professional rates.
If you want to learn, I have already given you pointers on where to
start. I'd be happy to help you understand that documentation, or to
help you correct any attempts you've made, free of charge.
Paul Lalli
------------------------------
Date: Wed, 12 Jan 2005 11:30:43 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <8fGdnZyjscRa8XjcRVn-vA@comcast.com>
toomanyjoes@mail.utexas.edu wrote:
> I have read the guidelines for this group.
But you don't follow them.
> I've been posting on these groups for over
> 10 years back when it was DejaNews
These groups have NEVER been DejaNews. DejaNews was an archive of these
groups.
> and it has and probably will remain
> a forum to ask people to write code for you
It never has been.
------------------------------
Date: Wed, 12 Jan 2005 13:32:03 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <huOdna3infe48HjcRVn-sw@adelphia.com>
toomanyjoes@mail.utexas.edu wrote:
> I'm not going to let my temper get the better of me Paul
Too late.
> Showing the passion of your emotions is very unattractive
Yes it is - why are you doing it?
> 2) Your post was of no help to me
Paul told you precisely where to find the answers you need? In what way was
that unhelpful? What did you expect, ready-to-run code written to spec?
> I've been posting on these groups for over
> 10 years back when it was DejaNews
Silly rabbit. This isn't "Google Groups", and it wasn't "DejaNews" - it's
usenet, and those are nothing but web-based front ends for it. Since you're
so fond of Google, try searching for "usenet history" and studying up a bit
before you mouth off.
> and it has and probably will remain
> a forum to ask people to write code for you
No, that is completely and utterly wrong. This is a forum for people who
want to learn to write their own code. If you want to hire someone to write
code for you, try a group with "jobs" in its name.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Wed, 12 Jan 2005 18:27:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <cs3prm$f0s$1@sun3.bham.ac.uk>
toomanyjoes@mail.utexas.edu wrote:
> I ended up with a new text file in this format:
>
> 1sampletextsampletextsamplet22tsampletextsampletextsampletext
> 2sampletextsampletextsampletextsam56etextsampletextsampletext
> 3sampletextsampletextsampletextsampletextsampletextsampletext
> 8sampletextsampletextsampletex765mpletextsampletextsampletext
> 9sampletextsampletextsampletextsampletextsampletextsampletext
> 15sampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsample324tsampletextsampletext
> ...
>
> Now what I want is to add a delimiter inbetween the number at the
> beginning of the line and the text. The number however could be any
> number of digits long. So for instance if I use a "/" as a delimiter
> the text would look like this.
>
> 1/sampletextsampletextsamplet22tsampletextsampletextsampletext
> 2/sampletextsampletextsampletextsam56etextsampletextsampletext
> 3/sampletextsampletextsampletextsampletextsampletextsampletext
> 8/sampletextsampletextsampletex765mpletextsampletextsampletext
> 9/sampletextsampletextsampletextsampletextsampletextsampletext
> 15/sampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsampletextsample324tsampletextsampletext
perl -pe 's/^(\d+)/$1\//'
> Could anyone help me with this?
Note I have helped you despite and not because of your complaints at
being told to RTFM.
------------------------------
Date: Wed, 12 Jan 2005 10:36:29 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <120120051036294970%jgibson@mail.arc.nasa.gov>
In article <1105553230.477052.134080@c13g2000cwb.googlegroups.com>,
<toomanyjoes@mail.utexas.edu> wrote:
> In spite of Scotts message anyone can feel free to post useful
> information. Scott, I already knew about those references. I've been
> going through them. My post did not violate any rules for this group, I
> have read those too. I am not new to newgroups, only to the Perl
> language. You guys could make someone new here a little more
> comfortable posting questions. Rather than more people telling me how
> little I know about Perl, I would be much oblidged to anyone who can
> post a little snippet of code for me.
>
I'll ignore your attitude and give you some help, anyway. Try this:
perl -pe 'chomp;s/^(\d+)/$1\//;print $/ if $.>1 and /^\d/' file1 > file2
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: 12 Jan 2005 10:43:23 -0800
From: toomanyjoes@mail.utexas.edu
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <1105555403.092020.169360@f14g2000cwb.googlegroups.com>
Ahhhh...Thank you guys. I apologize for this threads explosion, it got
a little out of hand. I just in practice never reply to a post unless I
have the answer so it irks me when others don't follow that practice.
Next time I'll just remain silent. I really thank you guys for your
help.
------------------------------
Date: Wed, 12 Jan 2005 13:47:32 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <wI2dnek3h5RZ7XjcRVn-pg@adelphia.com>
toomanyjoes@mail.utexas.edu wrote:
> I just in practice never reply to a post unless I
> have the answer so it irks me when others don't follow that practice.
Paul *did* follow that practice. He told you where you could find the answer
to your question. Quit whining.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Wed, 12 Jan 2005 12:35:22 -0600
From: Whitey Johnson <whitey@newmail.net>
Subject: Re: angle operator, backticks, and redirection
Message-Id: <pan.2005.01.12.18.35.22.211495@newmail.net>
On Tue, 11 Jan 2005 21:46:24 -0800, Ed Mancebo wrote:
> I have a short perl script, it goes like this:
>
> #!/usr/bin/perl
>
> $line = <STDIN>;
> print $line;
> `echo $line > output`;
Try using the system command instead of backticks.
#!/usr/bin/perl
use strict;
use warnings;
print "input something\n";
chomp(my $line = <STDIN>);
print "$line\n";
system "echo $line > output";
>
> I was expecting it to read a line from std. input, then output the line
> to the screen and to a file named 'output'. When I try this, the
> output file is always empty, even though the print statement works.
> Can someone tell me why?
>
> Thanks,
>
> Ed
------------------------------
Date: Wed, 12 Jan 2005 13:50:16 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: angle operator, backticks, and redirection
Message-Id: <wI2dneg3h5T17HjcRVn-pg@adelphia.com>
Whitey Johnson wrote:
> On Tue, 11 Jan 2005 21:46:24 -0800, Ed Mancebo wrote:
>
>> I have a short perl script, it goes like this:
>>
>> #!/usr/bin/perl
>>
>> $line = <STDIN>;
>> print $line;
>> `echo $line > output`;
>
> Try using the system command instead of backticks.
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> print "input something\n";
> chomp(my $line = <STDIN>);
> print "$line\n";
> system "echo $line > output";
Your code is correct - but your explanation is not. It's the chomp() in your
version that's making the difference, not your use of system() instead of
backticks.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7636
***************************************