Bob Showalter
Jan 7 2004, 10:29 PM
Dan Muey wrote:
QUOTE |
Howdy list. I'm trying to one lineify this:
my $guts = $firstchoice || ''; if(!$guts && $use_second_choice_if_first_is_empty) { $guts = $secondchoice; }
Basically my $guts = $firstchoice || $secondchoic || ''; Would be perfect except I only want to let it use $seconchoice if $use_second_choice_if_first_is_empty has a true value. This does not work like I want but illustrates the goal if you read it our loud. my $guts = $firstchoice || $secondchoic if $use_second_choice_if_first_is_empty || '';
Is that possible to do with one line?
|
$first || ($use_second && $second) || '';
Tim Johnson
Jan 7 2004, 07:36 PM
Wow. 50 times. That's some stamina. I imagine that's almost as
annoying as getting a humongous Christmas picture background HTML mail
in your Perl mailing list...
________________________________
From: David Kapp [mailto:[Email Removed]]
Sent: Wednesday, January 07, 2004 11:31 AM
To: [Email Removed]
Subject: stop
I've requested 50 times to be taken off your mailing list, but you still
send me this unwanted mail.
I will now report all mail sent to me by you as SPAM....................
Stop sending me spam.
Ned Cunningham
Jan 7 2004, 07:37 PM
Yeah or taking the time to blame the users of the list.
Happy New Year!!!
Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(ext. 310
[Email Removed]
-----Original Message-----
From: Tim Johnson [mailto:[Email Removed]]
Sent: Wednesday, January 07, 2004 2:36 PM
To: David Kapp; [Email Removed]
Subject: RE:[OT] stop
Wow. 50 times. That's some stamina. I imagine that's almost as
annoying as getting a humongous Christmas picture background HTML mail
in your Perl mailing list...
________________________________
From: David Kapp [mailto:[Email Removed]]
Sent: Wednesday, January 07, 2004 11:31 AM
To: [Email Removed]
Subject: stop
I've requested 50 times to be taken off your mailing list, but you still
send me this unwanted mail.
I will now report all mail sent to me by you as SPAM....................
Stop sending me spam.
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Dan Muey
Jan 7 2004, 07:39 PM
QUOTE |
I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail.
|
You've sent 50 emails to [Email Removed]?
I get no spam from this list ever, maybe it's coming
from someone who harvested your email address from a web site or something?
QUOTE |
I will now report all mail sent to me by you as SPAM....................
|
What are the headers and ip addresses, I doubt it's coming from the
real beginners list or else I'd have gotton spam also since I've
subscribed for a while now.
QUOTE |
Stop sending me spam.
|
I never have and the list hasn't either. It's got to be a harvesting
bot, virus, etc... Maybe your IncrediMail or Kazaa or somethgin has spyware in it?
HTH
DMuey
> 2003 www.hushport.com
Casey West
Jan 7 2004, 07:45 PM
It was Wednesday, January 07, 2004 when David Kapp took the soap box, saying:
: I've requested 50 times to be taken off your mailing list, but you still
: send me this unwanted mail.
: I will now report all mail sent to me by you as SPAM....................
: Stop sending me spam.
You can send a message to [Email Removed] and respond
to the confirmation request you get as a result. Emailing this list
directly will not help you. If that still doesn't work for you, email
[Email Removed] with the exact email address you would like
removed and the perl.org admins will take care of it.
As an aside, this mailing list could never be SPAM to you because you
confirmed your subscription to it and thus every message is
solicited. Even so, I'm sorry they bother you.
Casey West
--
Shooting yourself in the foot with APL
You hear a gunshot and there's a hole in your foot, but you don't
remember enough linear algebra to understand what has happened.
Dan Muey
Jan 7 2004, 07:52 PM
QUOTE |
I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail.
You've sent 50 emails to [Email Removed]?
What a fun thread, I wanted to go off in my usual flare but didn't :( |
Maybe next time :)
QUOTE |
I get no spam from this list ever, maybe it's coming from someone who harvested your email address from a web site or something?
I will now report all mail sent to me by you as SPAM....................
What are the headers and ip addresses, I doubt it's coming from the real beginners list or else I'd have gotton spam also since I've subscribed for a while now.
Stop sending me spam.
I never have and the list hasn't either. It's got to be a harvesting bot, virus, etc... Maybe your IncrediMail or Kazaa or somethgin has spyware in it?
HTH
DMuey
2003 www.hushport.com
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response |
Dan Anderson
Jan 7 2004, 08:04 PM
Uhhh...at the bottom of every list message is:
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
<withold sarcastic comment about thinking before you post />
-Dan
After being part of this list for a month, I don't recall seeing more than just this email requesting removal from the list.
Oh well. An amusing message. I see them all the time in the Linux mail lists I participate in. Pity people can't follow directions :-)
QUOTE |
Uhhh...at the bottom of every list message is:
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response
<withold sarcastic comment about thinking before you post /
-Dan
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response
|
Morbus Iff
Jan 7 2004, 08:14 PM
For the sake of:
* giving the guy a break.
* expecting some intellect.
* realizing he's probably
not reading your responses.
Notice he didn't say whether he requested to the list, or to the
proper email unsubscribe address: just that he had requested multiple
times to be removed. The flip side of the coin is that there may
very well be a problem with the unsubscription scripts.
Yes, this is a far-flung possibility, but besides courtesy in
the face of idiocy, one of the things ANY beginner to ANY thing
should know is to think things through from ALL angles: just
because the answer seems obvious, doesn't mean it is.
--
Morbus Iff ( i put the demon back in codemonkey )
Culture:
http://www.disobey.com/ and
http://www.gamegrene.com/Spidering Hacks:
http://amazon.com/exec/obidos/ASIN//disobeycomicq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
Charles K. Clarkson
Jan 7 2004, 08:19 PM
[Email Removed] <[Email Removed]> wrote:
:
: Oh well. An amusing message. I see them all the time in
: the Linux mail lists I participate in. Pity people can't
: follow directions :-)
Be careful what you wish for.
If everyone could follow directions we would be one
step closer to everyone being able to *write* directions.
Then I would have to become one of those really exceptional
programmers instead of just the average one I am today. :)
Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
Dan Muey
Jan 7 2004, 08:24 PM
QUOTE |
Are there any free PERL debuggers?
|
Have you tried use strict and use warnigns in your scripts?
Also perl -c script.pl is helpfule and then the perl debugger itself:
perl -d
I'm sure their's thrid party stuff but I never use any,
the above does plenty for my needs.
HTH
Dmuey
QUOTE |
I once came across pvdb (a vi-aware front-end for the PERL debugger developed by Tom Christainsen), but I never got it to work. |
Dan Muey
Jan 7 2004, 08:30 PM
Please tell me this thread will stay in the archives! It's hilarious!
I feel kinda bad for Mr. Kapp though, but if you're rude for no good
reason what can you expect.
QUOTE |
----- Original Message ----- From: [Email Removed] To: [Email Removed] Sent: Wednesday, January 07, 2004 14:31 Subject: stop
I've requested 50 times to be taken off your mailing list, but you still send me this unwanted mail. I will now report all mail sent to me by you as SPAM.................... Stop sending me spam. |
Casey West
Jan 7 2004, 08:52 PM
It was Wednesday, January 07, 2004 when Dan Muey took the soap box, saying:
: Please tell me this thread will stay in the archives! It's hilarious!
:
: I feel kinda bad for Mr. Kapp though, but if you're rude for no good
: reason what can you expect.
Well, around these parts we don't *expect* rudeness in return. I
believe that rudeness must conform to the "all things in moderation"
rule whenever it cannot be helped, which /should/ never happen. :-)
For the record the archives don't lie, the thread will be there.
That's precisely why rudeness must be kept in check.
I think now is a good time to stop this thread. Everything that
should have been said has been, as well as some things that shouldn't
have. :-)
Casey West
--
Shooting yourself in the foot with Pascal
The compiler won't let you shoot yourself in the foot.
R. Joseph Newton
Jan 8 2004, 03:28 AM
Casey West wrote:
QUOTE |
It was Wednesday, January 07, 2004 when Dan Muey took the soap box, saying: : Please tell me this thread will stay in the archives! It's hilarious! : : I feel kinda bad for Mr. Kapp though, but if you're rude for no good : reason what can you expect.
Well, around these parts we don't *expect* rudeness in return. I believe that rudeness must conform to the "all things in moderation" rule whenever it cannot be helped, which /should/ never happen. :-)
For the record the archives don't lie, the thread will be there. That's precisely why rudeness must be kept in check.
I think now is a good time to stop this thread. Everything that should have been said has been, as well as some things that shouldn't have. :-)
Casey West
|
Hi Casey,
I think there is one point that I have not seen presented here. Unfortunately,
many *real* spammers abuse the courtesy [or legal requirement?] of unsubscribe
information, and actually use it as a probe to detect live addresses. At least
many people believe that this is so. Some people may fear that they would only
get enmeshed more deeply by using the unsubscribe link.
Thanks for re-asserting the standards of kindness for the list.
Joseph
Wiggins D Anconia
Jan 8 2004, 10:37 PM
QUOTE |
How do I take advantage of this? I turn it on but I do not know how to get it to display a help message. If I pass in -h --help it just ends. I am assuming I need some kind of pod file but I am unknowledgeable on how to write a pod file. Also how do I tell it what pod file to open?
Form perldoc Getopt::Long
Configuring Getopt::Long Getopt::Long can be configured by calling subroutine Getopt::Long::Configure(). This subroutine takes a list of quoted strings, each specifying a configuration option to be enabled, e.g. "ignore_case", or disabled, e.g. "no_ignore_case". Case does not matter. Multiple calls to Configure() are possible.
auto_help (default:disabled) Automatically provide support for the --help and -? options if the application did not specify a handler for this option itself.
Getopt::Long will provide a help message using module Pod::Usage. The message, derived from the SYNOPSIS POD section, will be written to standard output and processing will terminate.
"auto_help" will be enabled if the calling program explicitly specified a version number higher than 2.32 in the "use" or "require" statement.
|
The key is in the docs you posted, specifically, "will provide a help
message using module Pod::Usage", I would suggest you have a look at the
docs for that module it should clear things up nicely. Particularly have
a look at the section "Recommended Use" that should help even more. I
have had good luck combining the two, though was unaware that this could
be handled automagically for me, very cool, I usually just code it in to
catch --help and -h and call pod2usage explicitly, god Perl+CPAN rocks...
I posted a template that takes advantage of this strategy late last year
if you want to check the archives, or e-mail me off list and I will fire
you a copy....
http://danconia.org
Chris McMahon
Jan 9 2004, 04:12 PM
Don't forget the poetic possibilities, either. Not to mention
doggerel and corruption, i.e.: "I have heard the mermaids singing foreach
to foreach".
"For to for" just wouldn't cut it.
-Chris
-----Original Message-----
From: Rob Dixon [mailto:[Email Removed]]
Sent: Thursday, January 08, 2004 3:21 PM
To: [Email Removed]
Subject: Re: Use of FOR statement
Paul Kraus wrote:
QUOTE |
Wow just tested that for (@array) do something. I didn't think that would work.
So there is no difference as far as the compiler is concerned with for and foreach? Why bother having both then?
|
The practical reason is likely to be historical, but Larry would tell you
all
about the value of redundancy in the syntax of spoken, written and computer
languages. Perl is full of it (for instance 'use English' and then $ARG
is the same thing as $_) and it goes a long way towards making the language
what it is. Not forgetting TMTOWTDI of course!
Rob
Chris McMahon
Jan 9 2004, 04:29 PM
Thank you Mr. Saffioti for the port-scanning code. I have been playing with
some simple network programming scripts recently and your code below is much
more elegant than mine. I'll be stealing parts of it very soon! =)
-Chris
-----Original Message-----
From: Goffredo Saffioti [mailto:[Email Removed]]
Sent: Friday, January 09, 2004 10:52 AM
To: [Email Removed]
Cc: [Email Removed]
Subject: Re: sockets on an HPUX
[Email Removed] ha scritto:
QUOTE |
People of the Perl,
does anyone have a perl program that will create a socket ( srwxr-xr-x ) for a HPUX 11.0 system? I am in need of this! I have looked into system calls such as mknod and mkfifo and these are not capable of creating these special files.
Thanks!
Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams
This is a socket in perl u can declare a socket in the form: $sock = |
Yuo need the module
use IO::Socket;
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp');
Not so distant by C socket :-) .
You can try this sochet with this simple script underneath
it's a simple tcp port scanner .
Hope this can help u.
Cya.
Go.
#!/usr/bin/perl -w
use IO::Socket;
use strict;
my ($line, $port, $sock, $range, $splitted, @servers, @splitted);
my $VERSION='1.0';
my $pid = 0;
my($server, $begin, $end, $processes) = @ARGV;
&usage if (!$server);
$begin = 0 if (!$begin);
$end = 65000 if (!$end);
$processes = 2 if ((!$processes) || ($processes<2));
print "Scanning from $begin to $endn";
for ($port=$begin;$port<=$end;$port++) {
&scan;
if ($sock){
print "Connected on port $portn";
}
else{
print "$port not connectedn";
}
}
sub usage{
print "Usage: portscan hostname [start at port number]n";
exit(0);
}
sub scan{
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp');
}
Great where do I get this IO::Socket module?
thank you
Derek B. Smith
OhioHealth IT
UNIX / TSM / EDM Teams
Goffredo Saffioti <[Email Removed]>
01/09/2004 12:52 PM
To: [Email Removed]
cc: [Email Removed]
Subject: Re: Perl sockets on an HPUX
[Email Removed] ha scritto:
QUOTE |
People of the Perl,
does anyone have a perl program that will create a socket ( srwxr-xr-x ) for a HPUX 11.0 system? I am in need of this! I have looked into system
calls such as mknod and mkfifo and these are not capable of creating these special files.
Thanks!
Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams
This is a socket in perl u can declare a socket in the form: $sock = |
Yuo need the module
use IO::Socket;
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp');
Not so distant by C socket :-) .
You can try this sochet with this simple script underneath
it's a simple tcp port scanner .
Hope this can help u.
Cya.
Go.
#!/usr/bin/perl -w
use IO::Socket;
use strict;
my ($line, $port, $sock, $range, $splitted, @servers, @splitted);
my $VERSION='1.0';
my $pid = 0;
my($server, $begin, $end, $processes) = @ARGV;
&usage if (!$server);
$begin = 0 if (!$begin);
$end = 65000 if (!$end);
$processes = 2 if ((!$processes) || ($processes<2));
print "Scanning from $begin to $endn";
for ($port=$begin;$port<=$end;$port++) {
&scan;
if ($sock){
print "Connected on port $portn";
}
else{
print "$port not connectedn";
}
}
sub usage{
print "Usage: portscan hostname [start at port number]n";
exit(0);
}
sub scan{
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp');
}
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
Daniel Staal
Jan 9 2004, 03:50 PM
--As off Friday, January 9, 2004 1:08 AM -0600, Robert Citek is
alleged to have said:
QUOTE |
On Thursday, January 8, 2004, at 08:22 AM, Daniel Staal wrote: 1. Upgrade to Panther. ;-) It includes Perl 5.8, and plenty more.
In the queue to do. Also, want to dual boot with Linux, but that's for an other discussion forum. :)
2. Upgrade Perl following the directions at: http://developer.apple.com/internet/macosx/perl.html This will get you the current version of Perl.
Right before doing #1.
|
--As for the rest, it is mine.
Don't bother doing both: it will just mean you have an extra copy of
Perl on your system. (And a non-standard one at that: Panther
includes a normal Perl build, which you couldn't quite do under Jag.)
Upgrade Perl if you need the new version of Perl and don't plan on
upgrading Mac OS X soon. Otherwise, just take the standard build in
Panther, which was up to date at the time of Panther's release. (If
you want to upgrade afterwards just use the normal Perl upgrade
instructions.)
Daniel T. Staal
---------------------------------------------------------------
This email copyright the author. Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes. This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------
Goffredo Saffioti
Jan 9 2004, 07:54 PM
[Email Removed] ha scritto:
QUOTE |
Great where do I get this IO::Socket module?
thank you
Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams
*Goffredo Saffioti <[Email Removed]>*
01/09/2004 12:52 PM
To: [Email Removed] cc: [Email Removed] Subject: Re: Perl sockets on an HPUX
[Email Removed] ha scritto:
People of the Perl,
does anyone have a perl program that will create a socket ( srwxr-xr-x ) for a HPUX 11.0 system? I am in need of this! I have looked into system calls such as mknod and mkfifo and these are not capable of creating these special files.
Thanks!
Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams
This is a socket in perl u can declare a socket in the form: $sock = Yuo need the module use IO::Socket;
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port, Proto => 'tcp');
Not so distant by C socket :-) . You can try this sochet with this simple script underneath it's a simple tcp port scanner . Hope this can help u. Cya.
Go.
#!/usr/bin/perl -w use IO::Socket; use strict;
my ($line, $port, $sock, $range, $splitted, @servers, @splitted); my $VERSION='1.0';
my $pid = 0; my($server, $begin, $end, $processes) = @ARGV;
&usage if (!$server); $begin = 0 if (!$begin); $end = 65000 if (!$end); $processes = 2 if ((!$processes) || ($processes<2));
print "Scanning from $begin to $endn";
for ($port=$begin;$port<=$end;$port++) { &scan;
if ($sock){ print "Connected on port $portn"; } else{ print "$port not connectedn"; } }
sub usage{ print "Usage: portscan hostname [start at port number]n"; exit(0);
} sub scan{
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port, Proto => 'tcp'); }
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response
Look in your perl path in the IO directory maybe u can find it there for |
default .
Goffredo Saffioti
Jan 9 2004, 08:38 PM
McMahon, Chris ha scritto:
QUOTE |
Thank you Mr. Saffioti for the port-scanning code. I have been playing with some simple network programming scripts recently and your code below is much more elegant than mine. I'll be stealing parts of it very soon! =) -Chris
maybe u can better appreciate this code that use also multiprocessing |
for scan the ports on more process atm 2 no more.
if u uncomment the "elses" can look also closed port with a different color.
Hope can help u .
Cya.
Go.
#!/usr/bin/perl -w
#Written by *SAFFIOTI GOFFREDO*
#script for scannning of open socket on ports.
use IO::Socket;
use IPC::Open2;
use Term::ANSIColor;
use POSIX ":sys_wait_h";
my ($port, $sock, @servers);
my $pid = 0;
my($server, $begin, $end) = @ARGV;
&usage if (!$server);
$begin = 0 if (!$begin);
$end = 65000 if (!$end);
print "Scanning from $begin to $endn";
my $status;
$pid = fork;
if ($pid != 0) {
# for ($port=$begin;$port<=(($begin + $end)/2);$port++) {
for ($port=$begin;$port<=(($end)/2);$port++) {
&scan;;
if ( $sock ) {
print color 'bold blue';
print " Connected on port $portn";
# print "$!";
}# else {
#print color 'bold blue';
#print " $port not connectedn";
#}
}
my $childpid;
# $status = 1;
while ($status = waitpid(-1, WNOHANG)> 0) {
wait;
}
}
else
{
# for ($port=(($begin + $end)/2);$port<=$end;$port++){
for ($port=($end/2)+1;$port<=$end;$port++){
&scan;
if ( $sock ) {
print color 'bold white';
print " Connected on port $portn ";
}# else {
# print color 'bold white';
# print " $port not connectedn";
#}
}
}
sub usage{
print "Usage: portscan hostname [start from port to port number]n";
exit(0);
}
sub scan{
$sock = IO::Socket::INET->new(PeerAddr => $server,
PeerPort => $port,
Proto => 'tcp');
}
Imran Dar
Jan 13 2004, 10:10 AM
Please cancel my subscription
Imran Dar
Service Cost Management,
Centrica IS, London Road, Staines.
QUOTE |
-----Original Message----- From: [Email Removed] [mailto:[Email Removed]] Sent: 10 January 2004 18:25 To: [Email Removed] Subject: beginners Digest 10 Jan 2004 18:25:16 -0000 Issue 1962
<< File: ATT775844.txt >> << Message: RE: Use of FOR statement (OT and apologies) >> << Message: Re: Writing style >> << Message: Re: Writing style >> << Message: RE: sockets on an HPUX (thanks for the port scanner!) >> << Message: Re: sockets on an HPUX (thanks for the port scanner!) >> << Message: RE: How to parse Microsoft Outlook Inbox >> << Message: RE: How to parse Microsoft Outlook Inbox >> << Message: Image Magick >> << Message: Re: Image Magick >> << Message: Re: Image Magick << Message: Re: Image Magick >> << Message: Re: printf sprintf >> << Message: Re: sockets on an HPUX >> << Message: Matching invalid characters in a URL >> << Message: Re: Matching invalid characters in a URL >> << Message: Re: Matching invalid characters in a URL >> << Message: Re: Matching invalid characters in a URL >> << Message: Equivalent to iconv for encoding conversion >> << Message: Re: Equivalent to iconv for encoding conversion >> << Message: Re: pod::usage example help >> << Message: qn about the reg expression. >> << Message: Re: qn about the reg expression. >> << Message: perl question >> << Message: perl error - please help I'm lost >> << Message: Leading zeroes >> << Message: Re: Leading zeroes >> << Message: Re: Leading zeroes >> << Message: Cobol format conversion >> << Message: Perl mapping solution << Message: Re: Perl mapping solution
|
------------------------------------------------------------
The information contained in or attached to this email is
intended only for the use of the individual or entity to
which it is addressed. If you are not the intended
recipient, or a person responsible for delivering it to the
intended recipient, you are not authorised to and must not
disclose, copy, distribute, or retain this message or any
part of it. It may contain information which is confidential
and/or covered by legal professional or other privilege (or
other rules or laws with similar effect in jurisdictions
outside England and Wales).
The views expressed in this email are not necessarily the
views of Centrica plc, and the company, its directors,
officers or employees make no representation or accept any
liability for its accuracy or completeness unless expressly
stated to the contrary.
Wiggins D Anconia
Jan 13 2004, 03:18 PM
QUOTE |
I'm nearly finished with this book (definitely excellent book!). Some items I need to review again (expressions will take some work). |
Afterwards I plan on moving upward and onward in perl. I'm curious if
Oreilly's "Programming Perl" or "Perl Cookbook" would be good to jump
into. Or is there another book I should study?
In the past I would have suggested Programming Perl, the cookbook is
more for examples of specific items, an excellent resource to be sure,
but not necessarily learning material. Recently I would suggest the
Llama's new soul mate,
http://www.oreilly.com/catalog/lrnperlorm/It will take you to the next level for sure. The old soul mate, which I
really enjoyed at the time seems to have lost some of its luster, at
least in that ORA seems to have replaced it with the above,
http://www.oreilly.com/catalog/advperl/The two above overlap a good deal.
Having said that, the Camel is indispensable and should be on every Perl
programmers shelf. Naturally there is also Safari if you aren't into
being a zoo keeper like some of us (or don't have the funds)....
http://danconia.org
Randal L. Schwartz
Jan 13 2004, 06:11 PM
QUOTE |
"Wiggins" == Wiggins D Anconia <[Email Removed]> writes:
|
Wiggins> The two above overlap a good deal.
The Alpaca and the Panther overlap in that they cover some similar
ground. But the Alpaca is designed to be a step-by-step tutorial: in
fact, it's a transcript of the course we teach (both onsite and
open-enrollment) for people who have completed the Llama course and
want more. The Panther is closer to a reference book.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +
<[Email Removed]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Duan Toh
Jan 13 2004, 06:12 PM
Hello all,
testing the use of DBI. Having a problem (highlighted in red) with using
"@$_" as the topic. When I use @row the program writes records as
expected to test.txt but when I use the topic it only writes ...
""
""
""
in the file. I have reread documentation to see if I am using @$_
correctly and it seems OK to me can anyone help ?
thanks,
Duan.
Source code ....
use warnings;
use strict;
use DBI;
use Data::Dumper;
my $destination = "test.txt";
my $dbh = DBI->connect( "dbi:ODBC:Northwind", "", "",
{RaiseError => 1, PrintError => 1, AutoCommit => 1} ) or
die "Unable to connect: " . $DBI::errstr . "n";
open OUTPUT, ">$destination" or die $!;
# OK, connected, now select from Customers table.
my $sel = $dbh->prepare( "select CustomerID,CompanyName,Country from
Customers where CustomerID like ?" );
$sel->execute( qq{%} );
if ($ARGV[0]) {
while ($sel->fetchrow_array) {
print OUTPUT '"';
print OUTPUT join '","', map {$_||0} @$_;
print OUTPUT '"',"n";
}
}
else {
while (my @row = $sel->fetchrow_array) {
print OUTPUT '"';
print OUTPUT join '","', map {$_||0} @row;
print OUTPUT '"',"n";
}
}
Wiggins D Anconia
Jan 13 2004, 06:38 PM
QUOTE |
"Wiggins" == Wiggins D Anconia <[Email Removed]> writes:
Wiggins> The two above overlap a good deal.
The Alpaca and the Panther overlap in that they cover some similar ground. But the Alpaca is designed to be a step-by-step tutorial: in fact, it's a transcript of the course we teach (both onsite and open-enrollment) for people who have completed the Llama course and want more. The Panther is closer to a reference book.
|
Well put, and I agree (naturally). I guess I hadn't thought about the
Panther as a reference, because at the time it acted as both for lack of
other resources, but the newer is definitely in the same vain as the
Learning style, and I definitely enjoyed its easy flow.
http://danconia.org
Jan Eden
Jan 13 2004, 08:55 PM
Randal L. Schwartz wrote:
QUOTE |
"Wiggins" == Wiggins D Anconia <[Email Removed]> writes:
Wiggins> The two above overlap a good deal.
The Alpaca and the Panther overlap in that they cover some similar ground. But the Alpaca is designed to be a step-by-step tutorial: in fact, it's a transcript of the course we teach (both onsite and open-enrollment) for people who have completed the Llama course and want more. The Panther is closer to a reference book.
|
I worked through the LLama and used the Camel for some additional information at certain stages. Now I ordered the Alpaca but not the Panther since it seems a bit outdated (1997) to me.
I am looking forward to reading the second Learning book, since I really enjoyed Learning Perl. Thanks Randal!
- Jan
--
Either this man is dead or my watch has stopped. - Groucho Marx
Drieux
Jan 13 2004, 11:25 PM
On Jan 13, 2004, at 10:12 AM, Duan Toh wrote:
[..]
QUOTE |
while ($sel->fetchrow_array) {
print OUTPUT '"';
print OUTPUT join '","', map {$_||0} @$_;
print OUTPUT '"',"n";
} [..] |
you might want to go back and re-read
the perldoc on perlvar - yes it is the
default value - if that were a <FH> type
of operation. think about the problem like
my $boo = some_sub();
print "$boo is a ", ref($boo) , "n";
my $i=0;
while( some_sub($i++) )
{
last unless $_;
print "got $_ n";
}
print "ending $in";
#------------------------
#
sub some_sub
{
my $i = shift;
my @list = qw/a b c d/;
return ($i)? 0: @list ;
} # end of some_sub
in this case there is a function call in the while
loop that will return the array reference - but there
is the minor detail that it is NOT being assigned to $_
as is your assumption...
HTH.
ciao
drieux
---
Peter Kay
Jan 14 2004, 11:45 AM
[Email Removed] (Rob Dixon) wrote:
QUOTE |
We Unix people find we Windows people very strange :) |
....
QUOTE |
test.pl < test.txt and type test.txt | perl test.pl
are just two (increasingly weird) versions of
perl test.pl test.txt
|
We Unix people want to rip out the operating system
some times! I don't know what this post is even doing
in "[Email Removed]" - it's been enough to make my
head swim for a while.
For the record, test.pl < test.txt won't work - you
need:
perl test.pl < test.txt
Just when you think Perl on Windows is more or less
normal, you get something like this thrown at you...
Peter
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
Jeff Westman
Jan 14 2004, 02:24 PM
Paul Kraus <[Email Removed]> wrote:
QUOTE |
(I love emacs, but vi is my tool of choice day-to-day ... much quicker .... vim is even better if you have it) Why? I started with emacs just because it happened to be the 1st I heard about. Since you know both why does vim appeal to you over emacs? Other then size.
|
I started off with the emacs version originally put out by MIT in
the 80s. Loved it. Then came along gnuemacs, gemacs, xemacs, etc.
All great improvements.
Simply stated, running 'vi' from the command line (ie, start-up) is
faster than *emacs. BUT, a TRUE emacs-person would rarely exit
from it and run everything within it's extensive environment.
To be honest? I can't remember half of the commands in emacs. But
as stated, it is simply faster for most day-to-day tasts.
JW
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
Rob Dixon
Jan 14 2004, 02:47 PM
Duan Toh wrote:
QUOTE |
testing the use of DBI. Having a problem (highlighted in red) with using "@$_" as the topic. When I use @row the program writes records as expected to test.txt but when I use the topic it only writes ... "" "" "" in the file. I have reread documentation to see if I am using @$_ correctly and it seems OK to me can anyone help ?
|
We can receive only plain text on this group: coloured highlighting
doesn't work. You must mark your program in a different way.
QUOTE |
use warnings; use strict;
use DBI; use Data::Dumper;
my $destination = "test.txt"; my $dbh = DBI->connect( "dbi:ODBC:Northwind", "", "", {RaiseError => 1, PrintError => 1, AutoCommit => 1} ) or die "Unable to connect: " . $DBI::errstr . "n";
open OUTPUT, ">$destination" or die $!;
# OK, connected, now select from Customers table.
my $sel = $dbh->prepare( "select CustomerID,CompanyName,Country from Customers where CustomerID like ?" );
$sel->execute( qq{%} );
if ($ARGV[0]) { while ($sel->fetchrow_array) { print OUTPUT '"'; print OUTPUT join '","', map {$_||0} @$_; print OUTPUT '"',"n"; } } else { while (my @row = $sel->fetchrow_array) { print OUTPUT '"'; print OUTPUT join '","', map {$_||0} @row; print OUTPUT '"',"n"; } }
|
The fetchrow_array method returns a list of data. In the first part of the 'if'
statement you're throwing that list away - nothing's being assigned to $_. In the
second part you're copying the list into array @row, so it should work fine.
Dereferencing $_ as an array with @$_ will work only if $_ holds an array
reference. You could rewrite the first loop as
while ($_ = $sel->fetchrow_arrayref) {
print OUTPUT '"';
print OUTPUT join '","', map {$_||0} @$_;
print OUTPUT '"',"n";
}
which will work because the fetchrow_arrayref method returns an array reference
and it's being stored in $_. Using $_ is only useful if there are several
operations to be done on the value that can take $_ as a default parameter. In
this case you have no such operations and you would be better off writing
while (my $row = $sel->fetchrow_arrayref) {
print OUTPUT '"';
print OUTPUT join '","', map {$_||0} @$row;
print OUTPUT '"',"n";
}
HTH,
Rob
Jeff Westman
Jan 14 2004, 06:22 PM
Incidently, emacs has a 'dired mode' (directory editor) which is
very nice... much like the old 'list' shareware in DOS land of the
dark past.... you can bring up a list of files (like 'ls -l'), then
view and selectively execute or delete all that you mark. It's
very nice, and it can also be used when accessing remote servers.
Not to mention it allows syntax highlighting.
As driex pointed out, it is the start-up time that is preferred in
vi/vim. But again, a true emacs die-hard never exits the "editor"
and does all his/her tasks inside the of it.
Not to mention, the learning curve for emacs is horrific.
JW
~~~~~~~~~
"Bradley A. Brown" <[Email Removed]> wrote:
QUOTE |
I use vim on a daily basis from the command line and its syntax highlighting and color coding is very nice in my opinion. I'm not flaming here so don't take me wrong, but I heard it said once that knowledge of a language can never be replaced by an IDE. IDE's have always been a put off to me, but I can see their usefullness in many projects. Bradley
-----Original Message----- From: Tim [mailto:[Email Removed]] Sent: Wednesday, January 14, 2004 3:47 PM To: drieux Cc: [Email Removed] Subject: Re: Apel of VIM was Emacs Wizards
At 11:24 AM 1/14/04 -0800, you wrote: ... or trying to make that one liner "perl -pie '....'" work right the first time...
Isn't that what the "i" is for (with ".bak", of course)? ;-)
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response
|
__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus
Dan Anderson
Jan 15 2004, 03:01 PM
On Wed, 2004-01-14 at 18:22, Jeff Westman wrote:
QUOTE |
Incidently, emacs has a 'dired mode' (directory editor) which is very nice... much like the old 'list' shareware in DOS land of the dark past.... you can bring up a list of files (like 'ls -l'), then view and selectively execute or delete all that you mark. It's very nice, and it can also be used when accessing remote servers. Not to mention it allows syntax highlighting.
|
Yes, and since Emacs is built on top of a LISP interpreter you can
customize it till your hearts content -- including changing the regular
expressions emacs matches files with in Dired mode.
QUOTE |
As driex pointed out, it is the start-up time that is preferred in vi/vim. But again, a true emacs die-hard never exits the "editor" and does all his/her tasks inside the of it.
|
I'd like to add that emacs allows a "Server Mode". So you start it up
once every time you boot, it runs nicely in the background, and whenever
you need to edit a file you use emacs in client mode (i.e. type
emacsclient instead of emacs).
QUOTE |
Not to mention, the learning curve for emacs is horrific.
|
I spent a lot of time learning both Vi and Emacs when I first came to
the *nix world. Both sides had some very smart people with very good
arguments as to why one was better then the other. So I figured the
best way to figure out which one was best for me was to spend a couple
hours mucking around with each one.
I ended up choosing Emacs because, despite the learning curve, it's a
damned good IDE. In emacs I can view packages, methods, and a bunch of
other code related things in the speedbar, and I have found I code much
faster in Emacs then vi (by over a thousand lines a day).
Most of it boils down to the fact that 30% of code tends to be
reusable. For instance, take the following:
my $query = qq+SELECT * FROM foo WHERE bar = "baz"+;
my $result = $DBI_connection->prepare($query)
or die("Can't prepare $query because $!");
$result->execute
or die("Can't execute $query because $!");
I've created an Emacs macro that will allow me to type three keys,
and everything with the exception of the contents of the query are
created. Then I fill in the query and hit alt } and I'm at the next
point in my code. It's much quicker then I ever could have done under
vi.
Throw into that abbreviation mode (you can define "abbreviations", so
type the abbreviation and have it automatically expand, i.e. every time
I type b@p [Email Removed] might be automatically replaced). This,
again, increases my efficiency because I can fly through code and many
common mistakes are automatically corrected.
Now, vi may have support for some of the features I've listed above.
(For instance Vi does have macros, but it's not built atop a programming
language like LISP so I'd assume they're not that powerful...But that's
conjecture). But the point is that ***I*** liked emacs better, so I use
emacs. Because it's more efficient for ***me***. It may be that for
***you*** Ed, or another editor may be a better choice.
I encourage everyone to try out all the alternatives out there to make
up his or her own mind,
-Dan
Bradley A. Brown
Jan 15 2004, 03:31 PM
Nicely put.
Bradley
-----Original Message-----
From: Dan Anderson [mailto:[Email Removed]]
Sent: Thursday, January 15, 2004 10:02 AM
To: Jeff Westman
Cc: Perl Beginners
Subject: RE: Apel of VIM was Emacs Wizards
On Wed, 2004-01-14 at 18:22, Jeff Westman wrote:
QUOTE |
Incidently, emacs has a 'dired mode' (directory editor) which is very nice... much like the old 'list' shareware in DOS land of the dark past.... you can bring up a list of files (like 'ls -l'), then view and selectively execute or delete all that you mark. It's very nice, and it can also be used when accessing remote servers. Not to mention it allows syntax highlighting.
|
Yes, and since Emacs is built on top of a LISP interpreter you can
customize it till your hearts content -- including changing the regular
expressions emacs matches files with in Dired mode.
QUOTE |
As driex pointed out, it is the start-up time that is preferred in vi/vim. But again, a true emacs die-hard never exits the "editor" and does all his/her tasks inside the of it.
|
I'd like to add that emacs allows a "Server Mode". So you start it up
once every time you boot, it runs nicely in the background, and whenever
you need to edit a file you use emacs in client mode (i.e. type
emacsclient instead of emacs).
QUOTE |
Not to mention, the learning curve for emacs is horrific.
|
I spent a lot of time learning both Vi and Emacs when I first came to
the *nix world. Both sides had some very smart people with very good
arguments as to why one was better then the other. So I figured the
best way to figure out which one was best for me was to spend a couple
hours mucking around with each one.
I ended up choosing Emacs because, despite the learning curve, it's a
damned good IDE. In emacs I can view packages, methods, and a bunch of
other code related things in the speedbar, and I have found I code much
faster in Emacs then vi (by over a thousand lines a day).
Most of it boils down to the fact that 30% of code tends to be
reusable. For instance, take the following:
my $query = qq+SELECT * FROM foo WHERE bar = "baz"+;
my $result = $DBI_connection->prepare($query)
or die("Can't prepare $query because $!");
$result->execute
or die("Can't execute $query because $!");
I've created an Emacs macro that will allow me to type three keys,
and everything with the exception of the contents of the query are
created. Then I fill in the query and hit alt } and I'm at the next
point in my code. It's much quicker then I ever could have done under
vi.
Throw into that abbreviation mode (you can define "abbreviations", so
type the abbreviation and have it automatically expand, i.e. every time
I type b@p [Email Removed] might be automatically replaced). This,
again, increases my efficiency because I can fly through code and many
common mistakes are automatically corrected.
Now, vi may have support for some of the features I've listed above.
(For instance Vi does have macros, but it's not built atop a programming
language like LISP so I'd assume they're not that powerful...But that's
conjecture). But the point is that ***I*** liked emacs better, so I use
emacs. Because it's more efficient for ***me***. It may be that for
***you*** Ed, or another editor may be a better choice.
I encourage everyone to try out all the alternatives out there to make
up his or her own mind,
-Dan
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
<http://learn.perl.org/> <http://learn.perl.org/first-response>
David
Jan 15 2004, 10:57 PM
Taylor Lewick wrote:
QUOTE |
Hi all. Need some help.
I have a data file that looks like this...
Date Team Name 1 Team Name 2 Field1 Field2 FieldX
Date Team Name 3 Team Name 4 Field 1 FieldX
and so on...
|
are entries always separate by an empty line?
QUOTE |
Each entry will have the data and team 1 and 2's name. But the number of fields will be variable... I would really like to turn this file into something like this... Date:Team Name 1:Team Name 2:Field1:Field2:FieldX Date:Team Name 3:Team Name 4:Field1:Field2:FieldX
I'm not really sure where to get started. I could load all of the values into an array (The file won't be too big) and print them back out all separated by colons, then run a regular expression to insert a blank line when it detects the date pattern.
|
you don't need to load everything into an array or hash. you can read and
process one entry at a time. assuming the entries are separated by an empty
line, the following works well:
#!/usr/bin/perl -w
use strict;
$/ = "nn";
while(<DATA>){
s/n/:/g; s/:+$//;
print "$_n";
}
__DATA__
Date
Team Name 1
Team Name 2
Field1
Field2
FieldX
Date
Team Name 3
Team Name 4
Field 1
FieldX
__END__
prints:
Date:Team Name 1:Team Name 2:Field1:Field2:FieldX
Date:Team Name 3:Team Name 4:Field 1:FieldX
david
--
sub'_{print"@_ ";* = * __ , & }
sub'__{print"@_ ";* = * ___ , & }
sub'___{print"@_ ";* = * ____ , & }
sub'____{print"@_,n"}&{_+Just}(another)->(Perl)->(Hacker)
Rob Dixon
Jan 16 2004, 01:04 PM
Taylor Lewick wrote:
QUOTE |
I have a data file that looks like this...
Date Team Name 1 Team Name 2 Field1 Field2 FieldX
Date Team Name 3 Team Name 4 Field 1 FieldX
and so on...
Each entry will have the data and team 1 and 2's name. But the number of fields will be variable... I would really like to turn this file into something like this... Date:Team Name 1:Team Name 2:Field1:Field2:FieldX Date:Team Name 3:Team Name 4:Field1:Field2:FieldX
I'm not really sure where to get started. I could load all of the values into an array (The file won't be too big) and print them back out all separated by colons, then run a regular expression to insert a blank line when it detects the date pattern.
I don't know how to go about loading the data into an array or hash, and then printing it out formatted on one line until the next date is detected. Am not sure how to combine those steps.
|
Hi Taylor.
If you set the input record separator - $/ - to a null string then it will
split the input file on one or more blank lines.
Take a look at the program below.
HTH,
Rob
#!perl
use strict;
use warnings;
local $/ = '';
while (<DATA>) {
my @data = split /n/;
print join(':', @data), "n";
}
__DATA__
Date
Team Name 1
Team Name 2
Field1
Field2
FieldX
Date
Team Name 3
Team Name 4
Field 1
FieldX
**OUTPUT
Date:Team Name 1:Team Name 2:Field1:Field2:FieldX
Date:Team Name 3:Team Name 4:Field 1:FieldX
John W. Krahn
Jan 16 2004, 06:52 PM
Rob Dixon wrote:
QUOTE |
If you set the input record separator - $/ - to a null string then it will split the input file on one or more blank lines.
Take a look at the program below.
#!perl use strict; use warnings;
local $/ = '';
while (<DATA>) { my @data = split /n/; print join(':', @data), "n"; }
__DATA__ Date Team Name 1 Team Name 2 Field1 Field2 FieldX
Date Team Name 3 Team Name 4 Field 1 FieldX
**OUTPUT
Date:Team Name 1:Team Name 2:Field1:Field2:FieldX Date:Team Name 3:Team Name 4:Field 1:FieldX
|
TMTOWTDI :-)
#!/usr/bin/perl
use strict;
use warnings;
( $/, $ ) = ( '', "n" );
while ( <DATA> ) {
chomp;
tr/n/:/;
print;
}
__DATA__
Date
Team Name 1
Team Name 2
Field1
Field2
FieldX
Date
Team Name 3
Team Name 4
Field 1
FieldX
John
--
use Perl;
program
fulfillment
John W. Krahn
Jan 16 2004, 08:02 PM
Taylor Lewick wrote:
QUOTE |
One more for everyone... In my perl script, I did a quick cheat by using the systems grep command... I tried: `/usr/bin/grep -v "BLAH" | /usr/bin/grep -v "COW" | /usr/bin/grep -v "STUFF" file1>file2`;
And this doesn't work. Sometimes it will get rid of STUFF. It seems to only act on the last grep I use. I tried escaping the pipes, but that didn't work. Any ideas?
|
Yes, you have the file name in the wrong place. The syntax is "do
something to FILE | pipe data to second process | pipe data to third
process > redirect STDOUT to a file". What you have is "do something to
STDIN | pipe data to second process | pipe data to third process but use
FILE instead > redirect STDOUT to a file". You have to specify the file
name on the first process in the pipeline.
John
--
use Perl;
program
fulfillment
Wiggins D Anconia
Jan 16 2004, 09:16 PM
QUOTE |
Okay, I redid it so it looks like this...
`grep -v "STUFF:STUFF" file1 > file2`; (I am looking for the string STUFF:STUFF and that didn't work... but it works via command line...
Any ideas?
|
What is the "real" goal? Aka why are you shelling out to grep in the
first place? As a side note you should be using full paths for grep,
file1, file2, and you should be checking the return code of the command.
Also it seems silly to use backticks if you are piping STDOUT to a file.
http://danconia.org
John W. Krahn
Jan 16 2004, 09:24 PM
Taylor Lewick wrote:
QUOTE |
Okay, I redid it so it looks like this...
`grep -v "STUFF:STUFF" file1 > file2`;
|
Is that what the ACTUAL line looks like?
QUOTE |
(I am looking for the string STUFF:STUFF and that didn't work... but it works via command line...
Any ideas?
|
Use perl to do it:
open my $in, '<', 'file1' or die "Cannot open file1: $!";
open my $out, '>', 'file2' or die "Cannot open file2: $!";
while ( <$in> ) {
next if /STUFF:STUFF/;
print $out;
}
close $out;
close $in;
John
--
use Perl;
program
fulfillment
Wiggins D Anconia
Jan 16 2004, 09:38 PM
Please bottom post...
QUOTE |
So you recommend using regular expressions instead of grep..? Care to provide an example in this case?
|
John just provided a good one. Optionally if all you care about is
determining whether a line contains a string it might (I didn't
benchmark it) be faster to use 'index' instead of a regex:
perldoc -f index
My complaint is about the use of shelling out to handle something that
can be easily done programmatically within Perl itself, aka like John
showed using two opens and a simple while with the diamond operator (and
conveniently it has more error checking in it, should be faster, is more
secure, less error prone, and portable!). To me shelling out is a last
resort, or a quick fix (aka if you have to ask here it isn't quick enough).
http://danconia.orgQUOTE |
-----Original Message----- From: Wiggins d Anconia [mailto:[Email Removed]] Sent: Friday, January 16, 2004 3:16 PM To: Lewick, Taylor; [Email Removed] Subject: RE: Data File, turn fields on mulitple lines into records on one li ne.. .
Okay, I redid it so it looks like this...
`grep -v "STUFF:STUFF" file1 > file2`; (I am looking for the string STUFF:STUFF and that didn't work... but it works via command line...
Any ideas?
What is the "real" goal? Aka why are you shelling out to grep in the first place? As a side note you should be using full paths for grep, file1, file2, and you should be checking the return code of the command. Also it seems silly to use backticks if you are piping STDOUT to a file.
http://danconia.org
|
John W. Krahn
Jan 16 2004, 11:22 PM
Taylor Lewick wrote:
QUOTE |
From: John W. Krahn [mailto:[Email Removed]]
Taylor Lewick wrote:
Okay, I redid it so it looks like this...
`grep -v "STUFF:STUFF" file1 > file2`;
Is that what the ACTUAL line looks like?
(I am looking for the string STUFF:STUFF and that didn't work... but it works via command line...
Any ideas?
Use perl to do it:
open my $in, '<', 'file1' or die "Cannot open file1: $!"; open my $out, '>', 'file2' or die "Cannot open file2: $!"; while ( <$in> ) { next if /STUFF:STUFF/; print $out; } close $out; close $in;
Okay, will do... One more, what about a sed command that deletes the first 3 spaces of each line... i.e., how would I do this in perl...
sed 's/^ //' file1 > file2
|
open my $in, '<', 'file1' or die "Cannot open file1: $!";
open my $out, '>', 'file2' or die "Cannot open file2: $!";
while ( <$in> ) {
s/^ //;
print $out;
}
close $out;
close $in;
John
--
use Perl;
program
fulfillment
Rob Dixon
Jan 16 2004, 11:26 PM
John W. Krahn wrote:
QUOTE |
TMTOWTDI :-)
#!/usr/bin/perl use strict; use warnings;
( $/, $ ) = ( '', "n" ); while ( <DATA> ) { chomp; tr/n/:/; print; }
|
Rogue!
/R
John W. Krahn
Jan 16 2004, 11:30 PM
Taylor Lewick wrote:
QUOTE |
John thank you for the example, one question about the example code...
It isn't printing anything to my out file, although it does create it.
On the print $out line, I don't need print $out "$_n"; do I?
|
I didn't remove the "n" character from the input line so it doesn't
have to be added to the output line and print() prints the contents of
$_ if nothing other than the filehandle is passed to it.
QUOTE |
Or, the expression /STUFF:STUFF/ What if my line looks like this.. 1 17 7 PM ET:Name:Name:STUFF:STUFF:STUFF Would the example you provided still match this line? I suspect this is the issue but am not sure.
|
What EXACTLY is STUFF? It could contain regex meta-characters which
will cause it to fail. Maybe you should use index() instead (as Wiggins
suggested.)
QUOTE |
Would I need something like /.*STUFF:STUFF/ ?
|
No.
John
--
use Perl;
program
fulfillment
Dan Muey
Jan 17 2004, 07:58 PM
QUOTE |
Most of the scripts I see end in an extension like .jsp, .asp, .dll, or something which says that they aren't perl. Is there a reason more businesses and online companies don't use perl?
|
- People like to spend money for stuff for no goods reason.
- Are those on servers you work with? Those specific ones may use those for whatever reason.
- Some people I know paid to go to school for years to learn crap like asp so if they don't use it they look kind of silly.
- *nix systems come with perl installed and use perl for lots of stuff,
- Mis informed people
- Perl is run as .cgi a lot of times so you may not notice it's Perl like you would the other kinds.
- People look at something shiny and think it must be good. IE(PHP people use CSS to make the utput of their scripts look very sharp, so people assume it must be good, but PHP has so many issues (Don't even get me started or I'll never shut up ;p) I can't stand to use it and when forced to (customer wants PHPBB or something) it ALWAYS a chore to make it work right.
PHP people say "IT runs fast" well use mod_perl and Perl will be faster than PHP and still be way more flexable and usefull.) Same principle applies to most other kinds as well.
Perl is all I use backend and frontend, and I mange a dozens
of servers, networks, and services for variose
isp's and internet service companies Around the united states.
Perl can do about anythign you want,
(I haven't found one practical job I needed to do I couldn't do with Perl)
So the short answer is:
There is no good reason, if they knew what was good for them and
what could boost reliablity, productivity, etcc whiel decreasing costs, time, and resources.
HTH
DMuey
Dan Anderson
Jan 17 2004, 08:06 PM
QUOTE |
- Are those on servers you work with? Those specific ones may use those for whatever reason.
|
No, just whenever I cruise the net I'm always surprised to see scripts
ending in .asp or .jsp. I understand that some people prefer Java to
Perl, but I know there are a lot of people out there who like perl.
Which has made me wonder more then once if in a security through
obscurity approach sites pass perl scripts off as ASP, etc.
For instance, Ebay's servers are run by IBM (hence the big blue IBM logo
on their sites). But all the forms like through to files ending in
..dll. That doesn't make much sense to me, I would think IBM would run
AIX / *nix servers for Ebay.
QUOTE |
- *nix systems come with perl installed and use perl for lots of stuff,
|
Perhaps I should have better said, why isn't it used more on the web?
QUOTE |
- Perl is run as .cgi a lot of times so you may not notice it's Perl like you would the other kinds.
|
Yes, but ASP and JSP end scripts in .asp and .jsp respectively, which
makes me wonder why I don't see less JSP and ASP tags.
Thanks for all your comments,
-Dan
Dan Muey
Jan 17 2004, 08:21 PM
QUOTE |
Which has made me wonder more then once if in a security through obscurity approach sites pass perl scripts off as ASP, etc.
|
Maybe, I don't see why I'd want to make people think I'm using insecure
stuff when I'm really using the best, but maybe.
QUOTE |
For instance, Ebay's servers are run by IBM (hence the big blue IBM logo on their sites). But all the forms like through to files ending in .dll. That doesn't make much sense to me, I would think IBM would run AIX / *nix servers for Ebay.
|
Yeah, Ebay's stuff is really screwy I think.
QUOTE |
- *nix systems come with perl installed and use perl for lots of stuff,
Perhaps I should have better said, why isn't it used more on the web?
- Perl is run as .cgi a lot of times so you may not notice it's Perl like you would the other kinds.
Yes, but ASP and JSP end scripts in .asp and .jsp respectively, which makes me wonder why I don't see less JSP and ASP tags.
|
To combat this I try to use .pl or .plx as of late.
I also suggested before on this list that Perl developers focus on using CSS in their
web site output to make their pages *look* nicer.
(See my whole PHP rant earlier in the thread)
IE - Basically that if a PHP/ASP/JSP/Whatever page *looks* nicer most people don't realize
that PHP/ASP/JSP/Whatever have nothing to do with the way it looks, it's the HTML/CSS/XML
that it outputs that determines the nice looks, So they never realize Perl is more
flexible and powerful.
For instance I was talking to a gentleman who was showing me his new web server ($$$ for Winders and IIS) with his new sexxy web app he was looking forward to using, and he was proud because "He had connections that saved him 10% so he only paid $3000 for it". I was shocked so I looked at his site with him and got a list of it's "awesome features".
That night I did the same thing in Perl and used the html/css from his site for the looks and I showed him the next day and he about died because mine did everything his did, looked the same and it was free. The only differenece was now he had a sort of torn and bleeding feeling in his bottom
;p
QUOTE |
Thanks for all your comments,
-Dan |
Dan Anderson
Jan 17 2004, 08:33 PM
On Sat, 2004-01-17 at 15:21, Dan Muey wrote:
QUOTE |
Which has made me wonder more then once if in a security through obscurity approach sites pass perl scripts off as ASP, etc.
Maybe, I don't see why I'd want to make people think I'm using insecure stuff when I'm really using the best, but maybe.
|
Well just to throw people off. I've often contemplated throwing up a
world readable /scripts directory on my server so anyone scanning my box
would say, "ooooh, insecure IIS" and provide me with enough notice they
were trying to hack me then if, for instance, they said "He's using
Mandrake Linux, better hang around the mailing lists looking for the
latest vulnerability". Of course, there's really not too much of value
on my box besides Nethack bones files so I'm not too worried.
QUOTE |
For instance I was talking to a gentleman who was showing me his new web server ($$$ for Winders and IIS) with his new sexxy web app he was looking forward to using, and he was proud because "He had connections that saved him 10% so he only paid $3000 for it". I was shocked so I looked at his site with him and got a list of it's "awesome features".
That night I did the same thing in Perl and used the html/css from his site for the looks and I showed him the next day and he about died because mine did everything his did, looked the same and it was free. The only differenece was now he had a sort of torn and bleeding feeling in his bottom
|
LOL...
-Dan
Dan Muey
Jan 17 2004, 09:20 PM
QUOTE |
In a job interview last year, I was talking to a company who was in the process of moving their big server application to Java from its current Perl base. They told me they felt like Perl was not ready for professional server environments, but they had had a lot of success with Java. I'm just passing on what the guy said, but I think it's representative of a common mindset.
Perl's a subtle and powerful language. I love that about it, but I think it is pretty easy to do things in less than ideal ways because it gives you so much freedom. That's a strength and a weakness, I think. A little bit of knowledge can be dangerous.
Think about it. How many times do we have to tell people on this list to use strict and warnings, get a module for that, don't slurp big files, etc. If even a percentage of that is happening in enterprise applications because the coders don't know better, perhaps we can see where some of the thinking comes from.
Why is it that all the Java guys I talk to know about JSP, but when I mention mod_perl to people they say "Mod what?" Maybe Perl's public face isn't as strong as some of the alternatives. Maybe Perl lacks a marketing department, being open source, and that hurts it a little. Don't laugh, I'm serious.
|
Good point, similar to my "better looking" argument but "better looking" market wise.
That's what we need to do, use shinier words, "Perl Secure Enterprise Edition - Leveraging the Power of Experience with Reliabilty ", that would be the latest Perl that always has 'use strict' and 'use warnings' running no matter what
the script has in it:
IE #/usr/bin/perl
print "hi";
Maybe a warning gets spit out if the file they are slurping is
over a certain size, also.
And You'd need to use shiny words for describeing it's features:
"Exponentially expand the ease and practicality of development, deployment,
and use with many powerful modules that help you get the job done faster, and more securely."
"Complies with industry standards and functionality."
You'd have to have a cli (running on our Perl S.E.E of course) for each platform that:
- lists/upgrades/installs modules
- upgrades to latest "Perl S.E.E." with one click/command
Have the binary be called perlSEE instead of perl or something.
Looks like we have a busy weekend ahead!
QUOTE |
Of course, that's all just guess work on my part. I'm no expert.
On the flip side, I believe Amazon.com uses a mostly Perl system, just to name a familiar name. There has to be others, I would think.
|
Maybe a website listing should be made/found??
QUOTE |
James
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed] <http://learn.perl.org/> <http://learn.perl.org/first-response |
James Edward Gray II
Jan 17 2004, 09:51 PM
On Jan 17, 2004, at 3:20 PM, Dan Muey wrote:
QUOTE |
Of course, that's all just guess work on my part. I'm no expert.
On the flip side, I believe Amazon.com uses a mostly Perl system, just to name a familiar name. There has to be others, I would think.
Maybe a website listing should be made/found??
|
A recent article on Perl.com covered this a little:
http://www.perl.com/pub/a/2004/01/09/survey.htmlRead the "Programming in the Large" section.
James