[24930] in Perl-Users-Digest
Perl-Users Digest, Issue: 7180 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 27 00:06:49 2004
Date: Sun, 26 Sep 2004 21:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 26 Sep 2004 Volume: 10 Number: 7180
Today's topics:
best way to search perldocs (wana)
Re: best way to search perldocs <mritty@gmail.com>
Re: best way to search perldocs <rob_gamble99@hotmail.com>
Re: Continous Looping of a List <postmaster@castleamber.com>
Re: DBI::ODBC Remote Login to Server <matthew.garrish@sympatico.ca>
Re: Defining 3D array <karl@lowth.com>
Re: Is it possible to embed perl inside a shell script <abigail@abigail.nl>
Re: Is it possible to embed perl inside a shell script <abigail@abigail.nl>
Re: Is it possible to embed perl inside a shell script <abigail@abigail.nl>
Re: Is it possible to embed perl inside a shell script <abigail@abigail.nl>
Re: Is it possible to embed perl inside a shell script <william@wilbur.25thandClement.com>
Re: path delimiter in windows platform("/" could change <end@dream.life>
Re: path delimiter in windows platform("/" could change <usa1@llenroc.ude.invalid>
Re: path delimiter in windows platform("/" could change <jwkenne@attglobal.net>
Re: Perl-5.8-win32-bin-0.8.exe installation fails <see@sig.invalid>
Precedence of exponentiation <nemo@weathersong.net>
Re: Precedence of exponentiation <kalinaubears@iinet.net.au>
references to filehandle? <stfhostf@kartos.de>
Re: references to filehandle? <usa1@llenroc.ude.invalid>
Retrieving cookies from a webserver <pvdberger@xs4all.nl>
Re: Retrieving cookies from a webserver <usa1@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 26 Sep 2004 18:52:49 -0700
From: ioneabu@yahoo.com (wana)
Subject: best way to search perldocs
Message-Id: <bf0b47ca.0409261752.c73b2b1@posting.google.com>
I was disconnected from the internet and had no access to my books
today, but I did have access to all of the perldocs saved on my
computer to look through. I was trying to find a way to change pwd
from a script.
I just wanted to write the most simple little thing to change
directories and list the contents. I never really learned shell
programming and I like to try to do everything with Perl these days.
Once I reconnected, I instantly found chdir with a simple Google
search. I wish I had Google to look through my perldocs though.
Question: How could I have found this command more easily in perldocs?
I was going crazy grepping through perltoc hopelessly to the point
where I was sure that there was no way to do it. By the way, why
doesn't system("cd $ARGV[0]") work?
Thanks!
------------------------------
Date: Sun, 26 Sep 2004 21:57:57 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: best way to search perldocs
Message-Id: <cj7s40$jtr$1@misc-cct.server.rpi.edu>
wana wrote:
> I was disconnected from the internet and had no access to my books
> today, but I did have access to all of the perldocs saved on my
> computer to look through. I was trying to find a way to change pwd
> from a script.
>
> I just wanted to write the most simple little thing to change
> directories and list the contents. I never really learned shell
> programming and I like to try to do everything with Perl these days.
>
> Once I reconnected, I instantly found chdir with a simple Google
> search. I wish I had Google to look through my perldocs though.
>
> Question: How could I have found this command more easily in perldocs?
> I was going crazy grepping through perltoc hopelessly to the point
> where I was sure that there was no way to do it. By the way, why
> doesn't system("cd $ARGV[0]") work?
perldoc perlfunc
"Functions sorted by category". Find one that looks likely, and then do
perldoc -f <function>
to read about it.
Paul Lalli
------------------------------
Date: Sun, 26 Sep 2004 22:19:30 -0400
From: Robert Gamble <rob_gamble99@hotmail.com>
Subject: Re: best way to search perldocs
Message-Id: <pan.2004.09.27.02.19.30.64815@hotmail.com>
On Sun, 26 Sep 2004 18:52:49 -0700, wana wrote:
> I was disconnected from the internet and had no access to my books
> today, but I did have access to all of the perldocs saved on my computer
> to look through. I was trying to find a way to change pwd from a
> script.
>
> I just wanted to write the most simple little thing to change
> directories and list the contents. I never really learned shell
> programming and I like to try to do everything with Perl these days.
>
> Once I reconnected, I instantly found chdir with a simple Google search.
> I wish I had Google to look through my perldocs though.
>
> Question: How could I have found this command more easily in perldocs?
> I was going crazy grepping through perltoc hopelessly to the point
> where I was sure that there was no way to do it.
pdldoc provides apropos-like searching of the perldocs.
> By the way, why doesn't system("cd $ARGV[0]") work?
What happens here is a child process is created to run a shell which in
turn runs your cd command. The shell then exits and control is returned
to your program. Changing the working directory of a child process does
not affect the working directory of the parent process.
> Thanks!
Rob Gamble
------------------------------
Date: 26 Sep 2004 23:05:57 GMT
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Continous Looping of a List
Message-Id: <Xns9570B819B16Fcastleamber@130.133.1.4>
Paul Lalli <mritty@gmail.com> wrote in
news:cj2bgs$sk$3@misc-cct.server.rpi.edu:
> John Bokma wrote:
>> A smart compiler removes tail recursion, so in many cases your
>> "probably not" is wrong. (This is a case of tail recursion, btw).
>>
>
> I don't understand what you mean by this. Can you please explain?
sub something {
:
:
something();
}
This is called tail recursion. A "smart" compiler can rewrite this.
http://www.program-transformation.org/Transform/TailRecursionElimination
<http://www.google.com/search?q=tail+recursion+elimination>
Hence, it's not expensive.
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sun, 26 Sep 2004 15:02:14 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: DBI::ODBC Remote Login to Server
Message-Id: <RmE5d.99$tT2.75304@news20.bellglobal.com>
"Fred Goldberg" <ackcomm@comcast.net> wrote in message
news:Xns95704EB29E018fredackcommcom@216.196.97.142...
> "Matt Garrish" <matthew.garrish@sympatico.ca> wrote in
> news:uep5d.36906$pA.2434554@news20.bellglobal.com:
>>
>> I think you need to take this question to a group that deals with MS
>> SQL and/or ODBC at this point. I can only tell you (having connected
>> to MS SQL servers at work from home) that you shouldn't need to take
>> any extra steps when setting up the ODBC source. You might want to
>> check with your database administrator and see if he/she has set up IP
>> blocking on the port to prevent anyone from connecting to the SQL
>> server from outside your office's computers. But that's just a stab in
>> the dark as to the source of the problem...
>>
>
> I know the firewall is not blocking this IP address. Otherwise, I
> wouldn't be able to access the server using this IP address and Remote
> Desktop. So, I'll try to look elsewhere for the solution. Again, thanks
> for all your assistance.
>
But you connect by remote desktop through a different port (3389 v. 1433 for
MS SQL). It's common practice to limit connections to certain ports for
security reasons (to prevent your mail server from being used for spam, for
instance). Hope you get it all sorted out, though.
Matt
------------------------------
Date: Sun, 26 Sep 2004 18:17:24 GMT
From: "Karl Lowth" <karl@lowth.com>
Subject: Re: Defining 3D array
Message-Id: <UID5d.348$FA.221@newsfe1-win.ntli.net>
Try
$schedule[0]= [
["0", "0", "0","0"],
["0", "0", "0","0"],
];
$schedule[1]= [
["0", "0", "0","0"],
["0", "0", "0","0"],
];
Ie: change "=(" to "=[" and ");" to "];".
--
http://www.lowth.com/blist/-/4045/1 : The best perl scripting books
"Duke of Hazard" <squash@peoriadesignweb.com> wrote in message
news:2d21b838.0409171906.4d97b9a4@posting.google.com...
> I have searched google, but could not find an answer for how to define
> a 3D array manually. Here is the code:
>
> $schedule[0]= (
> ["0", "0", "0","0"],
> ["0", "0", "0","0"],
> );
>
> $schedule[1]= (
> ["0", "0", "0","0"],
> ["0", "0", "0","0"],
> );
>
> The problem is $schedule[$i][$j][$k] are all undefined for any values
> of i,j, and k?
>
> Thanks!
------------------------------
Date: 26 Sep 2004 22:56:08 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <slrnclei88.hv.abigail@alexandra.abigail.nl>
zzapper (david@tvisnospam.co.uk) wrote on MMMMXLI September MCMXCIII in
<URL:news:bl76l05pff9qqmg44sibp8qo511tskp011@4ax.com>:
"" Hi,
"" Many years ago I used to embed AWK into a shell script, I've tried doing this with Perl with limited
"" results
""
"" A perl oneliner works no problem
""
"" eg
""
"" #!/bin/bash
"" fred=$(perl -e 'for $i (1..4) { $j="goat$i"; print " billy$j"; }')
"" echo $fred
""
"" But I really want to write more complex perl programs.
Embedded AWK scripts are typically written as:
awk -options '
PROGRAM
' arguments
or
awk -options -f PROGRAM_FILE arguments
Embedded Perl scripts are typically written as:
perl -options -e '
PROGRAM
' arguments
or
perl -options PROGRAM_FILE arguments
Abigail
--
BEGIN {print "Just " }
INIT {print "Perl " }
END {print "Hacker\n"}
CHECK {print "another "}
------------------------------
Date: 26 Sep 2004 22:59:55 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <slrncleifb.hv.abigail@alexandra.abigail.nl>
zzapper (david@tvisnospam.co.uk) wrote on MMMMXLII September MCMXCIII in
<URL:news:qfp7l0tqnojih1a612npuhscu4v622h379@4ax.com>:
'' On 23 Sep 2004 19:33:28 GMT, wrote:
''
'' >At 2004-09-23 03:15PM, zzapper <david@tvisnospam.co.uk> wrote:
'' >> Hi,
'' >> Many years ago I used to embed AWK into a shell script, I've tried doing this with Perl with limited
'' >> results
'' >>
'' > #!/bin/bash
'' > perlscript='
'' > for $i (1..4) { $j="goat$i"; print " billy$j"; }
'' > # make the script as arbitrarily long as you like,
'' > # taking care to avoid single quotes
'' > my $string = q{a single quoted string};
'' > ...
'' > '
'' > fred=$(perl -e $perlscript)
'' > echo $fred
'' >
'' > # or just write your perl code "inline"
'' > out=`perl -e '
'' > # perl code here
'' > '`
'' Glenn,
'' That looks good, I wasn't sure before if a Perl one-liner didn't have certa
'' But if anyone could suggest a method which frees me of the single quote cons
'' a hereis method?
Most Unix shells do, but that's a question to ask in a group dealing with
whatever shell(s) you are using. That's not a Perl issue. In fact, you'd
deal with it in exactly the same way as with AWK (because it's neither a
Perl nor an AWK issue - it's a shell issue).
Abigail
P.S., Perl one-liners don't have limits, but lines in Usenet postings
certainly do. 80 is the absolute limit without being rude, while
72-75 is preferred.
--
@;=split//=>"Joel, Preach sartre knuth\n";$;=chr 65;%;=map{$;++=>$_}
0,22,13,16,5,14,21,1,23,11,2,7,12,6,8,15,3,19,24,14,10,20,18,17,4,25
;print@;[@;{A..Z}];
------------------------------
Date: 26 Sep 2004 23:04:37 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <slrncleio5.hv.abigail@alexandra.abigail.nl>
Shawn Corey (shawn.corey@sympatico.ca) wrote on MMMMXLI September
MCMXCIII in <URL:news:6HF4d.28604$bL1.1113545@news20.bellglobal.com>:
## zzapper wrote:
## 8< snipped
## > Any ideas?
##
## Yes, skip the shell and use Perl directly. Perl can do anything your
## shell can do, only better.
Not quite true. Certain things are easier in the shell than in Perl.
## It is also portable.
That's very debatable. Any (Unix) box has a shell, but not every machine
has Perl.
Here's something to ponder about: Perl's "Configure", which you need to
run to compile Perl, is written in shell - not in Perl.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: 26 Sep 2004 23:10:54 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <slrnclej3u.hv.abigail@alexandra.abigail.nl>
Shawn Corey (shawn.corey@sympatico.ca) wrote on MMMMXLII September
MCMXCIII in <URL:news:fBT4d.29143$bL1.1295007@news20.bellglobal.com>:
&& Tintin wrote:
&& 8< snipped
&& > Actually, it's very easy to justify using the shell as there are plenty of
&& > operations that are easier/better suited to a shell script.
&&
&& There are plenty of operations that are easier/better in Perl. Pattern
&& matching and arithmetic are two examples.
That's a far cry from your previous statement:
"Perl can do anything your shell can do, only better."
Abigail
--
print v74.117.115.116.32;
print v97.110.111.116.104.101.114.32;
print v80.101.114.108.32;
print v72.97.99.107.101.114.10;
------------------------------
Date: Sun, 26 Sep 2004 17:14:07 -0700
From: William Ahern <william@wilbur.25thandClement.com>
Subject: Re: Is it possible to embed perl inside a shell script say bash?
Message-Id: <fj2k22-jnt.ln1@wilbur.25thandClement.com>
zzapper <david@tvisnospam.co.uk> wrote:
> Hi,
> Many years ago I used to embed AWK into a shell script, I've tried doing
> this with Perl with limited results
#!/bin/sh
function exec_perl {
perl <<-'EOP'
sub do_print {
print <<'EOF'
This is printed from perl.
EOF
}
&do_print;
EOP
cat <<-EOL
This is printed from the shell.
EOL
}
exec_perl;
------------------------------
Date: Mon, 27 Sep 2004 09:10:08 +0800
From: Alont <end@dream.life>
Subject: Re: path delimiter in windows platform("/" could change to "\"?)
Message-Id: <4158670e.59929671@130.133.1.4>
"A. Sinan Unur" <1usa@llenroc.ude.invalid>Wrote at 26 Sep 2004
16:53:17 GMT:
>
>Huh? Do you realize that in the example you give, it does not matter what
>slash you are using? In the cmd.exe shell, regardless of the slash, you
>need to enclose file paths that include space in double quotation marks.
>On the other hand,
>
>"c:/Program Files/Internet Explorer/iexplore.exe"
>
>works just fine (i.e. runs Internet Explorer).
My question is "Windows" not "Dos", if you open a file from Windows
"Common Dialog Box" it must fail
--
Your fault as a Government is My failure as a Citizen.
------------------------------
Date: 27 Sep 2004 03:09:06 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: path delimiter in windows platform("/" could change to "\"?)
Message-Id: <Xns9570EBB23672Basu1cornelledu@132.236.56.8>
Alont <end@dream.life> wrote in news:4158670e.59929671@130.133.1.4:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid>Wrote at 26 Sep 2004
> 16:53:17 GMT:
>>
>>Huh? Do you realize that in the example you give, it does not matter
>>what slash you are using? In the cmd.exe shell, regardless of the
>>slash, you need to enclose file paths that include space in double
>>quotation marks. On the other hand,
>>
>>"c:/Program Files/Internet Explorer/iexplore.exe"
>>
>>works just fine (i.e. runs Internet Explorer).
>
> My question is "Windows" not "Dos", if you open a file from Windows
> "Common Dialog Box" it must fail
1. Please quote properly. I did not write that message in response to your
original post but in response to
news:slrncldk2h.i8.wcitoan@wcitoan-via.supernews.com
2. cmd.exe is not DOS
3. Windows deals with / just fine
4. Why 'must'? Notepad on Win98 seems not to mind / if it is specified on
the command line whereas it fails to grok / if specified in the
File->Open dialog. OTOH, Start->Run or Word's File->Open has no problems.
On XP, I have not been able create a situation where / leads to problems.
Specific applications may have bugs. In that case, you should demand that
the bug be fixed. (By the way, I remember pointing out to you that EditPlus
is a supported product: <Xns954B80344CE38asu1cornelledu@132.236.56.8>. You
haven't avoided registering it, have you?)
Sinan.
------------------------------
Date: Mon, 27 Sep 2004 03:32:12 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: path delimiter in windows platform("/" could change to "\"?)
Message-Id: <0RL5d.709$NS1.754949@news4.srv.hcvlny.cv.net>
Alont wrote:
> "A. Sinan Unur" <1usa@llenroc.ude.invalid>Wrote at 26 Sep 2004
> 16:53:17 GMT:
>
>>Huh? Do you realize that in the example you give, it does not matter what
>>slash you are using? In the cmd.exe shell, regardless of the slash, you
>>need to enclose file paths that include space in double quotation marks.
>>On the other hand,
>>
>>"c:/Program Files/Internet Explorer/iexplore.exe"
>>
>>works just fine (i.e. runs Internet Explorer).
>
>
> My question is "Windows" not "Dos", if you open a file from Windows
> "Common Dialog Box" it must fail
That is a "feature" of the dialog box itself. The basic, nitty-gritty
file-opening code of Windows and DOS has accepted either "/" or "\" for
over twenty years, and if the dialog box weren't deliberately (and, in
my view, incorrectly) rejecting "/", it would work just fine.
--
John W. Kennedy
"Sweet, was Christ crucified to create this chat?"
-- Charles Williams. "Judgement at Chelmsford"
------------------------------
Date: Sun, 26 Sep 2004 14:19:08 -0400
From: Bob Walton <see@sig.invalid>
Subject: Re: Perl-5.8-win32-bin-0.8.exe installation fails
Message-Id: <4157063e$1_2@127.0.0.1>
Unknown Poster wrote:
> I've tried using the default the install program uses (which is
> windows\temp for some strange reason) or creating a new directory for
> the top-level. Either way, when I reach the "Configure" window, the
> "Perl directory:" and "Apache2 directory:" textboxes are already
> filled in as "..PERL/BIN". When I click the "Configure" button, this
> error box appears:
>
> "Perl configuation failed
>
> ! Please give the top-level Perl directory."
Please give more information: What is your platform (Windoze what?),
and whose Perl distribution is it? Sounds like it might be
apache.org's. If so, did you do what it says to do in
Perl-5.8-win32-bin-0.8.readme ?
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Mon, 27 Sep 2004 00:27:55 GMT
From: David Frauzel <nemo@weathersong.net>
Subject: Precedence of exponentiation
Message-Id: <1096244875.SwmN1svA7N7MUFMdSJ4pgw@teranews>
Rhetorical question.
Why does Perl give such high precedence to the exponentiation operator,
"**"?
perlop makes it very clear that -2**4 is equivalent to -(2**4), not (-2)
**4. So -2**4 gives you -16, not 16. So Perl facilitates people who
prefer unary operators to have less significance than binary operators,
which seems to be completely counter to the general rules of algebra.
But that's not why I'm asking the question, actually. What bugs me is
this:
2**-4
... gives you 2**(-4), not -(2**4). Looking at 2**-4, it seems obvious
that this should be the case, but it apparently defies the above stated
precedence rule. A token parser should recognize that the unary minus has
lower precedence than **, and push ** below the unary minus, in exactly
the same way it would with -2**4.
So, I'm left wondering if the Perl parser is actually going out of its
way to make sure that a unary minus on the right side of binary
exponentiation is given higher precedence than exponentiation, while on
the left side, it has lower precedence. Clearly, if that is indeed the
case, Perl is going out of its way to make sure that -2**4 arbitrarily
works one way, and 2**-4 works another. The double standard, coupled with
the illogical precedence to begin with, smells of some onerous backwards
compatibility that probably isn't even relevant any longer.
In building a token parser based on Perl, I am tempted to altogether
abandon this peculiar behavior, and give binary exponentiation the
precedence it seems to rightly deserve: lower than unary minus.
------------------------------
Date: Mon, 27 Sep 2004 12:59:14 +1000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Precedence of exponentiation
Message-Id: <41578337$0$12891$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
David Frauzel wrote:
>
> perlop makes it very clear that -2**4 is equivalent to -(2**4), not (-2)
> **4. So -2**4 gives you -16, not 16.
I think this is so that something like '17 - 2 ** 4' evaluates to 1 ...
which is certainly what I would want it to evaluate to. Without that
precedence, wouldn't '17 - 2 ** 4' evaluate to 50625 (ie 15 ** 4) ?
When I see an expression like '17 - 2 ** 4' I think '17 - (2 ** 4)', not
'(17 -2) ** 4'. If you really want to raise -2 to the 4th power write
it as (-2) ** 4.
That's the nice thing about precedence - if you don't like it the way it
is, it's very easy to override :-)
Similarly, I don't think I would ever want 2 ** -4 to evaluate to -16.
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Mon, 27 Sep 2004 02:47:38 GMT
From: Stefan H. <stfhostf@kartos.de>
Subject: references to filehandle?
Message-Id: <8qvel05j41ddn56hp9642o9dki10dlpoi9@4ax.com>
the first field of my data is the _name_ of the measure.
I need to create from the big file one file per measure containing only
data from that measure. The name of each file must be the same of
measure: ie
bigfile.csv
123 rms 12 132
2312 qrt 12 231
2342 sse 12 231
rms.csv
123 rms 12 132
qrt.csv
2342 sse 12 231
the measure names are changing in name and number, then I cannot code
it. I'd like to do
sub split_measures {
my (%splits);
for (<MYFILE>) {
$splits{[split /;/]->[1]} = '';
}
for (keys %splits) {
open $_, ">$_.csv";
}
for (<MYFILE>) {
print [split /;/;]->1 $_;
}
the error I get is that "strict refs" doesn't permit that. Why? It's
safe to remove that clause? Is there a better way to do that?
Thanks
Stefan
------------------------------
Date: 27 Sep 2004 03:29:11 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: references to filehandle?
Message-Id: <Xns9570EF19DAC7Dasu1cornelledu@132.236.56.8>
Stefan H. <stfhostf@kartos.de> wrote in
news:8qvel05j41ddn56hp9642o9dki10dlpoi9@4ax.com:
> the first field of my data is the _name_ of the measure.
Actually, looking at the lines below, it looks like the second field is the
name of the measure, whatever that might mean.
>
> I need to create from the big file one file per measure containing only
> data from that measure. The name of each file must be the same of
> measure: ie
>
> bigfile.csv
> 123 rms 12 132
> 2312 qrt 12 231
> 2342 sse 12 231
>
> rms.csv
> 123 rms 12 132
>
> qrt.csv
> 2342 sse 12 231
>
> the measure names are changing in name and number, then I cannot code
> it. I'd like to do
>
> sub split_measures {
>
> my (%splits);
>
> for (<MYFILE>) {
> $splits{[split /;/]->[1]} = '';
> }
Ahem ... I do not see anything that is separated using ;
>
> for (keys %splits) {
> open $_, ">$_.csv";
> }
>
> for (<MYFILE>) {
> print [split /;/;]->1 $_;
> }
Whoa!
D:\Home\test> perl -c s.pl
Number found where operator expected at s.pl line 14, near "->1"
(Missing operator before 1?)
Scalar found where operator expected at s.pl line 14, near "1 $_"
(Missing operator before $_?)
syntax error at s.pl line 14, near "/;/;"
Missing right curly or square bracket at s.pl line 17, at end of line
s.pl had compilation errors.
Did you actually run this thing? You should always post a short, self-
contained script others can run to see what is going on.
> the error I get is that "strict refs" doesn't permit that. Why? It's
> safe to remove that clause? Is there a better way to do that?
This is how I might do it:
use strict;
use warnings;
while(<DATA>) {
chomp;
if(my @fields = /^\s*(\d+)\s+(\w+)\s+(\d+)\s+(\d+)\s*$/) {
# Using '>>' so as to account for multiple
# lines for a given measure
if(open my $out, '>>', "$fields[1].csv") {
print $out "@{[ join ';', @fields ]}\n";
} else {
warn "Cannot open $fields[1].csv: $!";
}
}
}
__DATA__
123 rms 12 132
2312 qrt 12 231
2342 sse 12 231
__END__
Sinan.
------------------------------
Date: Mon, 27 Sep 2004 00:47:58 +0200
From: "Peter v.d. Berger" <pvdberger@xs4all.nl>
Subject: Retrieving cookies from a webserver
Message-Id: <4157452f$0$78772$e4fe514c@news.xs4all.nl>
Hello all,
I wrote a simple perl-script using Libwhisker to retrieve a plain html file
from a website (on a remote webserver) to view some stats of that site.
The website uses cookies, and i found out these cookies contain useful
information for me. Now I also want to retrieve (and print) the first cookie
the server sends me (the 'client').
Main problem: I'm not a Perl-guru, and i can't find any clear documentation
about retrieving cookies when you're simulating a webbrowser with a
perl-script.
My question: can someone point me to some clear documentation, or even give
me some info or an example on how to do this?
Kind regards,
Peter
------------------------------
Date: 26 Sep 2004 23:40:34 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Retrieving cookies from a webserver
Message-Id: <Xns9570C857FDB55asu1cornelledu@132.236.56.8>
"Peter v.d. Berger" <pvdberger@xs4all.nl> wrote in
news:4157452f$0$78772$e4fe514c@news.xs4all.nl:
> Main problem: I'm not a Perl-guru, and i can't find any clear
> documentation about retrieving cookies when you're simulating a
> webbrowser with a perl-script.
http://www.perldoc.com/perl5.8.0/lib/lwpcook.html
Sinan
------------------------------
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 7180
***************************************