[25165] in Perl-Users-Digest
Perl-Users Digest, Issue: 7414 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 17 14:07:17 2004
Date: Wed, 17 Nov 2004 11:05:06 -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, 17 Nov 2004 Volume: 10 Number: 7414
Today's topics:
Re: Adding a unique user name in a file <jgibson@mail.arc.nasa.gov>
Array of Hashes ? (Tom)
Re: Array of Hashes ? <perl@my-header.org>
Re: Array of Hashes ? <1usa@llenroc.ude.invalid>
CPAN shell as plain user <perl@my-header.org>
FAQ 6.22: How can I match strings with multibyte charac <comdog@panix.com>
Re: First Perl Program <glex_nospam@qwest.invalid>
Re: First Perl Program <1usa@llenroc.ude.invalid>
Re: How to work (?{code}) ctcgag@hotmail.com
Parse Row to Columns <jc_va@hotmail.com>
Re: Parse Row to Columns <tadmc@augustmail.com>
Re: Parse Row to Columns <jgibson@mail.arc.nasa.gov>
Re: Parse Row to Columns <uguttman@athenahealth.com>
Please help on script failures <me@you.com>
Re: Please help on script failures <tadmc@augustmail.com>
SysV constants, where are they defined? (js)
Re: Text::Autoformat usage for a rookie (Gary Schenk)
Re: the antichomp <1usa@llenroc.ude.invalid>
Re: the antichomp <1usa@llenroc.ude.invalid>
Re: the antichomp <sbryce@scottbryce.com>
Re: the antichomp <uguttman@athenahealth.com>
Re: the antichomp <uguttman@athenahealth.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Nov 2004 08:54:09 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Adding a unique user name in a file
Message-Id: <171120040854093429%jgibson@mail.arc.nasa.gov>
In article <cnfs5r$2dkq$1@news.hgc.com.hk>, sam <sam.wun@authtec.net>
wrote:
> Hi,
>
> Is there any perl module I can use to read in a list of user names from
> a file and do a binary search on the list base on the user name, if the
> user name is not found, add this user name to the file?
Have you looked on CPAN for a module? See <http://search.cpan.org>.
While there are thousands of Perl modules available, you are unlikely
to find one to do exactly what you want, as the task depends upon the
format of your file. Also, it sounds like a relatively simple task. No
one is going to submit a module to do a job that can be done in 10-20
lines of Perl.
Is there some reason that you cannot write a program to do what you
want? You should try to write a program and post here if you run into
problems. Hint: use a hash with user name as key to see if a name is in
the file. There is no need to do a binary search or any other kind of
search.
------------------------------
Date: 17 Nov 2004 08:59:07 -0800
From: sudhirx@gmail.com (Tom)
Subject: Array of Hashes ?
Message-Id: <f50c52fa.0411170859.ed4643f@posting.google.com>
Well, I am a beginner as far as perl is concerned.
Can some one point me that 'm doing is correct.
I have pasted below my hash and array using Data::Dumper()
I am pushing Hash1, Hash2 in to an Array
I don't see => when 'm priting the Array using Data::Dumper()
By looking at the dump can someone ascertain if I have formed an Array
of Hashes or not?
--------------------------------
Tom> Hash 1:
$VAR1 = {
'1' => [
'0'
],
'0' => [
'0'
],
'TestCase' => [
'PC_Battery'
]
};
Tom> Hash 2:
$VAR1 = {
'1' => [
'0'
],
'0' => [
'0'
],
'2' => [
'0'
],
'TestCase' => [
'PC_Something'
]
};
Tom> Array of Hashes: (?)
$VAR1 = [
[
'1',
[
'0'
],
'0',
[
'0'
],
'TestCase',
[
'PC_Battery'
]
],
[
'1',
[
'0'
],
'0',
[
'0'
],
'2',
[
'0'
],
'TestCase',
[
'PC_Something'
]
]
];
---------------------------------------------------
------------------------------
Date: Wed, 17 Nov 2004 18:17:27 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: Array of Hashes ?
Message-Id: <8p1np0h77ekpo3f2pkfpr5cs0v5sg2tkmt@4ax.com>
X-Ftn-To: Tom
sudhirx@gmail.com (Tom) wrote:
>Well, I am a beginner as far as perl is concerned.
>Can some one point me that 'm doing is correct.
>I have pasted below my hash and array using Data::Dumper()
>
>I am pushing Hash1, Hash2 in to an Array
>I don't see => when 'm priting the Array using Data::Dumper()
>
>By looking at the dump can someone ascertain if I have formed an Array
>of Hashes or not?
No, you didn't. What do you want to accomplish?
--
Matija
------------------------------
Date: 17 Nov 2004 17:21:04 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Array of Hashes ?
Message-Id: <Xns95A47DA443544asu1cornelledu@132.236.56.8>
sudhirx@gmail.com (Tom) wrote in
news:f50c52fa.0411170859.ed4643f@posting.google.com:
> Well, I am a beginner as far as perl is concerned.
> Can some one point me that 'm doing is correct.
> I have pasted below my hash and array using Data::Dumper()
>
> I am pushing Hash1, Hash2 in to an Array
comp.lang.perl.mindreadres is down the hall to your right.
> I don't see => when 'm priting the Array using Data::Dumper()
Have you read
perldoc perldsc
Sinan
------------------------------
Date: Wed, 17 Nov 2004 18:29:15 +0100
From: Matija Papec <perl@my-header.org>
Subject: CPAN shell as plain user
Message-Id: <142np0d5tqkdm4v7ldilhmaf2075jum9l4@4ax.com>
I want to install some modules and everything goes well until "make install"
as there are some test errors. Should I "force install Net::SFTP"?
o conf makepl_arg "LIB=~/myperl/lib INSTALLMAN1DIR=~/myperl/man/man1
INSTALLMAN3DIR=~/myperl/man/man3"
install Net::SFTP
================
Test returned status 2 (wstat 512, 0x200)
Failed Test Stat Wstat Total Fail Failed List of Failed
-----------------------------------------------------------------------------------------------------------------------------
t/01-load.t 2 512 1 2 200.00% 1
t/06-circular.t 2 512 ?? ?? % ??
Failed 2/2 test scripts, 0.00% okay. 1/1 subtests failed, 0.00% okay.
make: *** [test_dynamic] Error 2
/usr/bin/make test -- NOT OK
Running make install
make test had returned bad status, won't install without force
cpan>
--
Matija
------------------------------
Date: Wed, 17 Nov 2004 17:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 6.22: How can I match strings with multibyte characters?
Message-Id: <cng085$lnb$1@reader1.panix.com>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.
--------------------------------------------------------------------
6.22: How can I match strings with multibyte characters?
Starting from Perl 5.6 Perl has had some level of multibyte character
support. Perl 5.8 or later is recommended. Supported multibyte character
repertoires include Unicode, and legacy encodings through the Encode
module. See perluniintro, perlunicode, and Encode.
If you are stuck with older Perls, you can do Unicode with the
"Unicode::String" module, and character conversions using the
"Unicode::Map8" and "Unicode::Map" modules. If you are using Japanese
encodings, you might try using the jperl 5.005_03.
Finally, the following set of approaches was offered by Jeffrey Friedl,
whose article in issue #5 of The Perl Journal talks about this very
matter.
Let's suppose you have some weird Martian encoding where pairs of ASCII
uppercase letters encode single Martian letters (i.e. the two bytes "CV"
make a single Martian letter, as do the two bytes "SG", "VS", "XX",
etc.). Other bytes represent single characters, just like ASCII.
So, the string of Martian "I am CVSGXX!" uses 12 bytes to encode the
nine characters 'I', ' ', 'a', 'm', ' ', 'CV', 'SG', 'XX', '!'.
Now, say you want to search for the single character "/GX/". Perl
doesn't know about Martian, so it'll find the two bytes "GX" in the "I
am CVSGXX!" string, even though that character isn't there: it just
looks like it is because "SG" is next to "XX", but there's no real "GX".
This is a big problem.
Here are a few ways, all painful, to deal with it:
$martian =~ s/([A-Z][A-Z])/ $1 /g; # Make sure adjacent ``martian''
# bytes are no longer adjacent.
print "found GX!\n" if $martian =~ /GX/;
Or like this:
@chars = $martian =~ m/([A-Z][A-Z]|[^A-Z])/g;
# above is conceptually similar to: @chars = $text =~ m/(.)/g;
#
foreach $char (@chars) {
print "found GX!\n", last if $char eq 'GX';
}
Or like this:
while ($martian =~ m/\G([A-Z][A-Z]|.)/gs) { # \G probably unneeded
print "found GX!\n", last if $1 eq 'GX';
}
Here's another, slightly less painful, way to do it from Benjamin
Goldberg, who uses a zero-width negative look-behind assertion.
print "found GX!\n" if $martian =~ m/
(?<![A-Z])
(?:[A-Z][A-Z])*?
GX
/x;
This succeeds if the "martian" character GX is in the string, and fails
otherwise. If you don't like using (?<!), a zero-width negative
look-behind assertion, you can replace (?<![A-Z]) with (?:^|[^A-Z]).
It does have the drawback of putting the wrong thing in $-[0] and $+[0],
but this usually can be worked around.
--------------------------------------------------------------------
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-2002 Tom Christiansen and Nathan
Torkington, and other contributors as noted. All rights
reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
------------------------------
Date: Wed, 17 Nov 2004 10:40:26 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: First Perl Program
Message-Id: <2aLmd.9$ul1.35476@news.uswest.net>
Tore Aursand wrote:
> On Tue, 16 Nov 2004 13:04:41 -0800, DGP wrote:
>
>>#!C:\Perl\bin\perl.exe
>># iges2pt.pl
>># Extract point locations from IGES file and write to new text file.
>>use warnings;
[...]
> my @parts = split( ',', $_ );
> s/D/E/ for ( @parts );
>
> print OUTF "@parts[1..3]\n";
Small improvement. Since only [1..3] seems to be all that's needed in
the end.
my @parts = (split( ',', $_ ))[1..3];
s/D/E/ for ( @parts );
print OUTF "@parts\n";
------------------------------
Date: 17 Nov 2004 18:24:00 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: First Perl Program
Message-Id: <Xns95A4884FC7DC0asu1cornelledu@132.236.56.8>
Michele Dondi <bik.mido@tiscalinet.it> wrote in
news:lhhmp09f1851iud5ir24mm0in39mvptre9@4ax.com:
> On 16 Nov 2004 13:04:41 -0800, parkerdg@gmail.com (DGP) wrote:
>
>>I decided Perl was the best tool for the job. After reading a begginer
>>Perl book, I was able to complete the program below within a few
>>hours. I think this speaks to Perl's ease of use, power, and
>
> I see that your post has been duly commented, and it doesn't seem to
> me that I'd have anything to add. As an overall cmt, though, let me
> tell you that as a "First Perl Program" this is fairly good. You
> should really see the kind of crap some people post here...
Ditto. It is always good to see someone make the effort.
Sinan
------------------------------
Date: 17 Nov 2004 16:52:22 GMT
From: ctcgag@hotmail.com
Subject: Re: How to work (?{code})
Message-Id: <20041117115222.154$uC@newsreader.com>
"Mark" <admin@asarian-host.net> wrote:
> "Brian McCauley" <nobull@mail.com> wrote in message
> news:cncvhl$brg$1@sun3.bham.ac.uk...
>
> Thank you for your reply (more below).
>
> >> You are missing a question mark. :-)
> >>
> >> You want (?? { code }) rather than (? { code }).
> >
> > Surely the OP really wants the hideous but widely used idiom:
> >
> > (?? { (code) ? '' : '(?!)' })
>
> What does this do? "If code returns true, return '', else ..."?
If the code returns true, incorporate the empty string, which matches
everywhere, into the RE. If the code returns false, incorporate (?!),
which matches nowhere, into the RE.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Wed, 17 Nov 2004 11:40:17 -0500
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: Parse Row to Columns
Message-Id: <hgbs62-bff.ln1@turf.turgidson.com>
I have a very large csv file from a spreadsheet. The first 2 columns are a
description, and the next 52 columns are a value for a week of the year
(using only 3 weeks in this example)
Is there a way in Perl to transform these into a format that is loadable
into a relational database such as Oracle?
For example, I'd like to change the following into the latter format. The
first column would be a derived week number. That first column is something
I could live without if I had to.
Any help with a simple perl would be appreciated.
washer,sunday,33,44,55
dryer,monday,667,333,44
refrig,monday,555,876,99
...
...
1 washer sunday 33
2 washer sunday 44
3 washer sunday 55
1 dryer monday 667
2 dryer monday 333
3 dryer monday 444
1 refrig monday 555
2 refrig monday 876
3 refrig monday 99
...
...
------------------------------
Date: Wed, 17 Nov 2004 11:48:35 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Parse Row to Columns
Message-Id: <slrncpn3nj.blb.tadmc@magna.augustmail.com>
Buck Turgidson <jc_va@hotmail.com> wrote:
> Is there a way in Perl to transform these into a format that is loadable
> into a relational database such as Oracle?
>
> For example, I'd like to change the following into the latter format.
[ snip input, repeated in code below ]
[ desired output: ]
> 1 washer sunday 33
> 2 washer sunday 44
> 3 washer sunday 55
> 1 dryer monday 667
> 2 dryer monday 333
> 3 dryer monday 444
> 1 refrig monday 555
> 2 refrig monday 876
> 3 refrig monday 99
-----------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
while ( <DATA> ) {
chomp;
my( $item, $day, @nums ) = split /,/;
print $_ + 1, " $item $day $nums[$_]\n" for 0 .. $#nums;
}
__DATA__
washer,sunday,33,44,55
dryer,monday,667,333,44
refrig,monday,555,876,99
-----------------------------------------
You may need to Do It Right and use the Text::CSV or Text::CSV_XS
modules if you have trickier values than shown...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 17 Nov 2004 10:34:02 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Parse Row to Columns
Message-Id: <171120041034023002%jgibson@mail.arc.nasa.gov>
In article <hgbs62-bff.ln1@turf.turgidson.com>, Buck Turgidson
<jc_va@hotmail.com> wrote:
> I have a very large csv file from a spreadsheet. The first 2 columns are a
> description, and the next 52 columns are a value for a week of the year
> (using only 3 weeks in this example)
>
> Is there a way in Perl to transform these into a format that is loadable
> into a relational database such as Oracle?
>
> For example, I'd like to change the following into the latter format. The
> first column would be a derived week number. That first column is something
> I could live without if I had to.
>
> Any help with a simple perl would be appreciated.
>
>
>
> washer,sunday,33,44,55
> dryer,monday,667,333,44
> refrig,monday,555,876,99
> ...
> ...
>
> 1 washer sunday 33
> 2 washer sunday 44
> 3 washer sunday 55
> 1 dryer monday 667
> 2 dryer monday 333
> 3 dryer monday 444
> 1 refrig monday 555
> 2 refrig monday 876
> 3 refrig monday 99
Try this:
#!/usr/local/bin/perl
#
use warnings;
use strict;
while(<DATA>){
chomp;
my($appliance,$day,@values) = split(/,/);
for my $i ( 0 .. $#values ) {
printf "%d %s %s %d\n", ($i+1), $appliance,
$day, $values[$i];
}
}
__DATA__
washer,sunday,33,44,55
dryer,monday,667,333,44
refrig,monday,555,876,99
------------------------------
Date: Wed, 17 Nov 2004 13:54:41 -0500
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: Parse Row to Columns
Message-Id: <m3zn1g5mry.fsf@lap.athenahealth.com>
>>>>> "JG" == Jim Gibson <jgibson@mail.arc.nasa.gov> writes:
JG> use strict;
JG> while(<DATA>){
JG> chomp;
JG> my($appliance,$day,@values) = split(/,/);
JG> for my $i ( 0 .. $#values ) {
i try to not use index variables when not needed or at least avoid
indexing itself. so loop over the values and bump $i instead
JG> printf "%d %s %s %d\n", ($i+1), $appliance,
JG> $day, $values[$i];
$my $i ;
for my $val ( @values ) {
printf "%d %s %s %d\n", ++$i, $appliance, $day, $val ;
}
and choose different format specs if you want to keep the fields aligned
or use a format module.
uri
------------------------------
Date: Wed, 17 Nov 2004 08:55:53 -0800
From: "Paul in San Diego" <me@you.com>
Subject: Please help on script failures
Message-Id: <poLmd.123153$cJ3.74480@fed1read06>
I just moved my Corvette Club's website (www.cocsd.com) to another Unix
server that offered a lot more space. I've got lots of changes to make to
the site but the first thing is to get the login area to work again.
The Members Only area is supposed to allow us members with access, to log in
and update rasters, d/l files etc. I changed the info in the script config
files to indicate where the site is now loaded, but all the scripts fail.
Suggestions are DEARLY APPRECIATED!
I'm a part-time amateur on web design but scripting is not one of my strong
points!
Thanks
Paul in San Diego
------------------------------
Date: Wed, 17 Nov 2004 11:36:36 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Please help on script failures
Message-Id: <slrncpn314.blb.tadmc@magna.augustmail.com>
Paul in San Diego <me@you.com> wrote:
> The Members Only area is supposed to allow us members with access, to log in
> and update rasters, d/l files etc. I changed the info in the script config
> files to indicate where the site is now loaded, but all the scripts fail.
> Suggestions are DEARLY APPRECIATED!
>
> I'm a part-time amateur on web design but scripting is not one of my strong
> points!
Then you must not have written the code being used, eh?
The First Suggestion is to read the documentation that came
with whatever (nameless) software you've gotten.
The Second Suggestion is to contact the person/company that
you got the software from for technical support.
The Third Suggestion is to look in your server logs and
see if there are any helpful messages in there.
If none of those work, consider hiring someone who *is* a programmer
to fix it up for you.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Nov 2004 09:16:40 -0800
From: jstrempe@cox.net (js)
Subject: SysV constants, where are they defined?
Message-Id: <51d6249f.0411170916.55373844@posting.google.com>
I'm getting into some programming with IPC::Semaphore, etc. After
spending some time searching without success, I was wondering where
one finds what each of the SysV constants stand for so I know a little
bit more of what I'm doing.
Thanks!
js
------------------------------
Date: 17 Nov 2004 08:29:40 -0800
From: gary_schenk@yahoo.com (Gary Schenk)
Subject: Re: Text::Autoformat usage for a rookie
Message-Id: <81fd27bb.0411170829.73e2be41@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<qf0p62-715.ln1@osiris.mauzo.dyndns.org>...
> Quoth Gary Schenk <gwschenk@fuzz.socal.rr.com>:
> > #!/usr/bin/perl -w
>
> use warnings; # instead of -w
> use strict;
>
> Have you read the Posting Guidelines?
>
I have now.
> > use Text::Autoformat;
> >
> > print "\n\nEnter a file to convert, or 'q' to quit: ";
> > chomp( $input = <STDIN> );
> ^^
> my
>
> I would use ^D (EOF) (^Z on Win32) to signal 'quit' instead, as this is
> more usual with programs like this; you can detect EOF because $input
> will be undef. Also, I would check @ARGV for files before prompting, so
> you can call it like
>
> ./script file1
>
> if you want to.
>
> > if ( $input ne 'q' ) {
>
> I would use 'unless' here, but you may find that more confusing.
>
I find lots of Perl confusing. I have a simple mind, and try to keep
things simple.
> > open( INPUT, "<$input" ) or die( "Can't open $input for
> > reading: $!" );
>
> You have checked the return of open: good.
> You have included the file and $! in the error: good. :)
> Use lexical FHs.
> Use 3-arg open.
> Don't use unnecessary parens.
>
> open my $INPUT, '<', $input or die "...";
>
I have lots to learn about idioms in Perl. For example, in Anno's
reply, I still have not quite figured out how some of it works.
> > open( OUTPUT, ">output.txt" ) or die( "Can't open output.txt:
> > $!" );
>
> This is generally a bad idea... you would be much better off (say)
> renaming the old file to "$input~" and overwriting, or creating the new
> file as "$input.fmt"; or simply processing STDIN to STDOUT and letting
> the user redirect where he will.
>
I have a need to keep the original file intact. However, that is
laziness on my part. ( A Perl virtue?) Why is this "generally a bad
idea"?
<snipped a good explanation on how things work>
> Ben
Thanks for the thoughtful reply. There is a lot here, and in Anno's
reply, for me to digest. It should keep me busy for sometime!
I find it intersting that the Perl in my class and in my books is
different from the Perl in this newsgroup. So much to learn, so little
time.
Gary
------------------------------
Date: 17 Nov 2004 17:14:33 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: the antichomp
Message-Id: <Xns95A47C899C630asu1cornelledu@132.236.56.8>
Uri Guttman <uri@stemsystems.com> wrote in
news:x765445uy1.fsf@mail.sysarch.com:
>>>>>> "ASU" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:
>
> ASU> ioneabu@yahoo.com (wana) wrote in
> news:bf0b47ca.0411170715.2aa1d853 ASU> @posting.google.com:
>
> >> Is there a better way to it than this?
> >>
> >> $_ .= "\n" for @ARGV;
>
> ASU> Of course. Read perldoc -f chomp.
>
> and how would chomp append newlines?
It would not. But it would explain what one needs to do to write an
'antichomp'.
chomp VARIABLE
chomp( LIST )
chomp
This safer version of "chop" removes any trailing string
that corresponds to the current value of $/ (also known
as $INPUT_RECORD_SEPARATOR in the "English" module). It
returns the total number of characters removed from all
its arguments.
So, "the antichomp" would have to do the opposite of what chomp does,
wouldn't it?
Sinan.
------------------------------
Date: 17 Nov 2004 17:27:47 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: the antichomp
Message-Id: <Xns95A47EC7CBEDCasu1cornelledu@132.236.56.8>
Uri Guttman <uri@stemsystems.com> wrote in
news:x7is845vlh.fsf@mail.sysarch.com:
>>>>>> "w" == wana <ioneabu@yahoo.com> writes:
>
> w> Is there a better way to it than this?
> w> $_ .= "\n" for @ARGV;
>
> s/for/x/ ;
>
> uri
I am confused.
use strict;
use warnings;
$_ .= "\n" x @ARGV;
print @ARGV;
__END__
D:\Home> perl t.pl 1 2 3 4 5
12345
OTOH:
use strict;
use warnings;
$_ .= "\n" for @ARGV;
print @ARGV;
__END__
D:\Home> perl t.pl 1 2 3 4 5
1
2
3
4
5
What am I missing?
Sinan.
------------------------------
Date: Wed, 17 Nov 2004 11:15:22 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: the antichomp
Message-Id: <10pn59p24j4kdce@corp.supernews.com>
A. Sinan Unur wrote:
> What am I missing?
A definition of what exactly the OP wants to accomplish.
------------------------------
Date: Wed, 17 Nov 2004 13:46:23 -0500
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: the antichomp
Message-Id: <m3d5yc71q8.fsf@lap.athenahealth.com>
>>>>> "ASU" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:
ASU> Uri Guttman <uri@stemsystems.com> wrote in
ASU> news:x765445uy1.fsf@mail.sysarch.com:
>>>>>>> "ASU" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:
>>
>> >> $_ .= "\n" for @ARGV;
ASU> Of course. Read perldoc -f chomp.
>>
>> and how would chomp append newlines?
ASU> It would not. But it would explain what one needs to do to write an
ASU> 'antichomp'.
ASU> So, "the antichomp" would have to do the opposite of what chomp does,
ASU> wouldn't it?
but that isn't an antichomp. it is appending a newline it over and over
to a single string. and writing an antichomp for such a simple op makes
little sense. see my other post for a better solution.
uri
------------------------------
Date: Wed, 17 Nov 2004 13:48:14 -0500
From: Uri Guttman <uguttman@athenahealth.com>
Subject: Re: the antichomp
Message-Id: <m38y9071n5.fsf@lap.athenahealth.com>
>>>>> "ASU" == A Sinan Unur <1usa@llenroc.ude.invalid> writes:
ASU> Uri Guttman <uri@stemsystems.com> wrote in
ASU> news:x7is845vlh.fsf@mail.sysarch.com:
>>>>>>> "w" == wana <ioneabu@yahoo.com> writes:
>>
w> Is there a better way to it than this?
w> $_ .= "\n" for @ARGV;
>>
>> s/for/x/ ;
>>
>> uri
ASU> I am confused.
untested as always. must have been too late at night. i didn't see the
$_ being aliased to the elements of @ARGV.
uri
------------------------------
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 7414
***************************************