[30962] in Perl-Users-Digest
Perl-Users Digest, Issue: 2207 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 13 00:09:48 2009
Date: Thu, 12 Feb 2009 21:09:12 -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 Thu, 12 Feb 2009 Volume: 11 Number: 2207
Today's topics:
Re: * Obama's wife Naked <howard@brazee.net>
Re: * Obama's wife Naked <too_many_tools@yahoo.com>
Re: [OT] Programmers (UK)...? <cliff@excite.com>
Re: A good data structure to store INI files. <perl@marc-s.de>
Re: Adding path to @INC <whynot@pozharski.name>
cpan config applypatch program <steinbach@gmx-topmail.de>
Re: cpan config applypatch program <perl@marc-s.de>
Re: cpan config applypatch program <steinbach@gmx-topmail.de>
cpan defaults on first use. Can I provide them in a non <nospam@nospam.invalid>
Re: cpan defaults on first use. Can I provide them in a <thepoet_nospam@arcor.de>
Re: dbi mysql problem with placeholders and the default <perl@marc-s.de>
Re: dbi mysql problem with placeholders and the default <devnull4711@web.de>
Re: error printing page using LWP::Simple <larry@example.invalid>
Re: Getting the name of a variable reference <ben@morrow.me.uk>
Install a perl module to the main perl lib dir <steinbach@gmx-topmail.de>
Question about why a pipe doesn't block <cdalten@gmail.com>
Re: Question about why a pipe doesn't block xhoster@gmail.com
question on de-referencing expressions <olingaa@gmail.com>
Re: question on de-referencing expressions <noreply@gunnar.cc>
Re: question on de-referencing expressions (Jens Thoms Toerring)
Re: question on de-referencing expressions <jurgenex@hotmail.com>
Reading lines from a file tux.tango@gmail.com
Reading lines from a file <tux.tango@gmail.com>
Re: Reading lines from a file <glex_no-spam@qwest-spam-no.invalid>
Re: Reading lines from a file <jurgenex@hotmail.com>
Re: Reading lines from a file <tadmc@seesig.invalid>
Re: Reading lines from a file <1usa@llenroc.ude.invalid>
Re: Reading lines from a file <1usa@llenroc.ude.invalid>
Uninstall a module with/without cpan shell <steinbach@gmx-topmail.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Feb 2009 19:23:39 -0700
From: Howard Brazee <howard@brazee.net>
Subject: Re: * Obama's wife Naked
Message-Id: <8am9p49kjltnlb3dn57an791h6tfj1t0q8@4ax.com>
On Wed, 11 Feb 2009 17:43:22 -0800 (PST), albundy2@mailinator.com
wrote:
>
>· Pretty women make us BUY bear. Ugly women make us DRINK beer.
And they're all better than their alternatives.
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
A pretty woman makes her husband look small
And very often causes his downfall
As soon as he married her and then she starts
To do the things that will break his heart
But if you make an ugly woman your wife
A-you'll be happy for the rest of your life
An ug-a-ly woman cooks meals on time
And she'll always give you peace of mind
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
[Sax solo]
Don't let your friends say you have no taste
Go ahead and marry anyway
Though her face is ugly, her eyes don't match
Take it from me, she's a better catch
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
[Spoken:]
Say man!
Hey baby!
I saw your wife the other day!
Yeah?
Yeah, an' she's ug-leeee!
Yeah, she's ugly, but she sure can cook, baby!
Yeah, alright!
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
If you wanna be happy for the rest of your life
Never make a pretty woman your wife
So for my personal point of view
Get an ugly girl to marry you
--
"In no part of the constitution is more wisdom to be found,
than in the clause which confides the question of war or peace
to the legislature, and not to the executive department."
- James Madison
------------------------------
Date: Thu, 12 Feb 2009 20:37:16 -0800 (PST)
From: Too_Many_Tools <too_many_tools@yahoo.com>
Subject: Re: * Obama's wife Naked
Message-Id: <99fe00b0-4f8d-480f-9da5-ce742b8cd44d@j8g2000yql.googlegroups.com>
On Feb 11, 2:17=A0pm, thenth...@gmail.com wrote:
> Get ithttp://imival.blogspot.com/- Photos of Obamas wife naked! We
> will keep this our little secret amazing! archive of private movies
> and all kinds of sexual positions. You must see her with her batman
> utility belt its quite the movie. =A0A must watch. =A0Voted for change an=
d
> thats all I got :(.)
Got any of those Rush nudes?
------------------------------
Date: Thu, 12 Feb 2009 23:12:39 -0500
From: Cliff MacGillivray <cliff@excite.com>
Subject: Re: [OT] Programmers (UK)...?
Message-Id: <gn2rvu$bcp$1@aioe.org>
Uri Guttman wrote:
>>>>>> "CM" == Cliff MacGillivray <cliff@excite.com> writes:
>
> CM> Uri Guttman wrote:
> >>>>>>> "TJM" == Tad J McClellan <tadmc@seesig.invalid> writes:
> TJM> If you knew anything about usenet you would know that
> >> mentioning
> TJM> your line of business in a .sig is perfectly acceptable.
> >> best to ignore this troll (as with all trolls). he has stalked me on
> >> irc
> >> as well. not sure why i am his target but he also defended moronzilla
> >> too which says a lot.
> >> >> it wasn't spam.
> >> >> Yes, it was. it is stalking by this troll. he will deny it.
> >> as for my being unemployed, one of my businesses is helping others
> >> get
> >> employed. kind of ironic for the troll to point at that. i am gainfully
> >> employed by myself and have been for many successful years.
> CM> Well, a little bird tells me that you got shitcanned from
> CM> Athena for gross incompetence. There may have been some personal
>
> amusing. i wouldn't have wanted to stay there.
"I wouldn't have wanted those grapes anyway, I am sure they were sour."
ha ha ha ha. Pathetic.
> i finished up my contract
> there and we mutually agreed to not continue. no firing ever
> happened. you don't know athena at all. nor do you know their codebase
> and development culture.
Sure I do. They need people that work, not people that sit around all
day stuffing their faces.
and you also don't know perl. seems like there
> is a lot you don't know.
Keep fooling yourself asshat. Keep fooling yourself...
> like you really want a perl job and care? you are just a stalker who has
> no perl skills. go find moronzilla and form a cult of 2 member. have
> fun!
A fat worthless piece of shit like you has more than two enemies.
> as for perlhunter, it is doing just fine. not much you can find out
> about the actual business so you have to lie.
Yes, clearly perhunter is doing so well you don't need to have a
professional looking webpage. Or even one that looks like it wasn't
designed as an elementary school class project.
------------------------------
Date: Thu, 12 Feb 2009 20:40:31 +0100
From: Marc Lucksch <perl@marc-s.de>
Subject: Re: A good data structure to store INI files.
Message-Id: <gn1tv4$1m6r$1@ariadne.rz.tu-clausthal.de>
Brad Baxter schrieb:
> Marc Lucksch wrote:
>> I want it more like:
>>
>> $ini->{Ship}->[2]->{"fuse"}->[1]=["fusename",0,10];
>
> I think this would accomplish that. I doubt you really
> care about retaining the order of the keys.
I do care about that because the fuses for example have to be in order,
otherwise you get a critical from the game.
Currently I'm writing on a datastructure to represent all .ini files I
know of and write them out again unchanged (except for whitespace).
The whole point is it being easy to use (for now, speed comes later)
So if there is only one fuse and one ship and fuse in only one value:
print $ini->{Ship}->{fuse}.
Or if there are mulitple fuses:
print $ini->{Ship}->{fuse}; #Gets the first
print $ini->{Ship}->{fuse}->[1]; #Gets the second.
But that code shouldn't just break on two Ship's or 500 Ship's, so
without an following arrayref, it just gets the first.
This even works this way:
$ini->[0] #First section, returns {key,value}
pop @$ini; #remove the last entry, whatever key also returns {key,value}
pop @{$ini->{Ship}} # Remove the last ship and fetch it.
my $value=Data::INI->new();
push @{$ini->{ship}},$value; #Yes 'ship' is written small on purpose.
pop @{$ini->{Ship}} ( =$value ) #yes 'Ship' is ucfirst on purpose.
push @{$ini->{ship}},$value;
pop @$ini; ( ={ship=>$value} )
Same of course for keys of those sections.
Because there are in my opionion two ways to look at this data, as a
hash with keys (multiple or not) unordered or as an array of hashes with
one entry which are in the right order. Both have pros and cons, that's
why I think I want both of them.
> In your case, I think you need to separate the general
> case of reading/writing ini files from your specific
> needs. That is, read the configuration file into
> whatever structure works best for your program, whether
> or not that structure is general enough to work for
> any ini file. Then if you need to write the data
> back out, just make a routine for that.
Yes. Especially since there are two parsers (.ini and BINI) and to
writers (.ini and BINI).
But one thing: I don't want an structure for my program, I want the
best/easiest structure for someone using my lib.
Marc "Maluku" Lucksch
__DATA__
It looks somewhat like this: (Parser will be written later)
#Excerpt of 0_basic.t
use Data::INI;
my $ini=Data::INI->new();
$ini->{KEY}="Foo";
is($ini->{KeY}->[0]->[0],"Foo","Getting full key KEY");
is($ini->{KEy}->[0],"Foo","Getting half key KEY");
ok(exists $ini->{KEY},"KEY exists");
is($ini->{KEY},"Foo","Getting short key KEY");
ok(exists $ini->[0],"index 0 exists");
is($ini->[0]->[1],"Foo","Getting array index 0");
$ini->{KEY}->[0]="Bar";
#Same tests except Foo is now bar
#...
$ini->{Test}->[0]->[0]="foobar";
#tests to chech for foobar in Test
#$ini->{halfadd}=["foobar"];
#Same tests for halfadd
#Autovivification has to work as well:
my $ini=Data::INI->new();
$ini->{Foo}->[0]->{nickname}="test";
push @{$ini->{Bar}->{nickname}->[0]},"test2";
------------------------------
Date: Fri, 13 Feb 2009 04:30:42 +0200
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Adding path to @INC
Message-Id: <slrngp9mr3.kh3.whynot@orphan.zombinet>
On 2009-02-12, Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Peter Makholm wrote:
>> guru <guru.naveen@gmail.com> writes:
>>
>>> my $LINK_PATH = readlink("$CURR_PATH/source");
>>>
>>> BEGIN {
>>> push @INC,"$LINK_PATH";
>>> }
>>>
>>> source is softlink. path is read from this and trying to push to INC.
>>> Where I am going wrong.
>>
>> Everything you need to execute to set @INC should be put inside the
>> BEGIN block. So if you need to call readlink before setting @INC, then
>> do it in the BEGIN block and not just before the BEGIN-block.
>
> Optionally: Skip the BEGIN block. readlink() may not be known at compile
> time either, and it's a chance that files in $LINK_PATH are just
> require()d, not use()d.
Just noted that I<$CURR_PATH> should go in I<BEGIN> too (I doubt that OP
has C<source> directory in his root). (I suppose I<$CURR_PATH> has some
relations with B<cwd>. B<cwd> is in F<Cwd.pm>, what is unloaded yet
too.)
--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
------------------------------
Date: Thu, 12 Feb 2009 20:54:29 +0100
From: "Thomas Steinbach" <steinbach@gmx-topmail.de>
Subject: cpan config applypatch program
Message-Id: <gn1v52$8ln$03$1@news.t-online.com>
Hello NG,
if I run cpan client the first time.
There are some questions to configure
the cpan client.
What is the "applypatch" program?
Can't find this prog in the net
---snip---
Where is your applypatch program? [] _
---snap---
btw: not "patch" program. patch is
asked in a config step before. The
prog is named "applypatch" without
a space.
Thomas
------------------------------
Date: Thu, 12 Feb 2009 21:17:04 +0100
From: Marc Lucksch <perl@marc-s.de>
Subject: Re: cpan config applypatch program
Message-Id: <gn203k$1ni0$1@ariadne.rz.tu-clausthal.de>
Thomas Steinbach schrieb:
> What is the "applypatch" program?
> Can't find this prog in the net
How about CPAN?
http://search.cpan.org/~jv/makepatch-2.03/script/applypatch
But I think you can just leave it empty for now.
Marc "Maluku" Lucksch
------------------------------
Date: Fri, 13 Feb 2009 04:45:15 +0100
From: "Thomas Steinbach" <steinbach@gmx-topmail.de>
Subject: Re: cpan config applypatch program
Message-Id: <gn2qil$cmj$02$1@news.t-online.com>
Hello Marc,
>> What is the "applypatch" program?
>> Can't find this prog in the net
> How about CPAN?
>
> http://search.cpan.org/~jv/makepatch-2.03/script/applypatch
>
> But I think you can just leave it empty for now.
Thanx, didn't except that ;-)
But now - all programs are in place I still have problems
to get my perl (on windows) running and install packages
via the cpan shell. But I will post this problem in a new
thread.
Thomas
------------------------------
Date: Thu, 12 Feb 2009 20:19:55 +0000 (UTC)
From: Rahul <nospam@nospam.invalid>
Subject: cpan defaults on first use. Can I provide them in a non-interative format?
Message-Id: <Xns9BB091CB5BE366650A1FC0D7811DDBC81@85.214.105.209>
After I do a "yum install cpan" the first time around cpan insists on
asking all the questions about default's, preferred download hosts etc.
Is there a way to provide this info. in a non-interactive manner? I need
to do this on a bunch of similar machines.
--
Rahul
------------------------------
Date: Thu, 12 Feb 2009 21:53:37 +0100
From: Christian Winter <thepoet_nospam@arcor.de>
Subject: Re: cpan defaults on first use. Can I provide them in a non-interative format?
Message-Id: <49948c1f$0$31328$9b4e6d93@newsspool4.arcor-online.net>
Rahul wrote:
> After I do a "yum install cpan" the first time around cpan insists on
> asking all the questions about default's, preferred download hosts etc.
>
> Is there a way to provide this info. in a non-interactive manner? I need
> to do this on a bunch of similar machines.
You can simply overwrite the CPAN/Config.pm file, that's where
the config information is stored (the real functionality for
CPAN::Config is located in CPAN.pm itself, so it's safe.)
-Chris
------------------------------
Date: Thu, 12 Feb 2009 20:46:03 +0100
From: Marc Lucksch <perl@marc-s.de>
Subject: Re: dbi mysql problem with placeholders and the default keyword
Message-Id: <gn1u9g$1mfu$1@ariadne.rz.tu-clausthal.de>
Frank Seitz schrieb:
> david wrote:
>>
>> my $sth = $dbh->prepare('UPDATE A SET B = ? WHERE C = ?');
>> and then
>> $sth->execute('DEFAULT',1);
> A SQL placeholder stands for a value, not an expression.
>
Why not:
my $sth = $dbh->prepare('UPDATE A SET B = ".($default?"DEFAULT:"")."
WHERE C = ?');
Or on a per line base (I don't know it this works, someone test it (mysql)
my $sth = $dbh->prepare('UPDATE A SET B = IFNULL(?,DEFAULT) WHERE C = ?');
$sth->execute(undef,1); #undef instead of 'DEFAULT'
# Shouldn't SQL do this anyway using DEFAULT on NULL? (for
# NOTNULL columns)
or with 2 queries, calling the first on DEFAULT and the second on VALUE
my $sth = $dbh->prepare('UPDATE A SET B = ? WHERE C = ?');
my $sthdefault = $dbh->prepare('UPDATE A SET B = DEFAULT WHERE C = ?');
...
$value=1; #or whatever.
if ($default) {
$sthdefault->execute($value);
}
else {
$sthdefault->execute($someothervalue,$value);
}
Marc "Maluku" Lucksch
------------------------------
Date: Thu, 12 Feb 2009 22:33:39 +0100
From: Frank Seitz <devnull4711@web.de>
Subject: Re: dbi mysql problem with placeholders and the default keyword
Message-Id: <6vjitbFkb258U2@mid.individual.net>
Marc Lucksch wrote:
> Frank Seitz schrieb:
>> david wrote:
>>>
>>> my $sth = $dbh->prepare('UPDATE A SET B = ? WHERE C = ?');
>>> and then
>>> $sth->execute('DEFAULT',1);
>>
>> A SQL placeholder stands for a value, not an expression.
>
> Why not:
>
> my $sth = $dbh->prepare('UPDATE A SET B = ".($default?"DEFAULT:"")." WHERE C = ?');
Looks strange.
> Or on a per line base (I don't know it this works, someone test it (mysql)
>
> my $sth = $dbh->prepare('UPDATE A SET B = IFNULL(?,DEFAULT) WHERE C = ?');
> $sth->execute(undef,1); #undef instead of 'DEFAULT'
Nice idea but not allowed:
UPDATE [LOW_PRIORITY] [IGNORE] table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Thu, 12 Feb 2009 21:54:42 -0700
From: Larry Gates <larry@example.invalid>
Subject: Re: error printing page using LWP::Simple
Message-Id: <yp1gfa0ul1t2$.145l1ohnf4f9y$.dlg@40tude.net>
C:\MinGW\source>perl tree1.pl
2454875.70218
C:\MinGW\source>type tree1.pl
#!/usr/bin/perl
use warnings;
use strict;
use HTML::TreeBuilder;
use LWP::Simple;
my $site_url = 'http://www.fourmilab.ch/cgi-bin/Yoursky';
my $url_args = 'z=1&lat=35.0836&ns=North&lon=106.651&ew=West';
my $t = get "$site_url?$url_args" || "Problem";
my $tree = HTML::TreeBuilder->new_from_content($t);
foreach my $elem ( $tree->find_by_attribute('name', 'jd') ) {
print $elem->attr('value'), "\n";
}
# perl tree1.pl
C:\MinGW\source>
I spent alot of time looking for a module I already had, but I see what you
mean now.
I'm gonna get the same data underneath the collision.
--
larry gates
And other operators aren't so special syntactically, but weird
in other ways, like "scalar", and "goto".
-- Larry Wall in <199711071749.JAA29751@wall.org>
------------------------------
Date: Thu, 12 Feb 2009 22:20:31 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Getting the name of a variable reference
Message-Id: <fuje66-la2.ln1@osiris.mauzo.dyndns.org>
Quoth Dave Stallard <nomail@not.net>:
> So I have this handy function that is called like this
>
> setVar(\$someVar,$someValue);
>
> I use it to check and enforce consistency when multiple functions might
> want to set $someVar. It's defined something like this:
>
> sub setVar {
> my ($var,$value) = @_;
> my $cur = $$var;
> $$var = $value unless defined($cur);
> die "Mismatched value for $var: $cur vs. $value" unless $cur == $value;
> }
>
> The problem is I get this expression "<SCALAR-REF>#111" or whatever,
> instead of the variable name I want to appear in the die message. How
> do I get at the name?
The answer noone seems to want to give you is 'use PadWalker'. IMHO
producing decent diagnostics is one of the few occasions when finding
out what a variable is 'really' called is useful.
Not that I think that particular sub is a good idea, of course...
Ben
------------------------------
Date: Fri, 13 Feb 2009 04:52:00 +0100
From: "Thomas Steinbach" <steinbach@gmx-topmail.de>
Subject: Install a perl module to the main perl lib dir
Message-Id: <gn2r95$1e1$00$1@news.t-online.com>
Hello NG,
if I install new modules with the cpan
shell (windows), the modules will be installed
and stored under perldir/site/lib/[MODULE]
and not under perldir/lib/[MODULE] like the "base"
system which was installed after compiling perl
and use dmake install.
But if I look at ActiveStates Layout and
other diestributions, they have additional
modules installed under perldir/lib/[MODULE]
and _NOT_ under perldir/site/lib/[MODULE]
How they are made this? And Why?
Thomas
------------------------------
Date: Thu, 12 Feb 2009 15:16:26 -0800 (PST)
From: grocery_stocker <cdalten@gmail.com>
Subject: Question about why a pipe doesn't block
Message-Id: <7ec0712d-b39a-47db-a4e0-25bffd333c83@l39g2000yqn.googlegroups.com>
When I run the bbs system on my computer, I get the following
m-net% bbs
YAPP 3.1.1 Copyright (c)1995 Armidale Software
Registered to: Arbornet
Welcome to the
February General Conference
fairwitness: jerryr
22 newresponse items and 3 brandnew items
First item 1, last 46
Ok:
And the cursor just hangs at the block until I type exit. Now, when I
run the 'bbs program' using the following perl script
m-net% more bbs.pl
#!/usr/bin/perl
use strict;
use warnings;
open my $out, '|-', 'bbs' or die "cannot open pipe to bbs: $!";
#print $out "browse\n";
#close $out or die "cannot close pipe to t.exe: $!";
m-net% ./bbs.pl
The program runs and just exits.
YAPP 3.1.1 Copyright (c)1995 Armidale Software
Registered to: Arbornet
Welcome to the
February General Conference
fairwitness: jerryr
22 newresponse items and 3 brandnew items
First item 1, last 46
Now leaving February General...
m-net%
What is causing the script to exit? Even when I uncomment out close ,
I still get the exact same behavior
------------------------------
Date: 12 Feb 2009 23:45:01 GMT
From: xhoster@gmail.com
Subject: Re: Question about why a pipe doesn't block
Message-Id: <20090212185001.882$mK@newsreader.com>
grocery_stocker <cdalten@gmail.com> wrote:
...
>
> And the cursor just hangs at the block until I type exit. Now, when I
> run the 'bbs program' using the following perl script
>
> m-net% more bbs.pl
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> open my $out, '|-', 'bbs' or die "cannot open pipe to bbs: $!";
>
> #print $out "browse\n";
>
> #close $out or die "cannot close pipe to t.exe: $!";
> m-net% ./bbs.pl
>
> The program runs and just exits.
>
...
>
> What is causing the script to exit?
It ran out of code to execute. Why wouldn't it exit?
> Even when I uncomment out close ,
> I still get the exact same behavior
When perl runs out of code to execute, it starts doing the clean-up for
exit. As part of this, it closes the file handle, even if you didn't
explicitly request it. After doing so, it probably waits for the child to
exit, as it was a piped open. The bbs almost instantly sees that its input
has been closed, so it exits, satisfying Perl's wait so the wait blocks for
a teeny tiny time. Is this the blocking you were thinking of?
If not, what exactly did you think would block, and where and why do you
think it would do so?
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: Thu, 12 Feb 2009 14:21:37 -0800 (PST)
From: "olingaa@gmail.com" <olingaa@gmail.com>
Subject: question on de-referencing expressions
Message-Id: <f8668c72-f0c4-43f0-b6cb-a2c58320e340@k8g2000yqn.googlegroups.com>
Is there a way do this with one assignment so that the $hash_ref
variable is not necessary?
my $hash_ref = functionReturningReference();
my %hash = %$hash_ref;
------------------------------
Date: Thu, 12 Feb 2009 23:33:22 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: question on de-referencing expressions
Message-Id: <6vjm9qFkeu0tU1@mid.individual.net>
olingaa@gmail.com wrote:
> Is there a way do this with one assignment so that the $hash_ref
> variable is not necessary?
>
> my $hash_ref = functionReturningReference();
> my %hash = %$hash_ref;
my %hash = %{ functionReturningReference() };
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 12 Feb 2009 22:32:12 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: question on de-referencing expressions
Message-Id: <6vjmbcFk8fiuU1@mid.uni-berlin.de>
olingaa@gmail.com <olingaa@gmail.com> wrote:
> Is there a way do this with one assignment so that the $hash_ref
> variable is not necessary?
> my $hash_ref = functionReturningReference();
> my %hash = %$hash_ref;
my %hash = %{ functionReturningReference() };
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Thu, 12 Feb 2009 15:23:08 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: question on de-referencing expressions
Message-Id: <mnb9p45o0m74m96lpmmml1dlp8optas135@4ax.com>
"olingaa@gmail.com" <olingaa@gmail.com> wrote:
>Is there a way do this with one assignment so that the $hash_ref
>variable is not necessary?
>
>my $hash_ref = functionReturningReference();
>my %hash = %$hash_ref;
See "perldoc perlreftut",
Using References -> Use Rule 1
jue
------------------------------
Date: Thu, 12 Feb 2009 12:41:48 -0800 (PST)
From: tux.tango@gmail.com
Subject: Reading lines from a file
Message-Id: <fc0454af-a535-408c-9196-62642445ae96@z27g2000prd.googlegroups.com>
I have a text file that is somewhat structured. I can get the "first"
line from the file but not the others. I am not sure how to read all
the lines at the same time. If I check ($count % 8) == 2, I can get
the second lines, but I coundn't figuire out how to check it in the
same while loop.
#!/usr/bin/perl
use strict;
my $count = 0 ;
while(<DATA>) {
$count++ ;
if ( $count % 8 == 1) {
print "Title: $count $_ \n"; }
}
__END__
This is a title
This is a place
This is time
This is Age
This is Desciption
====
This is Title2
This is Place2
This is Time2
This is Age2
This is Description2
====
------------------------------
Date: Thu, 12 Feb 2009 12:57:46 -0800 (PST)
From: "tux.tango@gmail.com" <tux.tango@gmail.com>
Subject: Reading lines from a file
Message-Id: <34eb30e8-17bd-4508-a8d5-a51e61099f8b@w1g2000prk.googlegroups.com>
I have a text file that is somewhat structured. I can get the "first"
line from the file but not the others. I am not sure how to read all
the lines at the same time. If I check ($count % 8) == 2, I can get
the second lines, but I coundn't figuire out how to check it in the
same while loop.
#!/usr/bin/perl
use strict;
my $count = 0 ;
while(<DATA>) {
$count++ ;
if ( $count % 8 == 1) {
print "Title: $count $_ \n"; }
}
__END__
This is a title
This is a place
This is time
This is Age
This is Desciption
====
This is Title2
This is Place2
This is Time2
This is Age2
This is Description2
====
------------------------------
Date: Thu, 12 Feb 2009 15:57:19 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Reading lines from a file
Message-Id: <49949b40$0$48222$815e3792@news.qwest.net>
tux.tango@gmail.com wrote:
> I have a text file that is somewhat structured. I can get the "first"
> line from the file but not the others. I am not sure how to read all
> the lines at the same time.
Usually you don't need to do that.
See: File::Slurp
perldoc -q "How can I read in an entire file all at once?"
> If I check ($count % 8) == 2, I can get
> the second lines, but I coundn't figuire out how to check it in the
> same while loop.
Check it how? $_ will contain the information.
I'm not sure what you're after, but the following, might help
show you how to print the lines containing 'title' (ignoring case):
while(<DATA>)
{
print if /title/i;
}
>
>
> #!/usr/bin/perl
> use strict;
>
> my $count = 0 ;
> while(<DATA>) {
> $count++ ;
> if ( $count % 8 == 1) {
> print "Title: $count $_ \n"; }
> }
>
>
> __END__
> This is a title
> This is a place
> This is time
> This is Age
>
> This is Desciption
> ====
>
> This is Title2
> This is Place2
> This is Time2
> This is Age2
>
> This is Description2
> ====
------------------------------
Date: Thu, 12 Feb 2009 14:22:57 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Reading lines from a file
Message-Id: <hq79p494s02rs08uck88qfjd899b4112ma@4ax.com>
tux.tango@gmail.com wrote:
>I have a text file that is somewhat structured. I can get the "first"
>line from the file but not the others. I am not sure how to read all
>the lines at the same time.
You can slurp a whole file by either reading the file into an array
instead of into a scalar or by changing the Input Record Separator (see
perldoc perlvar) to undef.
However typically there is rarely a need for that because most tasks can
be better handled line by line.
> If I check ($count % 8) == 2, I can get the second lines,
Why not use $., the Input Line Number (see perldoc perlvar)?
>but I coundn't figuire out how to check it in the
>same while loop.
I have no idea what you mean by this sub-sentence. What is "it". What do
you mean by "check". What do you want to check against what?
>#!/usr/bin/perl
>use strict;
>
>my $count = 0 ;
>while(<DATA>) {
>$count++ ;
>if ( $count % 8 == 1) {
>print "Title: $count $_ \n"; }
>}
>
>
>__END__
>This is a title
>This is a place
>This is time
>This is Age
>
>This is Desciption
>====
>
>This is Title2
>This is Place2
>This is Time2
>This is Age2
>
>This is Description2
>====
------------------------------
Date: Thu, 12 Feb 2009 16:46:45 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Reading lines from a file
Message-Id: <slrngp99ml.bud.tadmc@tadmc30.sbcglobal.net>
tux.tango@gmail.com <tux.tango@gmail.com> wrote:
> I have a text file that is somewhat structured.
You mean each record ends with 4 equal signs and a newline?
> I am not sure how to read all
> the lines at the same time.
---------------------------------
#!/usr/bin/perl
use warnings;
use strict;
local $/ = "====\n";
while ( <DATA> ) {
chomp;
print "===>$_<===\n\n";
}
__DATA__
This is a title
This is a place
This is time
This is Age
This is Desciption
====
This is Title2
This is Place2
This is Time2
This is Age2
This is Description2
====
---------------------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Fri, 13 Feb 2009 02:49:17 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Reading lines from a file
Message-Id: <Xns9BB0DDFA48BFAasu1cornelledu@127.0.0.1>
"tux.tango@gmail.com" <tux.tango@gmail.com> wrote in news:34eb30e8-17bd-
4508-a8d5-a51e61099f8b@w1g2000prk.googlegroups.com:
> I have a text file that is somewhat structured. I can get the "first"
> line from the file but not the others. I am not sure how to read all
> the lines at the same time. If I check ($count % 8) == 2, I can get
> the second lines, but I coundn't figuire out how to check it in the
> same while loop.
>
>
> #!/usr/bin/perl
> use strict;
You need use warnings here.
> my $count = 0 ;
You do not need $count. Use the special variable $. See perldoc perlvar.
> while(<DATA>) {
> $count++ ;
> if ( $count % 8 == 1) {
> print "Title: $count $_ \n"; }
> }
I am not sure what you are trying to do. Are you just trying to grab
specific lines? Are you trying to process the file block by block? Have
you seen the posting guidelines?
Is this what you want?
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @data;
{
local $/ = "\n====\n\n";
while ( my $record = <DATA> ) {
chomp $record;
my %item;
@item{ qw( title place time age description )}
= (split /\n/, $record, 6)[0 .. 3, 5];
push @data, \%item;
}
}
print Dumper \@data;
__DATA__
This is a title
This is a place
This is time
This is Age
This is Desciption
====
This is Title2
This is Place2
This is Time2
This is Age2
This is Description2
====
This is Title3
This is Place3
This is Time3
This is Age3
Here is
a multiline
description
====
C:\DOCUME~1\asu1\LOCALS~1\Temp> t
$VAR1 = [
{
'time' => 'This is time',
'place' => 'This is a place',
'title' => 'This is a title',
'description' => 'This is Desciption',
'age' => 'This is Age'
},
{
'time' => 'This is Time2',
'place' => 'This is Place2',
'title' => 'This is Title2',
'description' => 'This is Description2',
'age' => 'This is Age2'
},
{
'time' => 'This is Time3',
'place' => 'This is Place3',
'title' => 'This is Title3',
'description' => 'Here is
a multiline
description',
'age' => 'This is Age3'
}
];
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Fri, 13 Feb 2009 02:51:35 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Reading lines from a file
Message-Id: <Xns9BB0DE5E6739Basu1cornelledu@127.0.0.1>
"tux.tango@gmail.com" <tux.tango@gmail.com> wrote in news:34eb30e8-17bd-
4508-a8d5-a51e61099f8b@w1g2000prk.googlegroups.com:
<snip>
Why did you post the same question twice within 16 minutes of each other?
I now see that Tad gave you basically the same answer I did so I wasted my
time.
Bye.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
Date: Fri, 13 Feb 2009 04:44:24 +0100
From: "Thomas Steinbach" <steinbach@gmx-topmail.de>
Subject: Uninstall a module with/without cpan shell
Message-Id: <gn2qim$gdo$01$1@news.t-online.com>
Hello NG,
How can I unistall a module from/within or
without the cpan shell? There is no such
an option...
For example:
After I compiled perl (win32) and installed the
base "system" there is a module
Module::Build::Platform::Amiga
and I think I never will need or use
this module. How can I remove it?
Thomas
------------------------------
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 V11 Issue 2207
***************************************