John W. Krahn
Sep 5 2003, 03:28 PM
Ramprasad A Padmanabhan wrote:
Hello,
QUOTE |
Suppose I have a huge array of filenames and I want to move them I would like to move 1 chunk at a time on 'n' elements
How Can I efficiently do it ?
something like
@allfiles = (....) # 10000 files @smallchunks = split_to_chunks(@allfiles,100); # This function is what I want to write
foreach (@smallchunks) { my $filelist = join(" ",@{$_}); .... ..... }
|
my @allfiles = (....) # 10000 files
while ( my @smallchunks = splice @allfiles, 0, 100 ) {
my $filelist = "@smallchunks";
}
John
--
use Perl;
program
fulfillment
John Fisher
Sep 5 2003, 05:08 PM
I am trying to figure out how clever it actually is.
I reversed Lu with uL expecting different results and got the same result.
Another Company Name Ltd
Why didn't reversing the metacharacters change the results.
the L escape forces lowercase
When written in lowercase (l and u), they affect only the next character:
$pt=~s/(w+)/uL$1/g
$pt=~s/(w+)/Lu$1/g
> Lu -- isn't perl clever?
David
Sep 5 2003, 06:29 PM
John Fisher wrote:
QUOTE |
I am trying to figure out how clever it actually is. I reversed Lu with uL expecting different results and got the same result. Another Company Name Ltd
Why didn't reversing the metacharacters change the results.
|
[snip]
QUOTE |
$pt=~s/(w+)/uL$1/g
$pt=~s/(w+)/Lu$1/g
|
because Lu and uL is exactly the same:
[panda]$ perl -MO=Deparse -e 's/(w+)/Lu$1/g; s/(w+)/uL$1/g'
s/(w+)/uL$1E/g;
s/(w+)/uL$1E/g;
-e syntax OK
[panda]$
david
-----
$_=q?015001450154015401570040016701570162015401440041?,local$",split$`;**=*_,
map{$#.=qq~chr(@_[$_<<1..$*<<1|3]),~}grep{~$_&1}0..s~.~~g-1;*_=*#,print+eval,
Rob Hanson
Sep 5 2003, 11:37 PM
Windows is a little weird here because of the way long filenames are
supported. You need to use the short name of the directory, which is the
first 6 letters - a tilda - and a number (always 1, unless there multiple
files with the same first 6 chars).
This works for me:
print <c:/progra~1/*.*>;
Rob
-----Original Message-----
From: Robert Citek [mailto:[Email Removed]]
Sent: Friday, September 05, 2003 8:24 PM
To: [Email Removed]
Subject: Re: REPOST - print <c:program files*.*>;
Hello Edward,
At 05:07 PM 9/5/2003 +0800, Edward Yang wrote:
QUOTE |
The problem is I do not get correct result from the following code: print <c:program files*.*>; or print <c:\program files\*.*>;
|
I don't use perl in Windows, but I can simulate a similar result on Linux
or Mac OS X:
mkdir "foo bar"
cd "foo bar"
touch a b c
cd ..
perl -le 'print join("n", <foo bar/*>);
I can get things to work by adding in two back slashes befor the space in
the name:
perl -le 'print join("n", <foo\ bar/*>);
Perhaps this will work with Windows as well.
Regards,
- Robert
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Robert Citek
Sep 5 2003, 11:23 PM
Hello Edward,
At 05:07 PM 9/5/2003 +0800, Edward Yang wrote:
QUOTE |
The problem is I do not get correct result from the following code: print <c:program files*.*>; or print <c:\program files\*.*>;
|
I don't use perl in Windows, but I can simulate a similar result on Linux
or Mac OS X:
mkdir "foo bar"
cd "foo bar"
touch a b c
cd ..
perl -le 'print join("n", <foo bar/*>);
I can get things to work by adding in two back slashes befor the space in
the name:
perl -le 'print join("n", <foo\ bar/*>);
Perhaps this will work with Windows as well.
Regards,
- Robert
David Wall
Sep 6 2003, 12:52 AM
--On Friday, September 05, 2003 2:14 PM +0100 Gary Stainburn
<[Email Removed]> wrote:
QUOTE |
I've got to tidy some data, including converting case. I need to convert
ANOTHER COMPANY NAME LTD **
to
Another Company Name Ltd **
while retaining spaces.
I've tried using split / join / lc / ucfirst which does most of the work but loses the spacings.
I guess that there's a regex that will do this but I'm at a loss how.
|
I'd try using Text::Autoformat to do the bulk of the work, and then do any
necessary "cleanup" afterwards.
John W. Krahn
Sep 6 2003, 08:05 PM
Deb wrote:
Hello,
QUOTE |
Here's some (unfinished) code I am trying to use with Getopt::Std,
#!/usr/local/bin/perl -w # use Getopt::Std; use diagnostics; getopts('hn:');
&usage if (defined $opt_h);
sub usage { print <<"EOM" USAGE: $0 [-h] -n [Email Removed]
-h This message -n <[Email Removed]
EOM
When it's executed, as "test.pl -h" here is what I get in response:
Name "main::opt_h" used only once: possible typo at test.pl line 16 (#1) (W once) Typographical errors often show up as unique variable names. If you had a good reason for having a unique name, then just mention it again somehow to suppress the message. The our declaration is provided for this purpose.
USAGE: test.pl [-h] -n [Email Removed]
-h This message -n <[Email Removed]
The program is functional, but strict settings complain, right?
|
No, you don't have strictures enabled (but you should have.) You are
getting a warning because you have warnings enabled. You are using the
$opt_h variable but you haven't declared it or assigned to it or used it
anywhere else. Getopt::Std creates the $opt_h variable in a different
namespace then your program.
QUOTE |
So what do I do? I putting "my $opt_h" to initialize the variable, but then that just overwrites the setting from the commandline, as you might expect.
What should I do to rid myself of the complaint? As far as I can tell, It's used only once, and that's all I need. So, what am I missing?
|
The best way is to enable strictures and use a lexical hash variable to
hold the options:
#!/usr/local/bin/perl -w
#
use strict;
use Getopt::Std;
use diagnostics;
my %opt;
getopts( 'hn:', %opt );
usage() if exists $opt{ h };
The next best way is to enable stictures and use package variables:
#!/usr/local/bin/perl -w
#
use strict;
use Getopt::Std;
use diagnostics;
our ( $opt_h, $opt_n );
# on older Perls where our() isn't available
# use vars qw( $opt_h, $opt_n );
getopts( 'hn:' );
usage() if defined $opt_h;
QUOTE |
PS- I'm on the digest...
|
Is that painful? BTW I'm on a couch. :-)
John
--
use Perl;
program
fulfillment
Bob Showalter
Sep 7 2003, 07:04 PM
[Email Removed] wrote:
QUOTE |
Is there an function that not suspends the current prog running when executes another script?
|
You need two functions for that: fork() and exec()
See: perldoc -q "How do I start a process in the background?"
R. Joseph Newton
Sep 7 2003, 08:29 PM
deb wrote:
QUOTE |
Hi,
Here's some (unfinished) code I am trying to use with Getopt::Std,
#!/usr/local/bin/perl -w # use Getopt::Std; use diagnostics;
|
Ooops! You started your executable code without
use strict;
[snipped--No point in even scanning it without first letting the error-checking
of the compiler work.]
QUOTE |
When it's executed, as "test.pl -h" here is what I get in response:
Name "main::opt_h" used only once: possible typo at test.pl line 16 (#1) (W once) Typographical errors often show up as unique variable names. If you had a good reason for having a unique name, then just mention it again somehow to suppress the message. The our declaration is provided for this purpose.
USAGE: test.pl [-h] -n [Email Removed]
-h This message -n <[Email Removed]
The program is functional, but strict settings complain, right?
|
No, not right. Functional programs do not generate errors under strict.
Programs that cannot meet strict compilation function, if at all, only by
accident.
Turn strict back on, and repair the errors cited until strict no longer reports
any errors.
That's all the help anyone can really give until you trun strict back on.
Joseph
Bob Showalter
Sep 8 2003, 02:28 PM
Akens, Anthony wrote:
QUOTE |
Sorry for the first post, didn't mean this as a reply.
Hello all...
I'm wanting to write a script that scans a file, ignoring all lines until it reaches a certain section, then processes all lines in that section that are not comments, until it reaches the end of that section.
The section would be designated like this:
## Beging Processing ##
## End Processing ##
So I open my file, and skip all lines until I see that first bit... Then do stuff until I see the last bit. Can someone help me out with this?
Tony
#!/usr/bin/perl -w
use strict;
open (FILE, "<myfile") or die "Could not open Template. ($!)";
while ($line = <FILE>) { #skip until beginning....
#End when "End Processing" is reached last if $line =~ "End Processing";
#Process the lines in between next if $line =~ /^#/; #do stuff.... }
|
The range operator in scalar context can handle this kind of thing. See
perldoc perlop and search for "Range Operators".
while (<FILE>) {
if (/^## Begin/ .. /^## End/) {
...do stuff here with $_
}
}
R. Joseph Newton
Sep 8 2003, 05:57 PM
"Akens, Anthony" wrote:
QUOTE |
The files are all pipe-delimited, so I don't have a problem separating the fields, I just am not sure how to make it remove all extra whitespace. It needs to keep all Space in the fields " the description of the
file " should still be readable as "the description of the file"
Any help with code examples? I have been looking through a beginning book and my old code and have come up nil.
|
[Original post repositioned for readability]
QUOTE |
I figured I'd take a stab at fleshing this out into what he wants... Any comments on things I could do better? I only added to what Robert had coded...
Tony
#!/usr/bin/perl -w
use strict; my $dirname = "/my/stuff/"; my $file; my $newfile; my $line;
opendir (DIR, $dirname) or die "Can't opendir $dirname: $!"; while (defined($file = readdir(DIR))) { next if $file =~ /^..?$/; open (OLDFILE, "< $file"); $newfile = $file . "_nice"; open (NEWFILE, "> $newfile"); while ($line = <OLDFILE>) { ($line) = ($line =~ /^s*(.*)s*n$/); print NEWFILE "$linen"; } close OLDFILE; close NEWFILE; }
|
Way too complicated. The specifications are much more simple: "Remove
extraneous whitespace". This does not reuire any capturing parentheses. Deal
only with whitespace:
while (<IN>) {
chomp;
s/^s*//; #trim start
s/s*$/; #trim end
s/s(2,)/ /g; # eliminate extraneous spce in between
print OUT "$_n";
}
More lines here, but a helluva lot less processing.
Joseph
R. Joseph Newton
Sep 8 2003, 07:05 PM
Dan Muey wrote:
QUOTE |
-----Original Message----- From: Randal L. Schwartz [mailto:[Email Removed]] Sent: Thursday, September 04, 2003 12:33 PM To: [Email Removed] Subject: Re: Test if browser's allows cookies/has them turned onetc..
"Dan" == Dan Muey <[Email Removed]> writes:
Dan> As much as I hate to do stuff that requires cookies, there is a Dan> project I'm doing that requires cookies.
This should have been on [Email Removed] instead. More experts there about this stuff.
Having said that, you should read my "basic cookie management" column at <http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.
I'm told that code was made into a module, but I can't seem to find that reference now.
Cool, that's pretty much the method I was using so I guess I'm not crazy! I agree with your sentiments about cookies in the article. I try to avoid them when ever possible but this one app will require them, either that or I have to make sure the data is passed in every invokation of the script via link or form which might just be worth the trouble.
|
YES!! It definitely is worth the trouble, and it is not that much trouble, if your routing
is well-designed. I haven't used the CGI module much, but I can tell you that
<input type="hidden" name="info_tag" value="whatever is currently useful for this stage">
works quite well, and should be returned as $cgi_object->param{'nfo_tag'}.
Much better than playing with your audience's file system.
Joseph
Dan Muey
Sep 8 2003, 07:11 PM
QUOTE |
Dan Muey wrote:
-----Original Message----- From: Randal L. Schwartz [mailto:[Email Removed]] Sent: Thursday, September 04, 2003 12:33 PM To: [Email Removed] Subject: Re: Test if browser's allows cookies/has them turned onetc..
"Dan" == Dan Muey <[Email Removed]> writes:
Dan> As much as I hate to do stuff that requires cookies, there is a Dan> project I'm doing that requires cookies.
This should have been on [Email Removed] instead. More experts there about this stuff.
Having said that, you should read my "basic cookie management" column at <http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.
I'm told that code was made into a module, but I can't seem to find that reference now.
Cool, that's pretty much the method I was using so I guess I'm not crazy! I agree with your sentiments about cookies in the article. I try to avoid them when ever possible but this one app will require them, either that or I have to make sure the data is passed in every invokation of the script via link or form which might just be worth the trouble.
YES!! It definitely is worth the trouble, and it is not that much trouble, if your routing is well-designed. I haven't used the CGI module much, but I can tell you that <input type="hidden" name="info_tag" value="whatever is currently useful for this stage"> works quite well, and should be returned as $cgi_object->param{'nfo_tag'}.
Much better than playing with your audience's file system.
|
True, the only thing I can't seem to do is this:
Say you have super duper shopping system, that passes shopperid=123456 around in every single form and link so that their cart and whatever info 123456 refers to is available.
Now how can you have a link to the shopping cart from a static page unrelated to the cart, or what if your shopper leaves the site for soemthign else and comes back, or how could they shut their browser down and restart up again, all of those situations and still keep their info all along?
Perhaps, pass the number around and if it is not available(IE one of the above situatios) check for a cookie and if there is no cookie try to set one and simply tell them they need cookies for their session to be remembered?
Cool?
K Old
Sep 8 2003, 07:33 PM
On Mon, 2003-09-08 at 16:11, Dan Muey wrote:
QUOTE |
Dan Muey wrote:
-----Original Message----- From: Randal L. Schwartz [mailto:[Email Removed]] Sent: Thursday, September 04, 2003 12:33 PM To: [Email Removed] Subject: Re: Test if browser's allows cookies/has them turned onetc..
"Dan" == Dan Muey <[Email Removed]> writes:
Dan> As much as I hate to do stuff that requires cookies, there is a Dan> project I'm doing that requires cookies.
This should have been on [Email Removed] instead. More experts there about this stuff.
Having said that, you should read my "basic cookie management" column at <http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.
I'm told that code was made into a module, but I can't seem to find that reference now.
Cool, that's pretty much the method I was using so I guess I'm not crazy! I agree with your sentiments about cookies in the article. I try to avoid them when ever possible but this one app will require them, either that or I have to make sure the data is passed in every invokation of the script via link or form which might just be worth the trouble.
YES!! It definitely is worth the trouble, and it is not that much trouble, if your routing is well-designed. I haven't used the CGI module much, but I can tell you that <input type="hidden" name="info_tag" value="whatever is currently useful for this stage"> works quite well, and should be returned as $cgi_object->param{'nfo_tag'}.
Much better than playing with your audience's file system.
True, the only thing I can't seem to do is this:
Say you have super duper shopping system, that passes shopperid=123456 around in every single form and link so that their cart and whatever info 123456 refers to is available.
Now how can you have a link to the shopping cart from a static page unrelated to the cart, or what if your shopper leaves the site for soemthign else and comes back, or how could they shut their browser down and restart up again, all of those situations and still keep their info all along?
Perhaps, pass the number around and if it is not available(IE one of the above situatios) check for a cookie and if there is no cookie try to set one and simply tell them they need cookies for their session to be remembered?
Cool?
|
Dan,
Ever looked at HTML::Mason? Check out this article on how to display
and hide session variables using httpd.conf (in conjunction with
HTML::Mason of course). It's a great templating engine that runs on top
of mod_perl.
http://www.masonhq.com/user/adpacifico/Apa...s%20and%20mysqlAlso, the Mason Book is available online at
http://www.masonbook.comHTH,
Kevin
--
K Old <[Email Removed]>
Dan Muey
Sep 8 2003, 07:59 PM
QUOTE |
-----Original Message----- From: Randal L. Schwartz [mailto:[Email Removed]] Sent: Thursday, September 04, 2003 12:33 PM To: [Email Removed] Subject: Re: Test if browser's allows cookies/has them turned onetc..
"Dan" == Dan Muey <[Email Removed]> writes:
Dan> As much as I hate to do stuff that requires cookies, there is a Dan> project I'm doing that requires cookies.
This should have been on [Email Removed] instead. More experts there about this stuff.
Having said that, you should read my "basic cookie management" column at <http://www.stonehenge.com/merlyn/WebTechniques/col61.html>.
I'm told that code was made into a module, but I can't seem to find that reference now.
Cool, that's pretty much the method I was using so I guess I'm not crazy! I agree with your sentiments about cookies in the article. I try to avoid them when ever possible but this one app will require them, either that or I have to make sure the data is passed in every invokation of the script via link or form which might just be worth the trouble.
YES!! It definitely is worth the trouble, and it is not that much trouble, if your routing is well-designed. I haven't used the CGI module much, but I can tell you that <input type="hidden" name="info_tag" value="whatever is currently useful for this stage"> works quite well, and should be returned as $cgi_object->param{'nfo_tag'}.
Much better than playing with your audience's file system.
True, the only thing I can't seem to do is this:
Say you have super duper shopping system, that passes shopperid=123456 around in every single form and link so that their cart and whatever info 123456 refers to is available.
Now how can you have a link to the shopping cart from a static page unrelated to the cart, or what if your shopper leaves the site for soemthign else and comes back, or how could they shut their browser down and restart up again, all of those situations and still keep their info all along?
Perhaps, pass the number around and if it is not available(IE one of the above situatios) check for a cookie and if there is no cookie try to set one and simply tell them they need cookies for their session to be remembered?
Cool?
Dan,
Ever looked at HTML::Mason? Check out this article on how to display and hide session variables using httpd.conf (in conjunction with HTML::Mason of course). It's a great templating engine that runs on top of mod_perl.
http://www.masonhq.com/user/adpacifico/Apa...s%20and%20mysql
Also, the Mason Book is available online at http://www.masonbook.com
HTH,
|
Thanks for the idea, I'll look into it. I'm a bit leary of it though since the average Joe would have a hard time just ftping, chmoding, and running it.
And if I'm not mistaken after they close their browser their data will be gone when they next open their browser, correct?
If that's the case it seems like a lot less trouble to just pass the userid=123456 param around since you still have the sam eproblem of remembering them thet nect time they turn their computer on.
Don't get me wrong I hat cookies too and definitely am aware of the security issues, I'm just trying to find a way to remember them if possible over multiple sessions. Without them having to log on.
Thanks for the info!
Dan
R. Joseph Newton
Sep 8 2003, 08:38 PM
David T-G wrote:
QUOTE |
Hi, all --
I'm having some trouble using this wonderful-looking module to tackle catching bounced mail and doing something with it. I've followed the man page to a tee but get errors.
Figuring that y'all can find the man page or don't need it, here is my basic script (with strict and warnings turned on above):
... my $bounce = eval { Mail::DeliveryStatus::BounceParser->new ( *STDIN ) } ;$ if ( $@ ) { print "Whoa -- one we actually couldn't handle!n" ; exit 255 ; } my @addresses = $bounce->addresses; # email address strings ### my @reports = $bounce->reports; # Mail::Header objects ### my $orig_message_id = $bounce->orig_message_id; # "<[Email Removed]>" string ### my $orig_message = $bounce->orig_message; # Mail::Internet object ###
print "WE HAVE orig_message_id AS .$orig_message_id.n"; ### print "WE HAVE orig_message AS .$orig_message.n"; ###
This works well enough except that $orig_message seems to be empty; well, I had an orig message in there but I'm not too worried about that at the moment.
|
I would suggest that you do. Programs do not generally work well if the data is not getting into the variables.
QUOTE |
The real problem is when I go on to say:
print "arrival-date: " ; print $report->get('arrival-date'); print "n" ;
and it pukes with
Global symbol "$report" requires explicit package name at ./catch-bounced-mail.pl line 32.
|
What am I missing? I look at the code posted, and see no declaration for any scalar $report? Is there some
reason you expect the compiler to recognize this identifier?
QUOTE |
What do I need to do to get to each of these reports?
|
which reports? The ones stored in the properly declared array @reposts?
foreach my $report (@reports) {
$report->do_something();
}
Joseph
R. Joseph Newton
Sep 9 2003, 12:36 AM
Christiane Nerz wrote:
QUOTE |
Oh-oh - there was a mistake - I tried chomp, not chmod.. How do I use chomp correctly? I have an array of strings, want to cut off the last n in each line and use the rest of the line. (concatenate it to another string) Jane
|
Return to the original thread [which you should have remained on, by replying to your own post or John''s] for a fairly simple solution.
Joseph
R. Joseph Newton
Sep 9 2003, 02:40 AM
Ned Cunningham wrote:
QUOTE |
Funny you just caught me working on something similar, and I have modified this code for my purposes. This should lead you in the right direction! Snip
#!/usr/bin/perl use Win32::Console;
$StdIn = new Win32::Console(STD_INPUT_HANDLE); my $Password = ""; $StdIn->Mode(ENABLE_PROCESSED_INPUT); print "Enter Password: "; while (my $Data = $StdIn->InputChar(1)) { if("r" eq $Data ) { last; } elsif ("ch" eq $Data ) { if( "" ne chop( $Password )) { print "ch ch"; } next; } $Password .=$Data; print "*"; } print "n $Passwordn"; <STDIN #note take out this print so it doesn't display to the user;)
Ned Cunningham
|
Took a bit of adjustment, but I got it to work on Win2K by setting the autoflush
global to true:
Greetings! E:d_driveperlStuff>perl -w
#!/usr/bin/perl
use Win32::Console;
$StdIn = new Win32::Console(STD_INPUT_HANDLE);
my $Password = "";
$StdIn->Mode(ENABLE_PROCESSED_INPUT);
local $| = 1; #without this, it didn't ever quite work.
print "Enter Password: ";
[snip--as in the above]
<STDIN>
^Z
Enter Password: *************
What the h*** [Asterisks added here for polite company]
Bob Showalter
Sep 9 2003, 12:12 PM
Kevin Pfeiffer wrote:
QUOTE |
I occasionally see things in a script such as: # $Id$
I assume this is for some sort of automated version identification? I use use cvs, but end up having to change version/rev. nos. within scripts/filenames, etc. myself. Maybe I'm missing out...
|
CVS should be updating these automatically, unless you've disabled it. For
further details, see:
http://www.cvshome.org/docs/manual/cvs-1.12.1/cvs_12.html
Jeff 'Japhy' Pinyan
Sep 9 2003, 11:31 AM
On Sep 9, Dan Muey said:
QUOTE |
if -T $data .... if -B $data ....
I never thought of using the file test operators on variables!
|
I'm not so sure you can. But the docs say that -B looks for at least 30%
of the characters to be control-chars or high-bit chars. So I'd suggest:
sub is_binary_data {
local $_ = shift;
(tr/ -~//c / length) >= .3;
}
The tr/ -~//c takes the range of characters from space to tilde (32-126),
inverts it (so characters 0-31 and 127-255), and counts how many of them
are in $_. Then we divide that by the length of the string. If that's at
least .3, that means at least 30% of the string is binary data.
--
Jeff "japhy" Pinyan [Email Removed]
http://www.pobox.com/~japhy/RPI Acacia brother #734
http://www.perlmonks.org/ http://www.cpan.org/<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
David T-G
Sep 9 2003, 01:07 PM
Joseph, et al --
...and then R. Joseph Newton said...
%
% David T-G wrote:
%
% > I'm having some trouble using this wonderful-looking module to tackle
% > catching bounced mail and doing something with it. I've followed the
% > man page to a tee but get errors.
...
% > print "WE HAVE orig_message AS .$orig_message.n"; ###
% >
% > This works well enough except that $orig_message seems to be empty; well,
% > I had an orig message in there but I'm not too worried about that at the
% > moment.
%
% I would suggest that you do. Programs do not generally work well if the data is not getting into the variables.
Fair enough, but since other things worked fine I wasn't worried about
that one variable. As I noted, ...
%
% > The real problem is when I go on to say:
% >
% > print "arrival-date: " ; print $report->get('arrival-date'); print "n" ;
% >
% > and it pukes with
% >
% > Global symbol "$report" requires explicit package name at ./catch-bounced-mail.pl line 32.
%
% What am I missing? I look at the code posted, and see no declaration for any scalar $report? Is there some
% reason you expect the compiler to recognize this identifier?
No, but I didn't know where to find it. As I said, I was following the
man page, which seemed to do a lovely job of laying out the framework of
a script. And yet at this point it fell down...
%
% > What do I need to do to get to each of these reports?
%
% which reports? The ones stored in the properly declared array @reposts?
Yup; those.
%
% foreach my $report (@reports) {
% $report->do_something();
% }
Thanks!
%
% Joseph
HAND
:-D
--
David T-G * There is too much animal courage in
(play) [Email Removed] * society and not sufficient moral courage.
(work) [Email Removed] -- Mary Baker Eddy, "Science and Health"
http://justpickone.org/davidtg/ Shpx gur Pbzzhavpngvbaf Qrprapl Npg!
Tim Johnson
Sep 9 2003, 06:55 PM
If you're viewing it through the newsgroup it might be quicker to use the
mailing list. If you have a client like Outlook that can sort by
Conversation (or topic, or whatever your client calls it), then you can use
it pretty much like a news reader.
-----Original Message-----
From: Rodney Wise [mailto:[Email Removed]]
Sent: Tuesday, September 09, 2003 11:53 AM
To: [Email Removed]
Subject: ? about this NG speed.
I've noticed that it sometimes takes a few hours before my post appear on
this NG (the one I sent before this one is already 4 hours and it still
hasn't showed up). I was wondering if this is common for this NG or is it
simply my experience?
I am posting this one at 2:52 PM EST on 9-9-03
--
....
`..`..`-> rodney
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Bob Showalter
Sep 9 2003, 06:57 PM
Dan Muey wrote:
QUOTE |
I'm using the $] (perl version) variable and was wondering what print "-$]-"; Would output on a 5.6.n or 5.8.n verison of perl where n is greater than 0 Anyone with those versions could you run: perl -e 'print "-$]-";' And send the results to me?
|
$ perl -V:version -e 'print "-$]-n"'
version='5.6.1';
-5.006001-
Kevin Pfeiffer
Sep 9 2003, 08:13 PM
In article <2E4528861499D41199D200A0C9B15BC001D7EAAF@FRISTX>, Bob Showalter
wrote:
QUOTE |
Kevin Pfeiffer wrote: I occasionally see things in a script such as: # $Id$
I assume this is for some sort of automated version identification? I use use cvs, but end up having to change version/rev. nos. within scripts/filenames, etc. myself. Maybe I'm missing out...
CVS should be updating these automatically, unless you've disabled it. For further details, see:
http://www.cvshome.org/docs/manual/cvs-1.12.1/cvs_12.html
|
For me picking up cvs from the docs alone was a miserable experience (no R.
L. Schwartzes and T. Phoenixes). I started using it out of necessity, but
obviously never picked up on some of its finer points. ;-)
After spending a couple hours today setting up a new cvs repository for one
of our servers (and trying out all the features that I had overlooked) I'm
very happy I asked about this.
Thanks!
--
Kevin Pfeiffer
International University Bremen
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
Kevin Pfeiffer
Sep 9 2003, 10:16 PM
In article
<20030905102831.VVOL11401.mta05-svc.ntlworld.com@[10.137.100.64]>, Ged
wrote:
QUOTE |
Hi all,
I am currently learning perl reading all the material I can get my hands on, but have no use for it on a daily basis.
Because of this I am not getting the practice I need on a day-to-day basis to gain more knowledge.
Having covered all the questions in books like 'Learning Perl' etc I need more exercises, if not small projects to further my skills.
Its not easy to think up usefull projects, so my question is, does anybody know of anything on the net to challenge me
|
This list will provide you with more than enough practice material for small
things. Just read the query first and not the answer and then 'solve the
problem'. Granted most things deal with parsing text but even these offer a
chance for practice (practice, practice) with IO, using subroutines,
error-checking, etc. And half the time, the hardest part is "compiling the
question" (if you will), i.e. understanding the problem and its nuances.
Some recent subject lines posted here...
Enumerating list of IP Addresses from a given range
Extracting equal entities from two different sized arrays?
Parsing URL
Best thing is these queries will generate interesting ideas of things you
could do for yourself.
--
Kevin Pfeiffer
International University Bremen
Dan Muey
Sep 10 2003, 06:18 PM
QUOTE |
Howdy,
perldoc perlre on 5.8.0 says that [:ascii:] should match any ascii character and [:^ascii:] is the negate version.
If I do =~m/[:^ascii:]/ or [:ascii:] on astring that is 'hi' it returns true each way, so I believe it says the [] are part of [::] conbstruct which I think means you have to have[[:class:]]
Now [^[:ascii:]] and [[:ascii:]] behave as you'd expect so I think that's all correct ( Please tell me if I'm wrong)
SO my question is:
Which is faster/better/more portable/compliant etc....
[^[:ascii:] or [[:^ascii:]] ??
|
Oops I meant [^[:ascii:]] or [[:^ascii:]] sorry ;p
QUOTE |
TIA
Dan
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
Hari Fajri
Sep 11 2003, 07:44 AM
Thank you Raghavan, its work :)
Sudarshan Raghavan <[Email Removed]>
09/11/2003 03:44 PM
To
[Email Removed]
cc
Subject
Re: Perl Module to print $string in exact possition
Hari Fajri wrote:
QUOTE |
Hi All,
What is perl module to print $string in exact position in sceen. For example: i wanna print "time remaining: 59 second(s)" after that, i want to replace it with: "time remaining: 58 second(s)"
|
Use 'r' (carraige return) instead of 'n' in your print statements and
turn autoflush on. E.g
#!/usr/bin/perl
use strict;
use warnings;
#Turn autoflush on, perldoc perlvar
local $| = 1;
print "Hello Worldr";
sleep (1);
print "Hope things are finer";
sleep (1);
print "n";
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Kevin Pfeiffer
Sep 11 2003, 06:34 PM
In article <3F58AADA.29411.5C84F40@localhost>, Jenda Krynicky wrote:
QUOTE |
From: Gary Stainburn <[Email Removed] I've got to tidy some data, including converting case. I need to convert
ANOTHER COMPANY NAME LTD **
to
Another Company Name Ltd **
while retaining spaces.
$text =~ s/(w+)/Lu$1/g;$y ^^ |
$y? A mysterious Perl variable that I've missed?
--
Kevin Pfeiffer
International University Bremen
Dan Muey
Sep 11 2003, 09:07 PM
QUOTE |
Question: I'm trying to use the links(); function which in the man page says "returns a list of the links found in the last fetched page. " However when I try
@LINKS = $agent->links(); foreach(@LINKS){ print "$_n"; } it returns
WWW::Mechanize::Link=ARRAY(0x84a731c)
Does this mean it's an reference or does it return and array and I'm just using it incorrectly?
|
It is an array reference not an array.
Try this:
for(@{$agent->links()}) { print "-$_-n"; }
or my @LINKS = @{$agent->links()};
`perldoc perlref` for a tutorial
HTH
Dan
QUOTE |
If it is a reference is there a good tutorial around for using them.
Thanks
|
Rob Hanson
Sep 11 2003, 09:08 PM
Each link returned is a WWW::Mechanize::Link object. You need to use the
methods supplied to get the info.
See:
http://search.cpan.org/~petdance/WWW-Mecha...echanize/Link.pm
Use it like this...
@LINKS = $agent->links();
foreach (@LINKS) {
print $_->url(), "n";
print $_->text(), "n";
print $_->name(), "n";
print $_->tag(), "n";
}
Rob
-----Original Message-----
From: Dave Odell [mailto:[Email Removed]]
Sent: Thursday, September 11, 2003 2:16 PM
To: [Email Removed]
Subject: WWW::Mechanize ->links() problem
Question:
I'm trying to use the links(); function which in the man page says
"returns a list of the links found in the last fetched page. "
However when I try
@LINKS = $agent->links();
foreach(@LINKS){
print "$_n";
}
it returns
WWW::Mechanize::Link=ARRAY(0x84a731c)
Does this mean it's an reference or does it return and array and I'm
just using it incorrectly?
If it is a reference is there a good tutorial around for using them.
Thanks
Dan Muey
Sep 11 2003, 09:14 PM
QUOTE |
Question: I'm trying to use the links(); function which in the man page says "returns a list of the links found in the last fetched page. " However when I try
@LINKS = $agent->links(); foreach(@LINKS){ print "$_n"; } it returns
WWW::Mechanize::Link=ARRAY(0x84a731c)
Does this mean it's an reference or does it return and array and I'm just using it incorrectly?
It is an array reference not an array.
Try this:
for(@{$agent->links()}) { print "-$_-n"; }
|
Oops! Didn't know that the array was also a ref.
for(@{$agent->links()}) {
$_->...
Like what Rob said.
}
HTH
Dan
QUOTE |
or my @LINKS = @{$agent->links()};
`perldoc perlref` for a tutorial
HTH
Dan
If it is a reference is there a good tutorial around for using them.
Thanks
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
Wiggins D'Anconia
Sep 11 2003, 09:17 PM
------------------------------------------------
On Thu, 11 Sep 2003 17:07:14 -0500, "Dan Muey" <[Email Removed]> wrote:
QUOTE |
`perldoc perlref` for a tutorial
|
That's the reference. You can also do:
perldoc perlreftut
For a "tutorial". Though I am not sure how recent the Perl needs to be, check perldoc.com if you don't have it.
http://danconia.org
R. Joseph Newton
Sep 12 2003, 05:30 AM
David T-G wrote:
QUOTE |
No, but I didn't know where to find it. As I said, I was following the man page, which seemed to do a lovely job of laying out the framework of a script. And yet at this point it fell down...
|
I've come to feel a bit leery of depending too much n man-pages [aka perldoc for Windows folks. Too many I've seen
are carelessy written.
I think the thing that irritates me the most is to see variables coming into existence out of the blue in coding
examles. I don't feel that they detract from the focus on the subject matter. They do set a bad example of neglect.
Whatever the samples look like, it is always important to use strict on even seemingly inconsequential scripts. Don't
underestimate the force of habit for good or ill.
Happy hacking,
Joseph
Zanardi2k3
Sep 14 2003, 01:05 PM
[Email Removed] (Bob X) wrote:
QUOTE |
"Zanardi2k3" <[Email Removed]> wrote in message I am in a Windows environment, and i love NotaTab. It is one of the few tools that makes me wonder how could i ever have carried on without it. Only it doesn't do syntax highlighting.
Pay the $20 bucks for NoteTab Pro and you get syntax highlighting.
|
Sorry for (very) late reply, but i am running through old posts right
now.
Checking for NoteTab Pro features is the first thing i did. But it still
doesn't do syntax highlighting apart from HTML. So it won't help.
Thank you for your reply.
--
Zanardi2k3
Tim Johnson
Sep 16 2003, 08:45 PM
My best suggestion: consult the list if you're completely stuck, being sure
to articulate your problem, including what you have already tried. Also,
for the best answers, send the appropriate question to the appropriate list.
Go to Perl.org and find the mailing lists for CGI and DBI.
-----Original Message-----
From: Jenda Krynicky [mailto:[Email Removed]]
Sent: Tuesday, September 16, 2003 1:29 PM
To: Perl List
Subject: Re: Any Suggestions for Programmer Needing To Know Perl by
Tomorrow?
From: Dan Anderson <[Email Removed]>
QUOTE |
My local pointy haired boss decided I should learn Perl over the weekend -- specifically to interact with databases and use in CGI programming. With the job market being what it is I said "Sure" and picked up O'Reilly's "Programming Perl". After a lot of reading I think I understand the basic structure of the language pretty well, and even can write some nifty (but perfectly useless) programs.
My question is: when I go in tomorrow and start out is there anything I should know? Any suggestions, comments, or general warnings from more experienced Perl hackers as to what to do and what not to do?
|
I believe you should at least scan through the perl faqs. Run
perldoc perlfaq1
...
perldoc perlfaq9
Plus at least one CGI/WWW related FAQs on
http://www.perl.org/CGI_MetaFAQ.htmlJenda
===== [Email Removed] ===
http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Dan Muey
Sep 16 2003, 10:08 PM
QUOTE |
Hi,
I've been analyzing my SPAM by replying to it lately and find that MOST email addresses where the SPAM originates do not exist.. Nothing new here..
What I'd like to do is to write a script that accesses my pop mail, gets the From: address, verifies it and if it is a valid address, accepts the mail, otherwise, removes it..
Is this feasible or plain wishful thinking ???
|
A bit of both, mostly the latter.
You could start an smtp conversation and look for a bad user error.
But you have ot mess with different error codes/strings and evn after all that, what if they send it as a real account, like viruses do? Then you'll check it, it exists, and still gets through.
It's possible but lots of work and unrelaiable results.
HTH
QUOTE |
I've written perl scripts to handle sending mail and to access pop mail but I'm not sure of being able to do the above ???
I realize this is a bit OFF topic but SPAM is getting to me ;-((
Thanks for your thoughts,
Jerry Rocteur.
Italy did it first... http://www.rocteur.cc/geeklog/public_html/ article.php?story=20030914164349518
-- To unsubscribe, e-mail: [Email Removed] For additional commands, e-mail: [Email Removed]
|
Rob Hanson
Sep 16 2003, 11:20 PM
You will probably run into a few issues. First you need to fetch the MX
record for the domain before you can even connect. After that you could use
the SMTP verify user command to see if the user exists, but I think you
might find that many SMTP servers will not give you a reliable answer. I
think AOL, for example, will always tell you that the user exists (I may be
wrong though).
I think you might be better off with Spam Assassin, or using an ISP that
uses it.
On the other hand, it can't hurt to try doing it yourself.
Rob
-----Original Message-----
From: Jerry Rocteur [mailto:[Email Removed]]
Sent: Tuesday, September 16, 2003 5:33 PM
To: [Email Removed]
Subject: OT: Conceptual -- Spam stopper script
Hi,
I've been analyzing my SPAM by replying to it lately and find that MOST
email addresses where the SPAM originates do not exist.. Nothing new
here..
What I'd like to do is to write a script that accesses my pop mail,
gets the From: address, verifies it and if it is a valid address,
accepts the mail, otherwise, removes it..
Is this feasible or plain wishful thinking ???
I've written perl scripts to handle sending mail and to access pop
mail but I'm not sure of being able to do the above ???
I realize this is a bit OFF topic but SPAM is getting to me ;-((
Thanks for your thoughts,
Jerry Rocteur.
Italy did it first...
http://www.rocteur.cc/geeklog/public_html/ article.php?story=20030914164349518
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
Stephen Hardisty
Sep 17 2003, 07:29 AM
You could try SpamAssassin (www.spamassassin.org). Quite effective rule based blocking.
A lot (if not most) Spam emails come from real email addresses, they just don't belong to the guy that sent the email. For the Spammers that use their own email addresses (be it Yahoo or Hotmail etc.), if you reply they'll know your email address is 'real' and you'll receive 10X more, so be careful.
SMTP has a command called 'RCPT TO: [Email Removed]', this will return 250 if the email address exists on that server (see
http://cr.yp.to/smtp.html). You can send real-time SMTP commands using the Net::Cmd module. There is one great big downside to this though (I think) the Qmail SMTP server will return '250' to every email address also some legitimate newsletters don't use 'real' email addresses either.
Good luck!
-----Original Message-----
From: Jerry Rocteur [mailto:[Email Removed]]
Sent: 16 September 2003 22:33
To: [Email Removed]
Subject: OT: Conceptual -- Spam stopper script
Hi,
I've been analyzing my SPAM by replying to it lately and find that MOST
email addresses where the SPAM originates do not exist.. Nothing new
here..
What I'd like to do is to write a script that accesses my pop mail,
gets the From: address, verifies it and if it is a valid address,
accepts the mail, otherwise, removes it..
Is this feasible or plain wishful thinking ???
I've written perl scripts to handle sending mail and to access pop
mail but I'm not sure of being able to do the above ???
I realize this is a bit OFF topic but SPAM is getting to me ;-((
Thanks for your thoughts,
Jerry Rocteur.
Italy did it first...
http://www.rocteur.cc/geeklog/public_html/ article.php?story=20030914164349518
--
To unsubscribe, e-mail: [Email Removed]
For additional commands, e-mail: [Email Removed]
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com________________________________________________________________________
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com________________________________________________________________________
The only solutions I've discovered is:
( for less secure tables)
1. Crypt the password
2. Put it into directory not in the public domain
3. Set the permissions set only for your scripts.
( for more secure tables)
1. I would gather sensitive info last if possible.
2. Do not put the password on the server.
3. It would have to gathered with a form and you have to have ssl. Then
track the password and page state with javascript. Always use post in your
forms method attribute. Any links on your page should have a target attribut of
_blank so as not to lose tracking or display the password in the address bar.
If you find any other solutions please let me know.
Here is some javascript that I use for maintaining state in my scripts.
Alter the script to your own variables where applicable.
******************* Maintaining page state
**************************
function setpage(){
// append the links with thier email
//document.write(document.links.length+" links <BR>");
var sep = "&";
for(var i=0;i<document.links.length;i++){
if(document.links[i].href.indexOf("?") == -1){
sep = "?";
}
else{sep = "&";
}
if((document.links[i].href.indexOf("paypal") == -1) &&
(document.links[i].href.indexOf("UpSeason") == -1)){
document.links[i].href=document.links[i].href+sep+"Cemail="+Cemail+"&
demo="+demo+"&season="+season;
}
}
for(var i=0;i<document.forms.length;i++){
if(document.forms[i]){
for(var k=0;k<document.forms[i].elements.length;k++){
if(document.forms[i].elements[k].name == "Cemail"){
if(Cemail == ""){Cemail = document.forms[i].Cemail.value;}
document.forms[i].Cemail.value = Cemail;
}
if(document.forms[i].elements[k].name == "season"){
if(season == ""){season = document.forms[i].season.value;}
document.forms[i].season.value = season;
}
if(document.forms[i].elements[k].name == "demo"){
//try to set the value first if it's empty
if(demo == ""){demo = document.forms[i].demo.value;}
document.forms[i].demo.value = demo;
}
}
}
}
}
**************************** end
**********************************
CGI.pm also maintains state if a variable is repeatedly called.
Also you would have to have a separate table for each user.
Zsdc
Sep 17 2003, 08:58 AM
Hanson, Rob wrote:
QUOTE |
You will probably run into a few issues. First you need to fetch the MX record for the domain before you can even connect. After that you could use the SMTP verify user command to see if the user exists,
|
....or just use Email::Valid module.
QUOTE |
but I think you might find that many SMTP servers will not give you a reliable answer. I think AOL, for example, will always tell you that the user exists (I may be wrong though).
|
Basicaly you cannot know for sure if any given email address is valid.
You'd have to send an actual email, wait some time for bounces, and even
then you wouldn't be sure. This is why websites requiring email address
often send password in email during the registration (which is
completely insecure but makes sure the email is valid).
QUOTE |
I think you might be better off with Spam Assassin, or using an ISP that uses it.
|
I agree.
QUOTE |
On the other hand, it can't hurt to try doing it yourself.
|
If we don't count the DOSing and lots of false positives then of course
it can't hurt.
--
ZSDC Perl and Systems Security Consulting
Jeff 'Japhy' Pinyan
Sep 17 2003, 10:26 AM
On Sep 17, NYIMI Jose (BMB) said:
QUOTE |
Let say the known length is 2. If the string is 'abcd', my array should be ('ab', 'dc') And if my string is 'abcdef', my array should be ('ab', 'dc', 'ef').
|
I'd just use:
@groups = $string =~ /../g; # use ... for three, or .{3}, etc.
You don't need capturing parens in this case.
--
Jeff "japhy" Pinyan [Email Removed]
http://www.pobox.com/~japhy/RPI Acacia brother #734
http://www.perlmonks.org/ http://www.cpan.org/<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Jeff 'Japhy' Pinyan
Sep 17 2003, 11:27 AM
On Sep 17, Jeff 'japhy' Pinyan said:
QUOTE |
On Sep 17, NYIMI Jose (BMB) said:
Let say the known length is 2. If the string is 'abcd', my array should be ('ab', 'dc') And if my string is 'abcdef', my array should be ('ab', 'dc', 'ef').
I'd just use:
@groups = $string =~ /../g; # use ... for three, or .{3}, etc.
You don't need capturing parens in this case.
|
Although it should probably be /../gs, since . doesn't match newlines by
default. And following the lead of other regex solutions, you could use
the .{1,$x} approach.
@groups = $string =~ /.{1,$x}/gs;
--
Jeff "japhy" Pinyan [Email Removed]
http://www.pobox.com/~japhy/RPI Acacia brother #734
http://www.perlmonks.org/ http://www.cpan.org/<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
Zsdc
Sep 17 2003, 11:50 AM
zsdc wrote:
QUOTE |
Hanson, Rob wrote:
You will probably run into a few issues. First you need to fetch the MX record for the domain before you can even connect. After that you could use the SMTP verify user command to see if the user exists,
...or just use Email::Valid module.
|
Sorry, I meant Mail::CheckUser module.
--
ZSDC Perl and Systems Security Consulting
Stephen Hardisty
Sep 17 2003, 01:38 PM
Hi,
you can use split for this sort of thing. For example:
my $string = "hello there";
# add an extra '.' for every character you want
my @pairs = split(/(..)/, $string);
The only thing you want to be careful about is empty quotes/nothing (e.g. ''). For example, if we wanted to print the character pairs:
foreach(@pairs)
{
# we'll skip on the empty elements
if($_ eq '')
{
next;
}
# print each pair, preceded by a *
# you could push onto another array instead
print "*$_";
}
Can't think of anything more code efficient at the moment but I hope this helps.
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com________________________________________________________________________
Charles K. Clarkson
Sep 17 2003, 01:59 PM
NYIMI Jose (BMB) <[Email Removed]> wrote:
:
: I mean writing :
: my @items = unpack('A2 A2', $str);
: Will work for $str='abdc';
: Not for $str='abcdef';
:
: Any ideas ?
use POSIX 'ceil';
my $size = 4;
my @items = unpack "A$size" x ceil( (length $string) / $size ), $string;
OR:
use Data::Dumper;
use POSIX 'ceil';
print Dumper fixed_split( 6, '12345678' );
sub fixed_split {
return [ unpack "A$_[0]" x ceil( ( length $_[1] ) / $_[0] ), $_[1] ];
}
HTH,
Charles K. Clarkson
--
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
Rob Dixon
Sep 17 2003, 02:27 PM
Nyimi Jose wrote:
QUOTE |
I have a string which i know, it is a concatenation of "fixed length of substring". I would like to split it based on this known length and get as result An array containing each substring.
Let say the known length is 2. If the string is 'abcd', my array should be ('ab', 'dc') And if my string is 'abcdef', my array should be ('ab', 'dc', 'ef').
I was thinking about unpack function but how to make it dynamic?
I mean writing : my @items = unpack('A2 A2', $str); Will work for $str='abdc'; Not for $str='abcdef';
Any ideas ?
|
Hi Nyimi.
The subroutine 'split_len' below will do what you want.
HTH,
Rob
use strict;
use warnings;
my $string = join '', 'A' .. 'Z';
print map "$_n", split_len(7, $string);
sub split_len {
my ($len, $string) = @_;
$string =~ m/.{1,$len}/g;
}
OUTPUT
ABCDEFG
HIJKLMN
OPQRSTU
VWXYZ
John W. Krahn
Sep 17 2003, 03:33 PM
Nyimi Jose wrote:
QUOTE |
Do you see any pitfall if i remove the 'm' on the regexp And use $string =~ /.{1,$len}/g; instead ?
I have tried without the 'm', it works as well :-)
|
If you use // to delimit the regular expression then the 'm' is not
required. In other words, m// and // are exactly the same.
John
--
use Perl;
program
fulfillment
Dan Muey
Sep 17 2003, 03:45 PM
Howdy
QUOTE |
you can use split for this sort of thing. For example:
my $string = "hello there";
# add an extra '.' for every character you want my @pairs = split(/(..)/, $string);
The only thing you want to be careful about is empty quotes/nothing (e.g. ''). For example, if we wanted to print the character pairs:
foreach(@pairs) { # we'll skip on the empty elements if($_ eq '') { next; }
# print each pair, preceded by a * # you could push onto another array instead print "*$_"; }
Can't think of anything more code efficient at the moment but I hope this helps.
|
How about this instead of a zillion lines?
for(split(/(..)/, $string)) { print "*$_" if $_; }
Although wouldn't that mean every second pair of characters would be missing?
But as for efficiency or just plain, one line sexxyness that look swell to me!
HTH
Dmuey
Jerry Rocteur
Sep 17 2003, 04:44 PM
Thanks Guys...
Perhaps one day the SMTP protocol will be rewritten to perform checks
on the sender, perhaps one day .....
Thanks for all your thoughts..
Jerry
On Wednesday, Sep 17, 2003, at 11:58 Europe/Brussels, zsdc wrote:
QUOTE |
Hanson, Rob wrote:
You will probably run into a few issues. First you need to fetch the MX record for the domain before you can even connect. After that you could use the SMTP verify user command to see if the user exists,
...or just use Email::Valid module.
but I think you might find that many SMTP servers will not give you a reliable answer. I think AOL, for example, will always tell you that the user exists (I may be wrong though).
Basicaly you cannot know for sure if any given email address is valid. You'd have to send an actual email, wait some time for bounces, and even then you wouldn't be sure. This is why websites requiring email address often send password in email during the registration (which is completely insecure but makes sure the email is valid).
I think you might be better off with Spam Assassin, or using an ISP that uses it.
I agree.
On the other hand, it can't hurt to try doing it yourself.
If we don't count the DOSing and lots of false positives then of course it can't hurt.
-- ZSDC Perl and Systems Security Consulting
|
Dan Anderson
Sep 17 2003, 05:31 PM
QUOTE |
Perhaps one day the SMTP protocol will be rewritten to perform checks on the sender, perhaps one day .....
|
You know it is interesting to think about what would be more efficient
(resource wise): current SMTP or SMTP with back checking. Because you
would use resources by checking addresses (and spammers could create
valid e-mail addresses) but spam might be squelched because it was
harder to spam.
-Dan