[17636] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5056 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Dec 7 18:05:57 2000

Date: Thu, 7 Dec 2000 15:05:19 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976230319-v9-i5056@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 7 Dec 2000     Volume: 9 Number: 5056

Today's topics:
    Re: ??newbie: s/// and \r <dgale@mailexcite.com>
    Re: ??newbie: s/// and \r (David Efflandt)
    Re: A sort of another color -- a Tale, not a question ; <mjcarman@home.com>
        ActivePerl Problem alazarev1981@my-deja.com
    Re: Alternating Prints from Two Files (Anno Siegel)
        ASP and Perlscript Socket Checking?! acalbazana@epotec.com
    Re: Beginner's question (Craig Berry)
    Re: Beginner's question <russ_jones@rac.ray.com>
    Re: Beginner's question <mjcarman@home.com>
        Bijeenkomst Amsterdam Perl Mongers, Dinsdag 12 December (Johan Vromans)
    Re: Can this script be done in a one-liner <elijah@workspot.net>
        comparing timedates HELP any_v@my-deja.com
        Desparate newbie: Perl and HTML manon_bertolini@mantacorp.com
    Re: Desparate newbie: Perl and HTML (David Efflandt)
        desperate newbie: Perl and HTML manon_bertolini@mantacorp.com
        File Operator -A Question <skpurcell@hotmail.com>
    Re: Format <jeffrey.schwab@Sun.COM>
        FTP question <wstsoi@hongkong.com>
    Re: FTP question <founder@pege.org>
    Re: HASH OF LISTS - Question erictwx@my-deja.com
    Re: Help with getting an array <mjcarman@home.com>
    Re: Help with HttpSniffer <iltzu@sci.invalid>
        Help with metacharacters and search and replace jrogers42@hotmail.com
    Re: Help with metacharacters and search and replace <kcount@ardenhouse.com>
    Re: Help with metacharacters and search and replace <kcount@ardenhouse.com>
    Re: Help: storing metacharacters in a variable <jeff@vpservices.com>
    Re: Help: storing metacharacters in a variable jrogers42@hotmail.com
    Re: Help: storing metacharacters in a variable <jeff@vpservices.com>
        How could I get the time of a server? <wstsoi@hongkong.com>
    Re: How could I get the time of a server? <westxga@my-deja.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 07 Dec 2000 19:45:33 GMT
From: "Doug Gale" <dgale@mailexcite.com>
Subject: Re: ??newbie: s/// and \r
Message-Id: <xNRX5.9943$7.373207@quark.idirect.com>


<jrogers42@hotmail.com> wrote in message news:90odch$jek$1@nnrp1.deja.com...
> Thanks,
>  I'm a little new at using perl, but I have programmed in C++. I need
> to remove the carriage return from a string. Any help on the syntax for
> this?
>
> Jason
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

$var = "This is a\nsentence with\ncarriage returns";

# This is a
# sentence with
# carriage returns

$var =~ s/\n//g;

# Now var holds:
# This is asentence withcarriage returns

# or to convert them to spaces:

$var =~ s/\n/\ /g;

# which would produce:
# This is a sentence with carriage returns

Doug




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

Date: Thu, 7 Dec 2000 21:44:45 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: ??newbie: s/// and \r
Message-Id: <slrn93015q.hb.efflandt@efflandt.xnet.com>

On Thu, 07 Dec 2000 19:45:33 GMT, Doug Gale <dgale@mailexcite.com> wrote:
>
><jrogers42@hotmail.com> wrote in message news:90odch$jek$1@nnrp1.deja.com...
>> Thanks,
>>  I'm a little new at using perl, but I have programmed in C++. I need
>> to remove the carriage return from a string. Any help on the syntax for
>> this?
>>
>> Jason
>
>
>$var = "This is a\nsentence with\ncarriage returns";
>
># This is a
># sentence with
># carriage returns
>
>$var =~ s/\n//g;
>
># Now var holds:
># This is asentence withcarriage returns
>
># or to convert them to spaces:
>
>$var =~ s/\n/\ /g;
>
># which would produce:
># This is a sentence with carriage returns

None of those statements have anything to do with carriage returns on my
system (Linux or FreeBSD).  A universal way to remove carriage returns is
s/\015//g, however, that does not remove linefeeds and might run
everything together for Mac files.  So a more universal way to convert to
proper line endings for the system the script is running on would be:

s/(\015\012|[\015\012])/\n/g;

Or Unix systems can use:  s/(\r\n|[\n\r])/\n/g;

Or to convert line endings to spaces:

s/(\015\012|[\015\012])/ /g;



-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Tue, 05 Dec 2000 14:29:30 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: A sort of another color -- a Tale, not a question ;)
Message-Id: <3A2D502A.C80DB019@home.com>

The WebDragon wrote:
>
[massive snippage]
>
> I don't remember which "transform" this refers to, although I can
> recall one name .. Guttman-Rosler Transform .. is that the one ? 
> There seems to be yet another transform title floating around in my
> memory, but I can't recall it at the moment. Correct me if I'm 
> wrong so I can get it straight :)

The "other transform" you're thinking of is probably the map-sort-map
technique, a.k.a, the "Schwartzian Transform."
 
> SO basically, what I did was 'create a manufactured key to sort the
> hash on in a single pass, using the standard sort() function rather
> than a custom sort' which yields vastly increased sort times. Such 
> a thing can be mission critical in the cases where a .cgi will be
> taking some 4000-70000 hits per day. (or more)

Yep, that describes the GRT. It's a topic that comes up here every once
in a while.

> I hope this is helpful to anyone who is stumbling around like I was
> before the transform idea occurred to me upon reading that short
> paragraph.

If you're interested in more info on it; straight from the horse's mouth
(so to speak) you can get it at

http://www.hpl.hp.com/personal/Larry_Rosler/sort/sorting.html

-mjc


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

Date: Thu, 07 Dec 2000 22:15:37 GMT
From: alazarev1981@my-deja.com
Subject: ActivePerl Problem
Message-Id: <90p262$6ae$1@nnrp1.deja.com>

I've installed ActivePerl 5.6.0.620 on my windows NT. I can run my file
(blah.cgi) from the command line and it works perfectly, spits out the
html taged code with no errors. However, when I try to run that same
script from an HTML form (action="blah.cgi") it doesn't work. All I get
is the .cgi file literally printed into my browser.

I have the exact same files running and working on a unix server, so I
think the error is not in my code.

I suspect the problem is in the first line of the .cgi file:
#!/usr/local/bin/perl

That line is needed for the unix server, but should it be changed for
ActivePerl on a WinNT system?

Any ideas?

Thanks in advance,

Alex Lazarevich
alazarev@itg.uiuc.edu


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 7 Dec 2000 21:23:10 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Alternating Prints from Two Files
Message-Id: <90ov3u$fp6$1@lublin.zrz.tu-berlin.de>

Elisa Roselli <e.roselli@volusoft.com> wrote in comp.lang.perl.misc:

>Still, for the sake of the art, I would have liked to know why I couldn't
>get the Perl programme to work.
>>You're reading HEAFILE twice here.
>How can I avoid re-invoking it and still get the corresponding line into a
>variable?

I don't think this has been satisfactorily answered in this thread.
Here is my take: We want to join lines from two files so that
like-numbered lines are joined into one.  We can assume that both
files contain equal numbers of lines, but will break off the process
if one file runs out of lines early.  Assume that we have successfully
opened the filehandles HEAD and TAIL:

while ( <HEAD> ) {   # run all lines of HEAD through $_
  last if eof TAIL;  # ...unless TAIL runs out of data
  chomp;             # we don't want a newline in the middle, it's confusing
  $_ .= <TAIL>;      # append line from tail. keep final newline
  print;             # output the line
}

Note how this reads exactly one line from TAIL for each line it gets
from HEAD, despite of the seemingly unequal treatment of HEAD and
TAIL.  The temptation to be fair and mention HEAD in the loop body
too must be resisted.

Anno


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

Date: Thu, 07 Dec 2000 20:29:34 GMT
From: acalbazana@epotec.com
Subject: ASP and Perlscript Socket Checking?!
Message-Id: <90orv5$g4$1@nnrp1.deja.com>

Hello,

I have the task of checking to see that an IP and socket are
available.  I want to use Perl to accomplish this by embedding the
following code in the ASP page using Perlscript server side:

<%@Language="PerlScript"%>
<%
use IO::Socket;
$sock = new IO::Socket::INET (PeerAddr => 'myIP',
                              PeerPort => myPort,
                              Proto    => 'tcp',
                             );

die "Socket could not be created. Reason: $!\n" unless $sock;
%>

Obviously this will not work since I can not use the DIE statement in
this context.  How can I return the presence or absence of a socket
using Perscript?  Basically, I want to do something if the connection
is available to me or do something else if it is not.

Thank in advance,

Al Calbazana
acalbazana@epotec.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 07 Dec 2000 21:37:34 -0000
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Beginner's question
Message-Id: <t300ou2poelj45@corp.supernews.com>

Martien Verbruggen (mgjv@tradingpost.com.au) wrote:
: On 7 Dec 2000 09:09:47 GMT,
: 	Abigail <abigail@foad.org> wrote:
: > On 5 Dec 2000 20:03:30 -0600, Logan Shaw (logan@cs.utexas.edu) wrote in comp.lang.perl.misc <URL: news:<90k6pi$e3i$1@pip.cs.utexas.edu>>:
: > ++ 
: > ++ That, of course, is not possible.  You need a functioning computer to
: > ++ run Perl scripts.
: > 
: > Nah, anyone can admire a Perl program and run it in their heads.
: 
: Is your head Turing-complete?

I keep running out of room for the infinite tape.

-- 
   |   Craig Berry - http://www.cinenet.net/~cberry/
 --*--  "The hills are burning, and the wind is raging; and the clock
   |   strikes midnight in the Garden of Allah." - Don Henley


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

Date: Thu, 07 Dec 2000 15:45:33 -0600
From: Russ Jones <russ_jones@rac.ray.com>
Subject: Re: Beginner's question
Message-Id: <3A3004FD.C5812C88@rac.ray.com>

Chris Fedde wrote:
> 
> This reminds me of that old joke:
> 
>     Perl programmers laugh at a joke three times.
>     Once when they hear it,  once when it is explained
>     and once when they figure it out.
> 


That's not a joke about Perl programmers, it's about trumpet players.
Everyone knows that!
-- 
Russ Jones - HP OpenView IT/Operatons support
Raytheon Aircraft Company, Wichita KS
russ_jones@rac.ray.com 316-676-0747

Quae narravi, nullo modo negabo. - Catullus


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

Date: Tue, 05 Dec 2000 15:37:39 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Beginner's question
Message-Id: <3A2D6023.EA4245BD@home.com>

Nick wrote:
> 
> Is it possible to get a Perl interpreter to run on a Win98 
> machine so I don't have to go online to test scripts?

Certainly, Perl has been ported almost everywhere. You can get the Win*
one from www.activestate.com.

(Note: If you're planning to test CGI scripts, you'll also need to
install some sort of web server.)

-mjc


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

Date: 07 Dec 2000 17:22:15 +0100
From: JVromans@Squirrel.nl (Johan Vromans)
Subject: Bijeenkomst Amsterdam Perl Mongers, Dinsdag 12 December 2000
Message-Id: <m2g0k0fbgo.fsf@phoenix.squirrel.nl>


[English version follows the dutch text]

Amsterdam.pm staat voor de "Amsterdamse Perl Mongers", een groep van
gebruikers van Perl. In tegenstelling tot wat de naam suggereert is
Amsterdam.pm niet beperkt tot alleen Amsterdam, maar functioneert, tot
er meer gebruikersgroepen in Nederland zijn, als Nederlandse
gebruikersgroep.

Amsterdam.pm organiseert informele bijeenkomsten waar Perl gebruikers
kunnen samenkomen en informatie en gebruikservaringen met betrekking
tot Perl kunnen uitwisselen. Deze bijeenkomsten vinden normaliter
plaats op elke eerste dinsdag van de maand. De voertaal binnen
Amsterdam.pm is in pricipe Nederlands, maar indien nodig zal Engels
worden gebruikt, b.v. om te communiceren met niet-Nederlandssprekende
aanwezigen.

De eerstvolgende bijeenkomst vindt plaats op dinsdag 12 december 2000 van
20:00 tot 22:00 uur op het kantoor van XS4All, Eekholt 32, Amsterdam ZO.

Voor meer details, waaronder een routebeschrijving, zie
http://www.amsterdam.pm.org/Meetings/next_meeting.html

Liefhebbers van een etentje vooraf kunnen tussen 17:45 en 18:15
arriveren. Om 18:15 (écht om 18:15!) zoeken we een restaurantje in de
buurt om een hapje te eten.

Bezoek onze Web site http://www.Amsterdam.pm.org voor meer details.

[English version]

Amsterdam.pm stands for the Amsterdam Perl Mongers. We're basically a
Perl user group. Despite its name, it is not local to the Amsterdam
environment, but it welcomes Perl mongers from all over the
Netherlands.

Amsterdam.pm organises informal meetings where Perl users can meet,
and exchange information and experiences with regard to using Perl.
The meetings are normally held every first Tuesday of the month.
Although the preferred language for communication is Dutch, English
will be spoken if necessary.

Our next meeting is Tuesday December 12th, 2000, from 20:00 till 22:00
at the office of XS4All, Eekholt 32, Amsterdam ZO.

See http://www.amsterdam.pm.org/Meetings/next_meeting.html for
more detail and the directions to get there.

Should you want to join some of us for dinner, please arrive between
17:45 and 18:15. At 18:15 sharp we'll leave for a restaurant somewhere
nearby for dinner.

See http://www.Amsterdam.pm.org for more details.







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

Date: 7 Dec 2000 21:00:56 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: Can this script be done in a one-liner
Message-Id: <eli$0012071547@qz.little-neck.ny.us>

On Dec 1, Derek Ross said:
>All it does is read in two lists of integers from the files a.txt and
>b.txt, and prints out the sum of each pair.
 
Jeff Pinyan came up with:
:   perl -lne 'BEGIN { @A=<>, @ARGV="b.txt" } print shift(@A)+$_' a.txt

Which reduces to:
    perl -lne'BEGIN{@A=<>,@ARGV="b.txt"}print shift(@A)+$_' a.txt

Abigail gave us:
++  perl -ple 'BEGIN {open B, "b.txt" or die} $_ += <B>' a.txt

Which reduces to:
    perl -ple'BEGIN{open B,"b.txt"or die}$_+=<B>' a.txt

Today I thought of this:

    paste a.txt b.txt|sed -e 's/$/+p/'|dc

My simplistic benchmarking shows Abigail's and my solution to about
the same speed, with Jeff's being somewhat slower. Won't work on a
typical non-Unix box, but there are things the Unix shell is still
good for.

Elijah
------
'paste', you think, what dusty closet did he pull that from?


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

Date: Thu, 07 Dec 2000 20:49:22 GMT
From: any_v@my-deja.com
Subject: comparing timedates HELP
Message-Id: <90ot4g$1i8$1@nnrp1.deja.com>

Hi everybody,
I have a script that takes from a web page two dates as "startdate =
2000-11-27" and "enddate = 2000-11-30". For this period of time I insert
into the databese one record with some more information for this period.
I would like to insert a new record for each day, but still take the
dates from the form as a period. I thuoght about a block that insert a
new record for $i e.g. from nov.27th to nov.30th, but I dont know whow
to obtain the difference between that dates. Any ideea???
Thanks,
Any


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 07 Dec 2000 20:35:25 GMT
From: manon_bertolini@mantacorp.com
Subject: Desparate newbie: Perl and HTML
Message-Id: <90osad$tk$1@nnrp1.deja.com>

Hello there!

I am very new at Perl and I wanted to know - is it possible to retrieve
a value stored in a variable from HTML or Javascript into Perl?

My code in the HTML doc
"<input type=radio name=Question value=ans1>" + a1 + "<BR><BR>" +  ...

Where "a1" contains a string, and I want that string passed to Perl.


Or can Perl evaluate whther a radio button is checked on an outside HTML
form?
Thanks!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 7 Dec 2000 22:01:51 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Desparate newbie: Perl and HTML
Message-Id: <slrn93025s.hb.efflandt@efflandt.xnet.com>

On Thu, 07 Dec 2000, manon_bertolini@mantacorp.com
<manon_bertolini@mantacorp.com> wrote:
>
>I am very new at Perl and I wanted to know - is it possible to retrieve
>a value stored in a variable from HTML or Javascript into Perl?
>
>My code in the HTML doc
>"<input type=radio name=Question value=ans1>" + a1 + "<BR><BR>" +  ...
>
>Where "a1" contains a string, and I want that string passed to Perl.

Your variable "a1" is not within any form tag, so the answer is No, unless
you somehow use JavaScript to submit that value to a CGI or other server
side method on a web server.  If you have JavaScript questions, refer to
javascript docs or newsgroup.

The only part of this that might have anything to do with Perl is whether
you have a question about the Perl CGI module, which is subject for the
cgi newsgroup, and explained in detail if you type:  perldoc CGI

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Thu, 07 Dec 2000 20:34:44 GMT
From: manon_bertolini@mantacorp.com
Subject: desperate newbie: Perl and HTML
Message-Id: <90os94$rt$1@nnrp1.deja.com>

Hello there!

I am very new at Perl and I wanted to know - is it possible to retrieve
a value stored in a variable from HTML or Javascript into Perl?

My code in the HTML doc
"<input type=radio name=Question value=ans1>" + a1 + "<BR><BR>" +  ...

Where "a1" contains a string, and I want that string passed to Perl.


Or can Perl evaluate whther a radio button is checked on an outside HTML
form?
Thanks!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 7 Dec 2000 15:10:54 -0600
From: "spurcell" <skpurcell@hotmail.com>
Subject: File Operator -A Question
Message-Id: <3a2ffd5c$0$12076@wodc7nh0.news.uu.net>

Hello,
I am having trouble understanding the -A operator in regards to a file.

I have a file that was created Nov. 27, 2000. It has not been modified since
its creation date. But when I run a -A on it, it shows the following:
my $tmp = (-A "$sessions/views/a-dbm");
print "$tmp";
prints     '2.17798611111111'

How can that be, if no one has "Modified, or Inserted New Records since Nov.
27, 2000"?

I do read that directory occasionally via  a file handle, but would that
constitute an access?

If anyone has any understanding of the -A, (The camel is very short on this
topic, and there is nothing about this in the Cookbook), I would appreciate
hearing from you.

Thanks
Scott




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

Date: Thu, 07 Dec 2000 15:42:09 -0500
From: jeffrey schwab <jeffrey.schwab@Sun.COM>
Subject: Re: Format
Message-Id: <3A2FF621.63FB5D91@Sun.COM>

Abigail,

I like the way you think. :)

-Jeff

Abigail wrote:
> 
> On Thu, 07 Dec 2000 10:39:39 -0600, Lalit (lalit@engrs.unl.edu) wrote in comp.lang.perl.misc <URL: news:<3A2FBD4B.5B0F7AE3@engrs.unl.edu>>:
> ++ Hi! I am very new to perl. I have used it for writing a program that
> ++ returns a two dimensional list. The problem is that the number of
> ++ columns in that are variable according to the user input. When the # of
> ++ columns are more than 5, the output that I get is getting wrapped and
> ++ falling into the next line. This is spoiling the format of the output
> ++ file. Please help me out if anyone knows a way of getting over this
> ++ problem. I would really appreciate a detailed solution as I am very new
> ++ to Perl.
> 
> You could use a smaller font, or you put in the paper sideways.
> 
> Abigail


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

Date: Fri, 8 Dec 2000 20:12:15 +0800
From: "Lucas" <wstsoi@hongkong.com>
Subject: FTP question
Message-Id: <90ondo$9p52@imsp212.netvigator.com>

I got a large log file that holding over 500,000 records, and each
record per line:

Log>>>>>>>>>>>
123456789 1997/8/24 13:24 ...
123456790 1997/8/24 13:50 ...
 ...
 ......
 .........

145678902 2000/11/23 2:30 ...
End of the log >>>>>>>>>>>


I only could telnet or FTP to access it, I need to write a
scipt to monitor the log and what I need could be the only
last 400 or 500 records (recent logs), so what ways could
let me get what I need, nut not get the whole file? Is it possible
to get the last 1Kb of the log file by FTP or whatever?

Thanks very much.






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

Date: Thu, 7 Dec 2000 20:23:39 +0100
From: "Mösl Roland" <founder@pege.org>
Subject: Re: FTP question
Message-Id: <3a2fe461$0$13180@SSP1NO25.highway.telekom.at>

"Lucas" <wstsoi@hongkong.com> wrote in message
news:90ondo$9p52@imsp212.netvigator.com...
> I got a large log file that holding over 500,000 records, and each
> record per line:
>
> Log>>>>>>>>>>>
> 123456789 1997/8/24 13:24 ...
> 123456790 1997/8/24 13:50 ...
> ...
> ......
> .........
>
> 145678902 2000/11/23 2:30 ...
> End of the log >>>>>>>>>>>
>
>
> I only could telnet or FTP to access it, I need to write a
> scipt to monitor the log and what I need could be the only
> last 400 or 500 records (recent logs), so what ways could
> let me get what I need, nut not get the whole file? Is it possible
> to get the last 1Kb of the log file by FTP or whatever?
>
> Thanks very much.

It would be pracital to compress the log
Such logs are usual 1:10 compressable


--
Mösl Roland founder@pege.org
http://www.pege.org clear targets for a confused civilization
http://www.BeingFound.com web design starts at the search engine




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

Date: Thu, 07 Dec 2000 21:19:50 GMT
From: erictwx@my-deja.com
Subject: Re: HASH OF LISTS - Question
Message-Id: <90outd$36u$1@nnrp1.deja.com>

In article <3a2ea217.2950352282@news.wildapache.net>,
  WA Support wrote:
> Hello,
>
> If I define a hash of list, say like:
>
>  %HoL = (
>         flintstones        => [ "fred", "barney" ],
>         jetsons            => [ "george", "jane", "elroy" ],
>         simpsons           => [ "homer", "marge", "bart" ],
>       );
>
> I can print $HoL{flintstones}[0] and get "fred", so I know the hash is
> loading.
>
> How do I pass reference to the hash with an input statement?
>
> I have tried:
>
> print '<input type=hidden name=structures value="',$HoL'">';
>
> but does not appear to work.
>
> Also, once I do get the hash properly passed to the program that is
> servicing the form, how do I pass the hash to a subroutine?
>
> I have tried:
>
> &parseform($HolL;
>
> and delcare $HoL in sub parseform with:
>
> ($HoL) = shift;
>
> but nothing is passing through.
>
> Any help would be greatly appreciated!
>
> Thanks,
> Murrah Boswell
>


I am not sure what you are trying to do in the html/cgi
To send a reference to hash to a function you do it like this:
sub myFunc {
   my $hashRef = shift;
   print "$$hashRef{twoKey}\n";
   return 0;
}
my %myHash = (oneKey => 'foo', twoKey => 'bar');
myFunc(\%myHash);



This prints
bar
Hope this helps
-Eric


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Tue, 05 Dec 2000 13:46:14 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Help with getting an array
Message-Id: <3A2D4606.C5A9369F@home.com>

debcod@my-deja.com wrote:
> 
> I need to read through log files and pull out two different 
> lines, then print into a comma-delimited list.
> 
> I can get the script to read through all the
> right files and pull out the correct lines, but
> can only get it to print the last record.

That's because you're only print()ing once.

> I know I have to get each of the lines I want into an array

Not necessarily. You could use a hash, or just print out every time you
finish with an entry.

> my ($cart, $cartlabel, $srvr, $dlt, $drvlabel, $jobname);

You never use $cartlabel, $drvlabel, or $jobname, so why declare them?
You can replace them with 'undef' in the split()s below.
 
>    foreach $file (<BEX*.txt>) {
> 
>        open(FILES, "<$file");

You should *always* check whether or not an open() was successful!

>        <FILES>;

Why are you skipping the first line? It looks like it holds data you
want.

>           while (<FILES>) {

I'd put a single chomp() here, and then you wouldn't have to mess with
it later on.

> 
>              if (/Job name/) {
>                 ($jobname,$srvr) = split /:/,$_;
>                 chomp $srvr;
>              }

if (/Job name/) {
    (undef, $srvr) = split /:/, $_;
}

etc.

> [...]
> print "$srvr,$dlt,$cart\n";

You need to either put this print() inside your while loop and call it
when you reach the end of each record, or save records into a hash or
array and regurgitate them later on.

> }
> 
> ==============================================
> The data from the log files looks like this:
> ==============================================
> Job name: JOBZ33
> Job started: Thursday, November 30, 2000
> Job type: Backup
> Log file: BEX54.txt
> 
> Drive and media information from media mount:
> Changer Name: COMPAQ 1
> Drive Name: DLT2
> Media Slot: 1
> Media Cartridge Label: CEU889
> Targeted Media Set Name: Media Set 33
> Backup set #2 on storage media #1
> 
> Drive and media information from media mount:
> Changer Name: COMPAQ 1
> Drive Name: DLT2
> Media Slot: 6
> Media Cartridge Label: CEU890
> Targeted Media Set Name: Media Set 33
> Backup set #2 on storage media #2

So one 'Job Name' can have multiple sets of drive/media data? If so, and
if you're data is all formatted nicely as above, you can do this:

#!/usr/local/bin/perl -w
use strict;

my ($cart, $srvr, $dlt);

foreach my $file (<BEX*.txt>) {

    unless (open(FILES, "<$file")) {
        warn "Can't open '$file', skipping [$!]\n";
        next;
    }

    while (<FILES>) {
        chomp;

        if (/Job name/) {
            (undef, $srvr) = split(/:/, $_);
        }
        if (/Drive Name/) {
            (undef, $dlt) = split(/:/, $_);
        }
        if (/Media Cartridge Label/) {
            (undef, $cart) = split(/:/, $_);
            print "$srvr,$dlt,$cart\n";
        }
    }
}

I'd clean things up a bit more if the script is going to be around for a
while, but that should be good enough for a "quick and dirty" script.

-mjc


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

Date: 7 Dec 2000 20:06:39 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Help with HttpSniffer
Message-Id: <976219441.10780@itz.pp.sci.fi>

In article <1rpuj4cdt0.fsf@video.bsd.uchicago.edu>, John Hunter wrote:
>
>But if there is a more appropriate forum, I would be happy to ask it
>there.  My news server has no groups which match http or proxy.  

Try the comp.infosystems.www.* hierarchy.  But ask the author of the
program first, in email.  Or search the web for helpful documents or
posts by others who've had the same problem before.

-- 
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real!  This is a discussion group, not a helpdesk.  You post
 something, we discuss its implications.  If the discussion happens to
 answer a question you've asked, that's incidental." -- nobull in clpm



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

Date: Thu, 07 Dec 2000 19:50:30 GMT
From: jrogers42@hotmail.com
Subject: Help with metacharacters and search and replace
Message-Id: <90opm3$udh$1@nnrp1.deja.com>

What I want to do is grab a line from a file, which I know how to do.
Then I want to search the file for a comma and replace it with a tab.
So if,

$line = "John,7";
$string = "\t";

how do I write the s/// so that $line = "John	7".

Jason


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 7 Dec 2000 16:10:55 -0500
From: "kcount" <kcount@ardenhouse.com>
Subject: Re: Help with metacharacters and search and replace
Message-Id: <90ou7h$9ml$1@news.warwick.net>

$line = "John,7";

$line =~ s/^(\w+),(\d)/$1 $2/;

# now $line contains "John 7"

hope this helps.

Kip
#!/usr/bin/perl || die;




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

Date: Thu, 7 Dec 2000 16:16:10 -0500
From: "kcount" <kcount@ardenhouse.com>
Subject: Re: Help with metacharacters and search and replace
Message-Id: <90ouha$ejg$1@news.warwick.net>

or, if you know the scalar is always going to be in the same format, and
just want to simply get rid of the comma...

$line =~ s/,/\t/;  # to replace with a tab.

$line =~s/,/ /; # to replace with a space.




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

Date: Thu, 07 Dec 2000 11:21:13 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help: storing metacharacters in a variable
Message-Id: <3A2FE329.94F934BC@vpservices.com>

jrogers42@hotmail.com wrote in an email response to this thread:

> $line = "John,7";
> $string = "\t";
>
> how do I write the s/// so that $line = "John   7".

PLEASE do not email members of the newsgroup, but rather respond to
newsgroup messages in the newsgroup itself.  The relevant word here is
newsGROUP.  This is not an individual help desk, it's a group activity.

The answer to your question is:  

    $line =~ s/,/$string/;

Is there some reason you could not try that out yourself?

-- 
Jeff


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

Date: Thu, 07 Dec 2000 19:52:06 GMT
From: jrogers42@hotmail.com
Subject: Re: Help: storing metacharacters in a variable
Message-Id: <90opp3$um4$1@nnrp1.deja.com>

In article <3A2FE329.94F934BC@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> jrogers42@hotmail.com wrote in an email response to this thread:
>
> > $line = "John,7";
> > $string = "\t";
> >
> > how do I write the s/// so that $line = "John   7".
>
> PLEASE do not email members of the newsgroup, but rather respond to
> newsgroup messages in the newsgroup itself.  The relevant word here is
> newsGROUP.  This is not an individual help desk, it's a group
activity.
>
> The answer to your question is:
>
>     $line =~ s/,/$string/;
>
> Is there some reason you could not try that out yourself?
>
> --
> Jeff
>
Sorry about that.
I tried that and it just put the \t in place of the comma.

Jason


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 07 Dec 2000 12:09:49 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Help: storing metacharacters in a variable
Message-Id: <3A2FEE8D.2E85A287@vpservices.com>

jrogers42@hotmail.com wrote:
> 
> In article <3A2FE329.94F934BC@vpservices.com>,
>   Jeff Zucker <jeff@vpservices.com> wrote:
> >
> > jrogers42@hotmail.com wrote in an email response to this thread:
> >
> > > $line = "John,7";
> > > $string = "\t";
> > >
> > > how do I write the s/// so that $line = "John   7".
> >
> >
> > The answer to your question is:
> >
> >     $line =~ s/,/$string/;
> >
> I tried that and it just put the \t in place of the comma.

Are you sure you didn't have single quotes around the \t?  That's the
only way I can think of you could get those results.

-- 
Jeff


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

Date: Fri, 8 Dec 2000 20:16:43 +0800
From: "Lucas" <wstsoi@hongkong.com>
Subject: How could I get the time of a server?
Message-Id: <90onm4$ci85@imsp212.netvigator.com>

Hi,

How could I get the time, date of a server by script?
I just checked some documents about telnet and Net::FTP,
but I couldn't find any clues.

Thanks very much again




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

Date: Thu, 07 Dec 2000 20:34:34 GMT
From: Glenn West <westxga@my-deja.com>
Subject: Re: How could I get the time of a server?
Message-Id: <90os8q$rq$1@nnrp1.deja.com>

In article <90onm4$ci85@imsp212.netvigator.com>,
  "Lucas" <wstsoi@hongkong.com> wrote:
> Hi,
>
> How could I get the time, date of a server by script?
> I just checked some documents about telnet and Net::FTP,
> but I couldn't find any clues.
>
> Thanks very much again
>

If the server is running Unix, you could connect to the port associated
with the daytime service (usually port 13).

HTH...


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 5056
**************************************


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