[22515] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4736 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 20 18:06:02 2003

Date: Thu, 20 Mar 2003 15:05:07 -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, 20 Mar 2003     Volume: 10 Number: 4736

Today's topics:
        Am I asking too much of "map"? (Sara)
    Re: Am I asking too much of "map"? <goldbb2@earthlink.net>
    Re: Am I asking too much of "map"? <grazz@nyc.rr.com>
    Re: Am I asking too much of "map"? <kkeller-spammmm@wombat.san-francisco.ca.us>
    Re: Am I asking too much of "map"? <tassilo.parseval@rwth-aachen.de>
    Re: Am I asking too much of "map"? <uri@stemsystems.com>
        Chopping of everything after a certain word <babydesmet@hotmail.com>
    Re: Chopping of everything after a certain word <ben_altman@deadspam.com>
        creating an error box <ben_altman@deadspam.com>
    Re: getOpenFile with -initialdir <bb@removeriverslime.com>
        help (nonsparker)
    Re: help <jurgenex@hotmail.com>
    Re: How can I....? (Cyber Scorpion)
    Re: How can I....? <goldbb2@earthlink.net>
        How to use Net::FTP - FTP Client class (Joe Kamenar)
    Re: How to use Net::FTP - FTP Client class <bobx@linuxmail.org>
    Re: How to use Net::FTP - FTP Client class <jmcada@hotmail.com>
    Re: Merging log files using hash - good idea/possible? (Thomas)
    Re: Need a little help with a short script (HKVandal)
    Re: Open file and print out contents from array (Jacques Veldhuijzen)
        Perl querystring encoding  question (Robert Dodd)
        pulling datafrom database (ramesh)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 20 Mar 2003 13:02:25 -0800
From: genericax@hotmail.com (Sara)
Subject: Am I asking too much of "map"?
Message-Id: <776e0325.0303201302.16d626c9@posting.google.com>

I love the perl map function, in the words of the immortal "Butthead",
"It kicks ass!".. I commonly populate hashes from fields in arrays
with things like:

 my %h = map /(\d+)\s\w+\s(\w+)/, @array;

which snags columns 1 and 3 in a whitespace-delimited file and makes
col 1 the keys and col 3 the values. Spiffy! It can be made to work of
course on a number of these kinds of applications.

Something I cannot figure out however, is how to transpose the keys
and values. In other words, what if I wanted column 3 to be the KEY
and 1 the VALUE? Now we seem to have a problem, and historically I end
up operating with some sort of regex on a copy of the array to get
things in the right order, then applying map on the copy. Not too
pretty.

I'm well aware of myriad ways to create a new array with column 3
first, and other equally insipid solutions. What I wonder is, though,
can I corerce map into switching the KEYS and VALUES, some sort of $1
<> $2 transformation as part of this one expression? I don't want to
change my original array, just the order of the resultant array.


Thanks,
Gx


------------------------------

Date: Thu, 20 Mar 2003 16:24:16 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Am I asking too much of "map"?
Message-Id: <3E7A3180.E2E065A7@earthlink.net>

Sara wrote:
> 
> I love the perl map function, in the words of the immortal "Butthead",
> "It kicks ass!".. I commonly populate hashes from fields in arrays
> with things like:
> 
>  my %h = map /(\d+)\s\w+\s(\w+)/, @array;
> 
> which snags columns 1 and 3 in a whitespace-delimited file and makes
> col 1 the keys and col 3 the values. Spiffy! It can be made to work of
> course on a number of these kinds of applications.
> 
> Something I cannot figure out however, is how to transpose the keys
> and values. In other words, what if I wanted column 3 to be the KEY
> and 1 the VALUE?

   my %h = map (/(\d+)\s\w+\s(\w+)/)[1,0], @array;
or:
   my %h = map { (/(\d+)\s\w+\s(\w+)/)[1,0] } @array;
or:
   my %h = reverse map /(\d+)\s\w+\s(\w+)/, @array;
or:
   my %h;
   /(\d+)\s\w+\s(\w+)/ and $h{$2} = $1 for @array;

[all untested]

After testing that they work, you might want to benchmark these to see
which is fastest.

-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


------------------------------

Date: Thu, 20 Mar 2003 21:14:36 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Am I asking too much of "map"?
Message-Id: <0bqea.48$LJ2.127127@twister.nyc.rr.com>

Sara <genericax@hotmail.com> wrote:
> 
>  my %h = map /(\d+)\s\w+\s(\w+)/, @array;
> 
> which snags columns 1 and 3 in a whitespace-delimited file and 
> makes col 1 the keys and col 3 the values. Spiffy! It can be made 
> to work of course on a number of these kinds of applications.
> 
> Something I cannot figure out however, is how to transpose the 
> keys and values. In other words, what if I wanted column 3 to be 
> the KEY and 1 the VALUE?
> 

  $ perldoc -f reverse

But I'd probably use split/slice:

  my %h = map { (split)[3,1] } @array;

-- 
Steve


------------------------------

Date: Thu, 20 Mar 2003 13:22:39 -0800
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: Am I asking too much of "map"?
Message-Id: <vebd5b.l3a.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In article <776e0325.0303201302.16d626c9@posting.google.com>, Sara wrote:
> 
>  my %h = map /(\d+)\s\w+\s(\w+)/, @array;
> 
> I'm well aware of myriad ways to create a new array with column 3
> first, and other equally insipid solutions. What I wonder is, though,
> can I corerce map into switching the KEYS and VALUES, some sort of $1
><> $2 transformation as part of this one expression? I don't want to
> change my original array, just the order of the resultant array.

my %h = map { /$regexhere/; $h{$3}=$1 } @array;

?

- --keith

- -- 
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
public key:  http://wombat.san-francisco.ca.us/kkeller/kkeller.asc
alt.os.linux.slackware FAQ:  http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj56MR0ACgkQhVcNCxZ5ID+TZQCeNsm84le7aUpjxYDS72BDYrkB
SD4An0ileQ9xWD3mPUY1YKt3l3oflp16
=zvZv
-----END PGP SIGNATURE-----


------------------------------

Date: 20 Mar 2003 21:40:43 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Am I asking too much of "map"?
Message-Id: <b5dcgr$l8$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Benjamin Goldberg:

> Sara wrote:
>> 
>> I love the perl map function, in the words of the immortal "Butthead",
>> "It kicks ass!".. I commonly populate hashes from fields in arrays
>> with things like:
>> 
>>  my %h = map /(\d+)\s\w+\s(\w+)/, @array;
>> 
>> which snags columns 1 and 3 in a whitespace-delimited file and makes
>> col 1 the keys and col 3 the values. Spiffy! It can be made to work of
>> course on a number of these kinds of applications.
>> 
>> Something I cannot figure out however, is how to transpose the keys
>> and values. In other words, what if I wanted column 3 to be the KEY
>> and 1 the VALUE?
> 
>    my %h = map (/(\d+)\s\w+\s(\w+)/)[1,0], @array;
                 
This one confuses perl. You have to disambiguate it by adding a '+' or
so to the pair of parentesis.

> or:
>    my %h = map { (/(\d+)\s\w+\s(\w+)/)[1,0] } @array;
> or:
>    my %h = reverse map /(\d+)\s\w+\s(\w+)/, @array;
> or:
>    my %h;
>    /(\d+)\s\w+\s(\w+)/ and $h{$2} = $1 for @array;
> 
> [all untested]

And even reversing the match works:

    my %h = map { reverse /(\d+)\s\w+\s(\w+)/ } @array;

or getting rid of the block and possibly making it a little quicker:

    my %h = map +( reverse /(\d+)\s\w+\s(\w+)/ ), @array;
    
> After testing that they work, you might want to benchmark these to see
> which is fastest.

Here is one (might wrap):

               Rate   slice_b       for rev_match_b     slice rev_match  rev_map
slice_b     31109/s        --       -2%         -3%       -5%      -10%     -12%
for         31808/s        2%        --         -1%       -3%       -8%     -10%
rev_match_b 32117/s        3%        1%          --       -2%       -7%      -9%
slice       32675/s        5%        3%          2%        --       -6%      -8%
rev_match   34623/s       11%        9%          8%        6%        --      -2%
rev_map     35372/s       14%       11%         10%        8%        2%       --

with this code:

    use Benchmark qw(cmpthese);
    chomp( my @array = <DATA> );
    cmpthese (-2, {
            slice   => sub {
                my %h = map +(/(\d+)\s\w+\s(\w+)/)[1,0], @array;
            },
            slice_b => sub {    # <--- slowest
                my %h = map { (/(\d+)\s\w+\s(\w+)/)[1,0] } @array;
            },
            rev_map => sub {    # <--- this one is the winner !
                my %h = reverse map /(\d+)\s\w+\s(\w+)/, @array;
            },
            for     => sub {
                my %h;
                /(\d+)\s\w+\s(\w+)/ and $h{$2} = $1 for @array;
            },
            rev_match_b => sub {
                my %h = map { reverse /(\d+)\s\w+\s(\w+)/ } @array;
            },
            rev_match => sub {
                my %h = map +( reverse /(\d+)\s\w+\s(\w+)/ ), @array;
            },
        });
    __DATA__
    1234 asdasda 2345 asdasd 12345
    1234 asdasda 2345 asdasd 12345
    [ couple of times ... ]

The differences however aren't worth the bother.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


------------------------------

Date: Thu, 20 Mar 2003 22:32:39 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Am I asking too much of "map"?
Message-Id: <x7y939ekjd.fsf@mail.sysarch.com>

>>>>> "KK" == Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us> writes:

  KK> In article <776e0325.0303201302.16d626c9@posting.google.com>, Sara wrote:
  >> 
  >> my %h = map /(\d+)\s\w+\s(\w+)/, @array;
  >> 
  >> I'm well aware of myriad ways to create a new array with column 3
  >> first, and other equally insipid solutions. What I wonder is, though,
  >> can I corerce map into switching the KEYS and VALUES, some sort of $1
  >> <> $2 transformation as part of this one expression? I don't want to
  >> change my original array, just the order of the resultant array.

  KK> my %h = map { /$regexhere/; $h{$3}=$1 } @array;

  KK> ?

if you are not sure, why post a guess? that will assign a list of $1
values to %h after it has already assigned each key/val pair to it (and
later wiped out).

what you might have been thinking of is:

my %h = map { /$regexhere/; ($3, $1) } @array;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class


------------------------------

Date: Thu, 20 Mar 2003 20:22:52 GMT
From: "bandb" <babydesmet@hotmail.com>
Subject: Chopping of everything after a certain word
Message-Id: <wqpea.22132$Vq.1570@afrodite.telenet-ops.be>

Hello,

I have a maybe easy question, but haven't found the answer yet.

How can I make perl chop of everything that comes after a given word in a
data-entry?
E.g. blablabla/blablabla/work_this have to disappear has to become
blablabla/blablabla/

Who can help?
Thx,

P.
-------
http://www.blueandbroke.be




------------------------------

Date: Thu, 20 Mar 2003 15:39:50 -0500
From: Ben <ben_altman@deadspam.com>
Subject: Re: Chopping of everything after a certain word
Message-Id: <b5d8um$250vs9$1@ID-121117.news.dfncis.de>

bandb wrote:
> How can I make perl chop of everything that comes after a given word in a
> data-entry?
> E.g. blablabla/blablabla/work_this have to disappear has to become
> blablabla/blablabla/

$string = "blabablabl/blab/work_this...";
$word = "blab/";

$string =~ s/$word.*/$word/;

It will clobber more than one occurance of word.

regards,
Ben



------------------------------

Date: Thu, 20 Mar 2003 15:31:13 -0500
From: Ben <ben_altman@deadspam.com>
Subject: creating an error box
Message-Id: <b5d8ei$28e79d$1@ID-121117.news.dfncis.de>

Hi,

I have a perl script called by several applications that currently logs 
errors to a log (when one occurs) but does not inform the user about the 
error. What I would like to do is to pop up an error window that the 
user can click "ok" on aside from the logging of the error that is 
currently happening.


Can someone point me to what I would need to use to accomplish this?

Thanks,
Ben



------------------------------

Date: Thu, 20 Mar 2003 14:47:59 -0500
From: "Chris W" <bb@removeriverslime.com>
Subject: Re: getOpenFile with -initialdir
Message-Id: <b5d5t0$46h$1@bob.news.rcn.net>

cwd is giving you the latest used directory.  just give it the name of your
directory.  i think that you need to specify backslashes in the directory
name on windows (not sure about cygwin), forward slashes won't work.


"Pascal Zerwetz" <pzerwetz@yaccom.com> wrote in message
news:b5d0nk$24l6$1@biggoron.nerim.net...
> Hello
> First many thanks to Christian Winter!
> I am using perl/Tk in Cygwin, on W2k.
> When I open the getOpenFile dialog, even with use of Cwd and -initialdir =
> Cwd,
> the starting directory is the latest used.
> Can anyone tell me how can I force the initialdir, please ?
> Thank you.
> Pascal.
>
>




------------------------------

Date: 20 Mar 2003 11:40:37 -0800
From: ajc1234@yahoo.com (nonsparker)
Subject: help
Message-Id: <12ab8c2f.0303201140.59a88891@posting.google.com>

i need to know what is wrong with this script

#!/usr/bin/perl
&get_form_data;
&send_mail;


sub get_form_data
{
	#get the input
	read(STDIN, $buffer,$ENV{'CONTENT_LENGTH'} );
	
	#split the name-value pairs
	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs)
	{
		($name, $value) = split(/=/, $pair);
		
		# unwebify plus signs and %-encoding
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9] [a-fA-F0-9])/pack("C", hex($1))/eg;
		$value =~ s/<!--(.|\n) *-->//g;
		$FORM{$name} = $value;
	}
}
sub send_mail
{

	
	@to = ($FORM('options'));
	
	#open(MAIL, "|/usr/sbin/sendmail -t @to") || die("can't open
sendmail");
	print MAIL "If this email has come to you some on has filled out a
form on ghclc.org.  \nlook at the comments below and please respond
acordingly.";
	print MAIL "From: $FORM{'email'}\n";
	print MAIL "To: @to \n";
	print MAIL "Subject: $FORM{'type'}\n\n";
	print MAIL "Name: $FORM{'name'}\n";
	print MAIL "Email: $FORM{'email'}\n";
	print MAIL "Phone: $FORM{'phone'}\n";
	
	print MAIL "";
	print MAIL "Comments:\n $FORM{'comments'}\n\n";
	print MAIL "";
	#close(MAIL);
	#print "Location: http://ajcook.open-creations.com/clc/thank_you.html\n\n";
}


------------------------------

Date: Thu, 20 Mar 2003 22:48:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: help
Message-Id: <jzrea.43097$Ad6.10137@nwrddc01.gnilink.net>

nonsparker wrote:
> i need to know what is wrong with this script
>
> #!/usr/bin/perl

Well, for starters it is missing
    use strict;
    use warnings;

Aside of that there is nothing we could tell you because you didn't tell us
what you expect this script to do neither what it does instead.
For all we know this script does exactly what it is programmed to do.

jue




------------------------------

Date: 20 Mar 2003 12:15:10 -0800
From: cyberscorpion@mail.bg (Cyber Scorpion)
Subject: Re: How can I....?
Message-Id: <38d3b40.0303201215.4d4485@posting.google.com>

"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<ltkea.40939$Ad6.31776@nwrddc01.gnilink.net>...
> Cyber Scorpion wrote:
> > I want to compare 2 strings in case in-sensitive mode, but the strings
> > contain cyrillic characters (ascii code > 127 and < 255) and the
> > standart way does not work, i.e. the following code:
> >
> > if ($sdata =~ /$rdata/i)
> 
> That's not the standard way to begin with. First of all using REs to compare
> two strings is like using a shotgun to kill a fly. A fly swatter would be a
> more appropriate tool. And second what if $rdata contains characters which
> are special in REs? Let's say $rdata is the string '.*'?
> 
> If you want to compare two strings then you should use the string comparison
> operator.
> And if you want to compare them with ignore case then just convert both into
> a normal form, e.g. all upper case:
>     if (uc($data) eq uc($rdata))
> 
> jue

After reading the help of 'perllocale' I used this

use POSIX qw(locale_h);
setlocale(LC_ALL, "ISO8859-5");
print lc('This Òîâà å òåñò!!!');

for testing purpose only and the first part ('This' was converted to
'this', i.e. lowercase function works for latin charset, but the
remind part of the string 'Òîâà å òåñò' (It's bulgarian cyrillic text
representing 'This is a test' in English) remains unchanged in the
case (cyrillic 'T' was not changed to cyrillic 't').

In this situation 'if (uc($data) eq uc($rdata))' does not work too,
because the uc() function does not work with cyrillic chars. I am new
to perl programming, so please give me more advices!

P.S.
My English is very bad, so excuse me for that!


------------------------------

Date: Thu, 20 Mar 2003 15:41:15 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: How can I....?
Message-Id: <3E7A276B.2CF4F288@earthlink.net>

Cyber Scorpion wrote:
> 
> I want to compare 2 strings in case in-sensitive mode, but the strings
> contain cyrillic characters (ascii code > 127 and < 255) and the
> standart way does not work, i.e. the following code:
> 
> if ($sdata =~ /$rdata/i)
> {
> ....
> }
> 
> doesn't work. How can I do this? Please advice!

Convert both strings from ISO8859-5 into perl's native utf8 using either
the 'encoding' pragma, or a ":encoding(ISO8859-5)" perlio layer, or
subroutines from the Encode (or Encode::compat) module, or Text::IConv.

Then, you would do as normal:

   if( $sdata =~ /^\Q$rdata\E\z/i )
or:
   if( lc($sdata) eq lc($rdata) )
or:
   if( uc($sdata) eq uc($rdata) )

Where are $sdata and $rdata coming from?  Literal strings?  Files?  A
database?  (The answer to this question is to know what module will best
suit your needs for conversion).


-- 
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}


------------------------------

Date: 20 Mar 2003 13:32:26 -0800
From: joey19020@aol.com (Joe Kamenar)
Subject: How to use Net::FTP - FTP Client class
Message-Id: <fca4c27e.0303201332.233e7f54@posting.google.com>

Greetings,

I want to use the following sort of code in one of my scripts:

#!/usr/bin/perl
print "Content-type: text/html\n\n";

use Net::FTP;

    $ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 0);
    $ftp->login("nationuser",'xxxxxx');
    $ftp->cwd("/pub");
    $ftp->get("that.file");
    $ftp->quit;

exit;
When I run this, I get the following:

Can't call method "login" on an undefined value at C:\Perl\bin\test.pl
line 7.

Of course, the "xxxxx" string contains the real domain and password I
am using.
Must I install the ftp application into the Perl directory? If so,
where do I get it? All I find on a google search is documentation for
it, but not the code itself.


------------------------------

Date: Thu, 20 Mar 2003 21:54:29 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: How to use Net::FTP - FTP Client class
Message-Id: <pMqea.2721$FN.2116985@news2.news.adelphia.net>

"Joe Kamenar" <joey19020@aol.com> wrote in message
news:fca4c27e.0303201332.233e7f54@posting.google.com...
<snip>
> use Net::FTP;
>
>     $ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 0);
>     $ftp->login("nationuser",'xxxxxx');
>     $ftp->cwd("/pub");
>     $ftp->get("that.file");
>     $ftp->quit;
>
> exit;
> When I run this, I get the following:
>
> Can't call method "login" on an undefined value at C:\Perl\bin\test.pl
> line 7.
>
> Of course, the "xxxxx" string contains the real domain and password I
> am using.
> Must I install the ftp application into the Perl directory? If so,
> where do I get it? All I find on a google search is documentation for
> it, but not the code itself.

You do not need the "ftp" application, Perl does it all. I ran the script
through the Perl interpreter using "perl -cw test.pl" and it checks out so I
am not sure why you are having problems with it.




------------------------------

Date: Thu, 20 Mar 2003 21:54:50 GMT
From: "Josh McAdams" <jmcada@hotmail.com>
Subject: Re: How to use Net::FTP - FTP Client class
Message-Id: <KMqea.98$6Y.35595308@newssvr30.news.prodigy.com>

Your script was allowed to execute, so Perl must have found found Net::FTP.
Try temporarily turning debugging on {Debug=>1} to get some diagnostic
messages.  Also, it wouldn't hurst to permanently change your script to look
something like:

$ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 0) or die("Unable to
create ftp object");


"Joe Kamenar" <joey19020@aol.com> wrote in message
news:fca4c27e.0303201332.233e7f54@posting.google.com...
> Greetings,
>
> I want to use the following sort of code in one of my scripts:
>
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
>
> use Net::FTP;
>
>     $ftp = Net::FTP->new("ftp.fund.xxxxx.com", Debug => 0);
>     $ftp->login("nationuser",'xxxxxx');
>     $ftp->cwd("/pub");
>     $ftp->get("that.file");
>     $ftp->quit;
>
> exit;
> When I run this, I get the following:
>
> Can't call method "login" on an undefined value at C:\Perl\bin\test.pl
> line 7.
>
> Of course, the "xxxxx" string contains the real domain and password I
> am using.
> Must I install the ftp application into the Perl directory? If so,
> where do I get it? All I find on a google search is documentation for
> it, but not the code itself.




------------------------------

Date: 20 Mar 2003 11:13:16 -0800
From: tornell@hotmail.com (Thomas)
Subject: Re: Merging log files using hash - good idea/possible?
Message-Id: <24ae4e25.0303201113.967f50b@posting.google.com>

Paul wrote:
> If you were to go the scripted-merging route I suppose you could
> remove/change the identifying string which tells the software which
> server served which page, which should stop the problem. Hmm, but then
> you might lose useful information like one server being used less than
> the other/s because it has an intermittent problem that's not showing
> up yet. 

Well, that's always the problem when messing around with the logfiles,
you might loose some information. I think I will just continue to pay
WebTrends the server fees, even if it hurts, especially since I am
looking into to upgrading from "Webtrends Reporting Center E-Business
Edition" to "Enterprise Edition".

Regards, Thomas


------------------------------

Date: 20 Mar 2003 14:15:47 -0800
From: hkvandal@shackmail.com (HKVandal)
Subject: Re: Need a little help with a short script
Message-Id: <8dbe2cad.0303201415.6af7bba6@posting.google.com>

hkvandal@shackmail.com (HKVandal) wrote in message news:<8dbe2cad.0303192231.1cc76cc1@posting.google.com>...
> Hi trying to make my first productive script, it (in theory)renames
> file extensions in win32, script is below
> 
> print "Type in name of Directory, ie. C:\\music\\\n";
> chomp($dirname=<STDIN>);
> print "Type in name of extension to replace ie. mp3 (no period)";
> chomp($old=<STDIN>);
> print "Type in name of the new extension ie. mpg";
> chomp($new=<STDIN>);
> opendir (DIR, $dirname) or die "can't open dir $!";
> while(defined($file=readdir(DIR))){
> $old_file=$file;
> if($file=~/.*\.(.*)/){
> $currext=$1;
> if($currext=$old){
> $file=~/(.*)\..*/;
> $currfile=$1;
> $new_file=$currfile . "\." . $new;
> rename ($old_file, $new_file) or die "$!";
> }
> }
> }
> closedir(DIR);
> 
> 
> 
> I get the following error when I run it
> 
> Permission denied at c:\docs\ext.pl line 16, <STDIN> line 3.
> 
> Any help is greatly appreciated



Thank you both very much, I appreciate your help excpecially the links
to other resources. I have been trying to learn perl by using perldoc
and it has been slow going


------------------------------

Date: 20 Mar 2003 12:43:52 -0800
From: veld@interparts-cp.nl (Jacques Veldhuijzen)
Subject: Re: Open file and print out contents from array
Message-Id: <cb594a0f.0303201243.73f509d2@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb7jdp5.65e.tadmc@magna.augustmail.com>...
> Jacques Veldhuijzen <veld@interparts-cp.nl> wrote:
> 
> > 	open (IN, "$text_url"); 
>                   ^         ^ those quotes do not do anything
>                   ^         ^ so they should not be there
> 
> 
> You should always, yes *always*, check the return value from open():
> 
>    open (IN, $text_url) or die "could not open '$text_url'  $!";
> 
> 
> >         print MAIL @lines;
> > has no effect at all.
> 
> 
> Then @lines is empty, probably because your open() failed.
> 
> If you had checked open()'s return value, you would know what is wrong.
> 
> If you had enabled warnings, you would have known that something was
> wrong on the <IN> line.
> 
> You should always enable warnings when developing Perl code!
> 
> 
> 
> open() works on *files* not URLs. If $text_url is really a URL
> that you want to fetch, then see the Perl FAQ:
> 
>    perldoc -q fetch
> 
>       "How do I fetch an HTML file?"

Now i know:

        use LWP::Simple;
	$content = get($text_url);
	print MAIL $content;

Thanks for your help !!!
This works fine


------------------------------

Date: 20 Mar 2003 12:34:51 -0800
From: rdodd@xltech.net (Robert Dodd)
Subject: Perl querystring encoding  question
Message-Id: <907e039c.0303201234.1de824c4@posting.google.com>

I am trying to pass values in a querystring that come from a a flat
file db extracted using Perl (see code below) Can anyone tell me how
to encode the variable encoding querystring variables $job_title?
right now it get truncated because it contains a / the code is below

while ( my $job_record = <JOBS> ) {
	my ($emp_id,$jobtype,$state,$job_title,$job_desc,$contact_email,$mod_date)
=
		split(/\|/,$job_record);
	my $ab_state = $state_hash{$state};
	# Display the jobs if the states match and the types match or
	#  if no states is specified and the types match or
	#  if no type is specified and the states match
	
if( (($state_match eq $ab_state) && ($type_match eq lc($jobtype))) ||
    (!$state_match && ($type_match eq lc($jobtype))) ||
    (!$type_match && ($state_match eq $ab_state))  ||
    (!$type_match && !$state_match )) {
$cnt++;
	if( $jobtype =~ /product/ ) {
			$jobtype = 'Product Demo';
	 } elsif( $jobtype =~ /headquarters/ ) {
			$jobtype = 'Sarasota Headquarters';
	 } elsif( $jobtype =~ /sales/ ) {
			$jobtype = 'Sales Training';      
	 } else {
			$jobtype = ucfirst($jobtype);
	}
	 print <<"End_of_HTML";
  <tr>
    <td><b>JOB TYPE:  $jobtype</b></td>
  </tr>
  <tr>
    <td><b>STATE:  $state</b></td>
  </tr>
  <tr> 
    <td><b>JOB TITLE:  $job_title</b><br> <a
href="mailto:$contact_email">$contact_email</a></td>
  </tr>
  <tr>
    <td>DESCRIPTION:</td>
  </tr>
  <tr>
    <td>$job_desc<br></td>
  </tr>
  <tr>
    <td><a href=application.shtml?email=$contact_email&state=$state&position=$job_title>Online
Application</a><br></td>
  </tr>
  <tr>
     <td align="right"><a href="email_friend.shtml"><img
src="images/email_friend.gif" width="96" height="28" border="0"
title="Email this to a friend" alt="Email this to a friend"></a></td>
  </tr>
  <tr><td><hr width="100%" size="1" noshade></td></tr>
End_of_HTML
 
 }
}


------------------------------

Date: 20 Mar 2003 14:46:22 -0800
From: rpalla@kentlaw.edu (ramesh)
Subject: pulling datafrom database
Message-Id: <2b0865a8.0303201446.47629e6d@posting.google.com>

Hi

I am pulling data from database (msaccess and odbc oracle driver)
through select command.

my select statement and code is as follows

if (defined $dbh) {
                  $csr =$dbh->prepare("select ENVOBJID from
HARENVIRONMENT where
 environmentname like 'Release2%'");

                     $csr->execute() || die "Could not execute SQL
statement, ma
ybe invalid?";

          while( $row = $csr->fetchrow_hashref ) {
       
         print Dumper($row);
                 
            }


and My outputis  like this.


$VAR1 = {
          'ENVOBJID' => '226'
        };

but i want to caputure only 226.    How to get this through
program...i am just sstarted learning perl.


------------------------------

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.  

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 4736
***************************************


home help back first fref pref prev next nref lref last post