Re: deleting elements of an array and push into new
- Original Message - From: "Ramprasad" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, January 03, 2003 1:48 AM Subject: deleting elements of an array and push into new > Hello all, > I have to remove elements from an array if they match a particualr > string and put it into another array > > eg if element matches index or default I want it to be in a new array > > I am trying this > my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); > > > # the following does not compile > #map {s/^(index|default).*/{push @new,$_}/e && delete $_ } @arr; > > > #This works but it does not remove the array element > map {s/^(index|default).*/{push @new,$_}/e && undef $_ } @arr; There is probably a mroe elegant way of doing this, but... my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); my @new; my $count=0; for(@arr) { if(/^(index|default).*/) { push @new,$_; @arr=@arr[0..$count-1,$count+1..$#arr]; } $count++; } print Dumper([\@new,\@arr]); Shawn [snip] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Brand new to Perl
"Wiggins D'Anconia" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > ActivePerl is free. > That's what I was trying to say :) /R -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
XML::Mini question
Hi, I'm using XML::Mini to parse and print the contents of an xml file. The xml file has one root tag "" and identcal children "" which has 2 attributes "id & name" and 6 children " , , " " Since their can be any number of "" tags in the xml document at any one time, however, at all times, the stock tag will have two attributes and 6 children to go with it (preview attached). Is their any flexible way to parse this xml file?. -- Mathew McBride [EMAIL PROTECTED] 1.00 1.05 1.03 1,000 1.50 1.05 1.03 5,000 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question re POP3 module
Hello All, Perhaps someone can help me understand what I am doing wrong. I am trying to write a program that will manipulate my various POP3 mail boxes on the net. I seem to be having a problem with the get method in the Net::POP3 module. I am trying to read a message into an array and then print each message in the array. The print command only seems to give me the scalar value to the array and the characters in the array. Here is the test program I have created. Can someone give me a quick pointer to what I am doing wrong? Thanks! Mark #!/usr/bin/perl use Net::POP3; use strict; my $username = 'foouser'; my $password = 'secret'; my $host = 'pop.foo.com'; print "creating handel\n"; my $h=Net::POP3->new($host); print "setting username\n"; $h->user($username); print "setting password\n"; print("there are ", my $last=$h->pass($password), " messages\n\n") ; my @message = $h->top(1); while (@message) { print $_; } $h->quit(); exit(0);
Question re POP3 module
Hello All, Perhaps someone can help me understand what I am doing wrong. I am trying to write a program that will manipulate my various POP3 mail boxes on the net. I seem to be having a problem with the get method in the Net::POP3 module. I am trying to read a message into an array and then print each message in the array. The print command only seems to give me the scalar value to the array and the characters in the array. Here is the test program I have created. Can someone give me a quick pointer to what I am doing wrong? Thanks! Mark #!/usr/bin/perl use Net::POP3; use strict; my $username = 'foouser'; my $password = 'secret'; my $host = 'pop.foo.com'; print "creating handel\n"; my $h=Net::POP3->new($host); print "setting username\n"; $h->user($username); print "setting password\n"; print("there are ", my $last=$h->pass($password), " messages\n\n") ; # START This is where things go wrong. my @message = $h->top(1); while (@message) { print $_; } $h->quit(); exit(0); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Output PERL to E-mail
Well, here's how I do it...using sendmail on a *nix machine. my $MAILFROM = '[EMAIL PROTECTED]'; my $MAILSUBJECT = "subject goes here"; my $MAILTO = '[EMAIL PROTECTED],[EMAIL PROTECTED]'; # or "user1\@domain.com" open(SENDMAIL, "| /usr/lib/sendmail $MAILTO") || die; print(SENDMAIL "From: $MAILFROM\nTo: $MAILTO\nSubject: $MAILSUBJECT\n\n"); print(SENDMAIL "Put your output here"); close(SENDMAIL) || die; One way of many... Regards, Danny -Original Message- From: Derek Brinson [mailto:[EMAIL PROTECTED]] Sent: Thursday, January 02, 2003 6:42 PM To: [EMAIL PROTECTED] Subject: Output PERL to E-mail I have a PERL installed on a WinIIS box. This script queries a (SQL) database, makes a few minor manipulations to that data, then builds a small paragraph of text, from there. So, how do I send that text info to an e-mail address (gathered from that same database)? How about several e-ddresses? Surely there are several ways to do this. Isn't there a specific PERL statement especially for this kind of thing? I *do* have FormMail running on another machince (a UNIX/Apache Web Server) on the same network. Would that be easier? More secure? How would I finish this task that way? It is politically necessary avoid any M$ solutions, if possible. Any other, better tacts/suggestions? Please fire away. Yours, -dB- [EMAIL PROTECTED] Web Master/Web Manager/Computer Consultant II North Carolina Central University 712 Cecil Street Suite # 3014 (or 3010) New Education Bldg. - NCCU Campus Durham, NC 27707 Tele: (919) 530-7151 Fax: 530-5097 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: deleting elements of an array and push into new
Ramprasad wrote: > Hello all, > I have to remove elements from an array if they match a particualr > string and put it into another array > > eg if element matches index or default I want it to be in a new array > > I am trying this > my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); > > > # the following does not compile > #map {s/^(index|default).*/{push @new,$_}/e && delete $_ } @arr; > > > #This works but it does not remove the array element > map {s/^(index|default).*/{push @new,$_}/e && undef $_ } @arr; > > print Dumper([\@new,\@arr]); > > I get > $VAR1 = [ >[ > 'index.html' >], >[ > '01.html', > undef, > 'aa.html', > 'bb.html', > 'cc.html', > 'dd.html' >] > ]; > > the element $arr[1] is undefed but not removed from the array > > > Can I delete the element somehow > I am going to run this for about 60,000 arrays and I cant afford > needless if's and foreach's You want the splice() function. Here's one approach. I'm sure somebody can come up with one-liner... #!/usr/bin/perl use strict; my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); my @new; my $n = 0; while ($n < @arr) { push(@new, splice(@arr, $n, 1)), next if $arr[$n] =~ /^(index|default)/; $n++; } print "@arr\n"; print "@new\n"; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Question re POP3 module
See inline. On Fri, 3 Jan 2003 00:23:01 +0100, "Mark Troyer" <[EMAIL PROTECTED]> wrote: > Hello All, > > Perhaps someone can help me understand what I am doing wrong. I am > trying to write a program that will manipulate my various POP3 mail > boxes on the net. I seem to be having a problem with the get method in > the Net::POP3 module. I am trying to read a message into an array and > then print each message in the array. The print command only seems to > give me the scalar value to the array and the characters in the array. > Here is the test program I have created. Can someone give me a quick > pointer to what I am doing wrong? > > Thanks! > > Mark > > #!/usr/bin/perl > > use Net::POP3; > use strict; > > my $username = 'foouser'; > my $password = 'secret'; > my $host = 'pop.foo.com'; > > print "creating handel\n"; > my $h=Net::POP3->new($host); > > print "setting username\n"; > $h->user($username); > > print "setting password\n"; > print("there are ", my $last=$h->pass($password), " messages\n\n") ; > > my @message = $h->top(1); > my $message = $h->top(1); It appears 'top' returns a reference to an array rather than an array. > while (@message) { while (@$message) { > print $_; > } > > $h->quit(); > > > exit(0); > This should help if the docs are correct, but I haven't done development with this module yet. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Sent time in a Net::SMTP mail
Hi all, Please help me sort the following two issues : 1 ) I cannot display the Sent time in MS Outlook in a mail generated using Net::SMTP. With the code I am using , the Sent field in the Outlook pane comes blank. 2 ) I cannot reply to the mail received using this code.The email address information is lost on using names instead of email addresses in the To and Cc tabs. How can I display names and allow a reply-to-all too ? Here is the code I am using : - use Net::SMTP; $sender = '[EMAIL PROTECTED]'; $subject = "Just a test...pls ignore"; $body = "\n IMPORTANT: This information is for internal authorized use only. "; my $smtp = Net::SMTP->new('my_mail_server_name');#what mailserver to use # Sender's Address $smtp->mail('[EMAIL PROTECTED]'); # Who will receive the notification mail? $smtp->to('[EMAIL PROTECTED]','[EMAIL PROTECTED]','[EMAIL PROTECTED]' ); #place the actual data within the email $smtp->data(); $smtp->datasend("Content-type: text/html\n"); $smtp->datasend("From: Aman Thind\n"); $smtp->datasend("To : Aman Thind\n"); $smtp->datasend("Cc : Shishir Saxena; Manish Kashyap\n"); $smtp->datasend("Subject : ".$subject."\n"); #Here is the body $smtp->datasend("\n"); $smtp->datasend($body); $smtp->dataend(); $smtp->quit; - Thanks aman -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Output PERL to E-mail
From: "David H. Lynch Jr." <[EMAIL PROTECTED]> > Below is a perlscript to do approximately what you asked. I found it > somewhere else on the web. Unfortunately I do not remember where, and > I have seen several similar. It is pretty basic anyway. > > #!/usr/bin/Perl > > use MIME::QuotedPrint; > use MIME::Base64; > use Mail::Sendmail 0.75; # doesn't work with v. 0.74! > > $file = $ARGV[0] ; > $to = $ARGV[1] ; > $msg = $ARGV[2] ; > > %mail = ( > SMTP => 'mail.yourdomain.com', > from => '[EMAIL PROTECTED]', > to => "$to", > subject => "This is your e-mail subject", > ); > > > $boundary = "" . time() . ""; > $mail{'content-type'} = "multipart/mixed; boundary=\"$boundary\""; ... use Mail::Sender; $file = $ARGV[0] ; $to = $ARGV[1] ; $msg = $ARGV[2] ; my $sender = new Mail::Sender {smtp => 'mail.yourdomain.com'}; die "Can't send the email: $Mail::Sender::Error\n" unless ref $sender; if (! ref $sender->MailFile({ from => '[EMAIL PROTECTED]', to => $to, subject => "This is your e-mail subject", msg => $msg, file => $file, b_encoding => 'quoted-printable', b_ctype => 'text/plain; charset="iso-8859-1"' })) { die "Can't send the email: $Mail::Sender::Error\n"; } Jenda (Untested, but should be fine.) = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sent time in a Net::SMTP mail
From: Aman Thind <[EMAIL PROTECTED]> > Please help me sort the following two issues : See below. > 1 ) I cannot display the Sent time in MS Outlook in a mail generated > using Net::SMTP. > With the code I am using , the Sent field in the Outlook pane > comes > blank. > > 2 ) I cannot reply to the mail received using this code.The email > address information is lost on using names instead of email addresses > in the To and Cc tabs. How can I display names and allow a > reply-to-all too ? > > > Here is the code I am using : > > -- > -- - > > use Net::SMTP; > > $sender = '[EMAIL PROTECTED]'; > > $subject = "Just a test...pls ignore"; > > $body = "\n > > > red>IMPORTANT: This information is for internal > authorized use only. > > > > >"; > > my $smtp = Net::SMTP->new('my_mail_server_name'); > #what mailserver to use > # Sender's Address > $smtp->mail('[EMAIL PROTECTED]'); > # Who will receive the notification mail? > > $smtp->to('[EMAIL PROTECTED]','[EMAIL PROTECTED]','mkashyap@quark. > co.in' ); > > #place the actual data within the email > $smtp->data(); > $smtp->datasend("Content-type: text/html\n"); #time diference to GMT - Windows will not set $ENV{'TZ'}, if you know a better way ... my $GMTdiff; { my $time = time(); my @local = (localtime($time))[2,1,3,4,5]; # hour, minute, mday, month, year; I don't mind year is 1900 based and month 0-11 my @gm = (gmtime($time))[2,1,3,4,5]; my $diffdate = ($gm[4]*512*32 + $gm[3]*32 + $gm[2]) <=> ($local[4]*512*32 + $local[3]*32 + $local[2]); # I know there are 12 months and 365-366 days. Any bigger numbers work fine as well ;-) if ($diffdate > 0) {$gm[0]+=24} elsif ($diffdate < 0) {$local[0]+=24} my $hourdiff = $gm[0]-$local[0]; my $mindiff; if (abs($gm[1]-$local[1])<5) { $mindiff = 0 } elsif (abs($gm[1]-$local[1]-30) <5) { $mindiff = 30 } elsif (abs($gm[1]-$local[1]-60) <5) { $mindiff = 0; $hourdiff ++; } $GMTdiff = ($hourdiff < 0 ? '+' : '-') . sprintf "%02d%02d", abs($hourdiff), $mindiff; } my $date = localtime(); $date =~ s/^(\w+)\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)$/$1, $3 $2 $5 $4/; $smtp->datasend("Date: $date $GMTdiff\n"; > $smtp->datasend("From: Aman Thind\n"); $smtp->datasend("From: \"Aman Thind\" <[EMAIL PROTECTED]>\n"); Same for the other addresses. > $smtp->datasend("To : Aman Thind\n"); > $smtp->datasend("Cc : Shishir Saxena; Manish Kashyap\n"); > $smtp->datasend("Subject : ".$subject."\n"); > #Here is the body > $smtp->datasend("\n"); > $smtp->datasend($body); > $smtp->dataend(); > $smtp->quit; HTH, Jenda = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sent time in a Net::SMTP mail
Thanks a lot Jenda...u're a real wizard :) There are still just two minor issues which I thought I should bring to your notice... The time displayed is 30 mins more than the actual time here. The To \ From tab now reads : Aman Thind [[EMAIL PROTECTED]]. Can't I just do away with the email address ? Thanks again aman -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 7:38 PM To: [EMAIL PROTECTED] Subject: Re: Sent time in a Net::SMTP mail From: Aman Thind <[EMAIL PROTECTED]> > Please help me sort the following two issues : See below. > 1 ) I cannot display the Sent time in MS Outlook in a mail generated > using Net::SMTP. > With the code I am using , the Sent field in the Outlook pane > comes > blank. > > 2 ) I cannot reply to the mail received using this code.The email > address information is lost on using names instead of email addresses > in the To and Cc tabs. How can I display names and allow a > reply-to-all too ? > > > Here is the code I am using : > > -- > -- - > > use Net::SMTP; > > $sender = '[EMAIL PROTECTED]'; > > $subject = "Just a test...pls ignore"; > > $body = "\n > > > red>IMPORTANT: This information is for internal > authorized use only. > > > > >"; > > my $smtp = Net::SMTP->new('my_mail_server_name'); > #what mailserver to use > # Sender's Address > $smtp->mail('[EMAIL PROTECTED]'); > # Who will receive the notification mail? > > $smtp->to('[EMAIL PROTECTED]','[EMAIL PROTECTED]','mkashyap@quark. > co.in' ); > > #place the actual data within the email > $smtp->data(); > $smtp->datasend("Content-type: text/html\n"); #time diference to GMT - Windows will not set $ENV{'TZ'}, if you know a better way ... my $GMTdiff; { my $time = time(); my @local = (localtime($time))[2,1,3,4,5]; # hour, minute, mday, month, year; I don't mind year is 1900 based and month 0-11 my @gm = (gmtime($time))[2,1,3,4,5]; my $diffdate = ($gm[4]*512*32 + $gm[3]*32 + $gm[2]) <=> ($local[4]*512*32 + $local[3]*32 + $local[2]); # I know there are 12 months and 365-366 days. Any bigger numbers work fine as well ;-) if ($diffdate > 0) {$gm[0]+=24} elsif ($diffdate < 0) {$local[0]+=24} my $hourdiff = $gm[0]-$local[0]; my $mindiff; if (abs($gm[1]-$local[1])<5) { $mindiff = 0 } elsif (abs($gm[1]-$local[1]-30) <5) { $mindiff = 30 } elsif (abs($gm[1]-$local[1]-60) <5) { $mindiff = 0; $hourdiff ++; } $GMTdiff = ($hourdiff < 0 ? '+' : '-') . sprintf "%02d%02d", abs($hourdiff), $mindiff; } my $date = localtime(); $date =~ s/^(\w+)\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)$/$1, $3 $2 $5 $4/; $smtp->datasend("Date: $date $GMTdiff\n"; > $smtp->datasend("From: Aman Thind\n"); $smtp->datasend("From: \"Aman Thind\" <[EMAIL PROTECTED]>\n"); Same for the other addresses. > $smtp->datasend("To : Aman Thind\n"); > $smtp->datasend("Cc : Shishir Saxena; Manish Kashyap\n"); > $smtp->datasend("Subject : ".$subject."\n"); > #Here is the body > $smtp->datasend("\n"); > $smtp->datasend($body); > $smtp->dataend(); > $smtp->quit; HTH, Jenda = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sent time in a Net::SMTP mail
From: Aman Thind <[EMAIL PROTECTED]> > Thanks a lot Jenda...u're a real wizard :) Shame I can't even get drunk :-} > There are still just two minor issues which I thought I should bring > to your notice... > > The time displayed is 30 mins more than the actual time here. Are you sure the timezone is set correctly on your computer? Could you see what do these two print? print scalar(localtime)."\n"; print scalar(gmtime)."\n"; Do the times look correct? > The To \ From tab now reads : Aman Thind [[EMAIL PROTECTED]]. > Can't I just do away with the email address ? I don't think so. Jenda = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sent time in a Net::SMTP mail
Hi Jenda Apparently the time zones are correct on my machine. Statements : print scalar(localtime)."\n"; print scalar(gmtime)."\n"; Output : Fri Jan 3 20:35:34 2003 Fri Jan 3 15:05:34 2003 India is +5:30. However I think i caught the bug... The statement : elsif (abs($gm[1]-$local[1]-30) <5) should be replaced by : elsif (abs(abs($gm[1]-$local[1])-30) <5) and similarly for the next elsif. The script runs like a spell thereafter :) Thank you so much Keep crooning... :-) aman -Original Message- From: Jenda Krynicky [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 8:37 PM To: [EMAIL PROTECTED] Subject: RE: Sent time in a Net::SMTP mail From: Aman Thind <[EMAIL PROTECTED]> > Thanks a lot Jenda...u're a real wizard :) Shame I can't even get drunk :-} > There are still just two minor issues which I thought I should bring > to your notice... > > The time displayed is 30 mins more than the actual time here. Are you sure the timezone is set correctly on your computer? Could you see what do these two print? print scalar(localtime)."\n"; print scalar(gmtime)."\n"; Do the times look correct? > The To \ From tab now reads : Aman Thind [[EMAIL PROTECTED]]. > Can't I just do away with the email address ? I don't think so. Jenda = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Installing Crypt::IDEA
Hello, I am experiencing some difficulties trying to install the module, Crypt::IDEA, which is required in order for me to use the Net::SSH module. When trying to install this module, I get the following error when attempting to do the "make": >perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Crypt::IDEA >make cp IDEA.pm blib/lib/Crypt/IDEA.pm cp IDEA.pod blib/lib/Crypt/IDEA.pod /usr/local/bin/perl /usr/local/lib/perl5/5.6.1/ExtUtils/xsubpp -typemap /usr/local/lib/perl5/5.6.1/ExtUtils/typemap -typemap typemap IDEA.xs > IDEA.xs c && mv IDEA.xsc IDEA.c Please specify prototyping behavior for IDEA.xs (see perlxs manual) cc -c-D_HPUX_SOURCE -Aa -I/usr/local/include -O -DVERSION=\"1.01\ " -DXS_VERSION=\"1.01\" +z "-I/usr/local/lib/perl5/5.6.1/PA-RISC2.0/CORE" IDE A.c cc: "idea.h", line 5: error 1000: Unexpected symbol: "idea_cblock". cc: error 2017: Cannot recover from earlier errors, terminating. *** Error exit code 1 Stop. Can anyone help me with this? Thank you. Steve Rinehart EDI P/A Utah Dept. of Health -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Clear command in perl?
the system "clear" command merely echo's 2 escape sequences to screen, which are very easy to do by hand. This is idential to what clear does: print "\e[H\e[2J"; -gomes -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I retrieve permissions?
I am writing a program that uses the CHMOD function to set permissions on a file. I'd like to then be able to "read" or "retrieve" the permission value for that file and compare it against what I wanted to set it to to know if it actually did get changed. I searched the fuctions that are built into PERL but didn't find anything that seemed to fit. Can anyone suggest how I can retrieve the permissions on a file? I've tried a GOOGLE search on "perl" and "module" and "permissions" but nothing seemed to fit. Thank you.
Re: glob subtlety question
A little background on my question. Basically I want people to be able to say something like prog page*.html morebookmarks.html For Unix users, I want to be lazy and have the shell glob that for me. For Windows users, I want to be lazy and have the perl function glob that for me. Q1. Could the redundant perl glob be harmful to files that have already been shell globbed in Unix? Q2. If bash globs page*.html and there are no matching files, is that automatically an error even if there are other files are on the command line to be processed? Or does bash consider you to be specifying zero or more files that match page*.html and silently glob it to ''; I have been silently hoping it is the second, but I am not sure. Here is my test script: print "Before perl globbing:\n "; for $arg (@ARGV) {print "- $arg\n";}; my @Robs_way = map glob, @ARGV; print "Rob\'s way:\n"; for $arg (@Robs_way) {print "- $arg\n";}; my @Johns_way = map glob, map { s/(\s)/\\$1/g; $_ } @ARGV; print "John\'s way:\n"; for $arg (@Johns_way) {print "- $arg\n";}; Here is my command line and output: C:\junk>testargs.pl "C:\Documents and Settings\deason\My Documents\xyz\junk test .html" *.html Before perl globbing: - C:\Documents and Settings\deason\My Documents\xyz\junk test.html - *.html Rob's way: - C:./Documents - and - SettingsdeasonMy - Documentsxyzjunk - test.html - junk3.html - px600.html John's way: - C:./Documents and SettingsdeasonMy Documentsxyzjunk test.html - junk3.html - px600.html Looks like I have to try Jenda's way! "Jenda Krynicky" <[EMAIL PROTECTED]> wrote in message 3E1380AA.23905.3D8B65B0@localhost">news:3E1380AA.23905.3D8B65B0@localhost... > From: "Rob Dixon" <[EMAIL PROTECTED]> > > "Jenda Krynicky" <[EMAIL PROTECTED]> wrote in message > > 3E1349E5.27703.3CB576EE@localhost">news:3E1349E5.27703.3CB576EE@localhost... > > > From: "Rob Dixon" <[EMAIL PROTECTED]> > > > > But glob 'absent_file.txt' returns ('absent_file.txt') so I think > > > > this does what's required. As perldoc says, glob EXPR returns the > > > > value of EXPR with filename expansions such as the standard Unix > > > > shell /bin/csh would do. > > > > > > I see ... it only returns nothing if the parameter contained a * or > > > ? > > > > > > I remember having some discussions regarding this and we agreed that > > > even this should survive the cmdline globbing. > > > > Sounds like a little overactive ego on the part of the shell in that > > case. You're saying that the script in > > > > script.pl *.ext file.ext > > > > would see an @ARGV of > > > >('*.ext', 'file.ext') > > > > if there were no files with this extension, but > > > > ('file.ext', 'file1.ext', 'file2.ext', 'file.ext') > > > > if all of these (three) files existed? > > > > Then how do you pass '*.ext' as ('*.ext') if there are such files? > > If we are talking about unix shells > > script.pl '*.ext' file.ext > > And actually that's what will work with G.pm as well. > > And yes you are right, that's exactly what is the shell supposed to > be doing. > > > I > > suppose you can pick up the entire command line (I think?) and process > > that, but I'm very glad most languages don't do clever 'useful' things > > with your parameter list before called code gets to see them. > > The whole problem is that the process gets the commandline if you use > Windows and a list of parameters if you use Unix. > > Normaly the C runtime under Windows parses the commandline and fills > the argv array. Which is exactly what happens if you run a Perl > script under windows. The system passes the cmdline and the runtime > breaks it apart. And breaks it. And your program is supposed to do > the globbing, even though the runtime already stripped some well > needed info. > > The G.pm basicaly overcomes the broken @ARGV and parses the cmdline > and globs the parameters at the same time. Close to the Unix way. > > If you do not want that you either do not use G.pm and glob just the > stuff you want or > use G qw(NOGLOB StripPerlFromCommandLine GetCommandLine); > > $rawcmdline = GetCommandLine(); > $cmdlineparams = StripPerlFromCommandLine($rawcmdline); > > and parse the raw commandline. > (Actually it's not totally raw. The IO redirections and pipes are > already processed by the shell and NOT passed to the process.) > > > > So that you could print > > > > > > Cannot open file *.txt > > > or > > > No files match the *.txt mask > > > > > > > > > If you happen to have several masks with different meanings it might > > > be good to be able to say which one did not return anything. And it > > > may not of course :-) I was told this is the behaviour of the Unix > > > shells ... > > > > > > > Fine, but rather than have the shell performing obscure gymnastics > > beneath me I'd rather code it explicitly: > > > > for (@ARGV) { print "No files match the $_ mask\n" unless glob }; > > my @input_files = map glob, @ARGV; > > Problem is that under Unix the shell IS performing the gymnastics. > > You can quote
RE: Use a hash or multi dimensional array?
yep your right. Type oh. Meant the scalar not the entire hash. :) > -Original Message- > From: Randal L. Schwartz [mailto:[EMAIL PROTECTED]] > Sent: Thursday, January 02, 2003 7:14 PM > To: [EMAIL PROTECTED] > Subject: Re: Use a hash or multi dimensional array? > > > > "Paul" == Paul Kraus <[EMAIL PROTECTED]> writes: > > Paul> use a hash for many reasons. Speed the best. > Paul> your main statement would be > Paul> %hash{$variable}++; > > No it wouldn't. Unless you're coding in Perl6 already. :) > > > Maybe you meant $hash{$variable}++; > > -- > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - > +1 503 777 0095 <[EMAIL PROTECTED]> > 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! > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How do I retrieve permissions?
perldoc -f stat > -Original Message- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 03, 2003 11:13 AM > To: [EMAIL PROTECTED] > Subject: How do I retrieve permissions? > > > > I am writing a program that uses the CHMOD function to set > permissions on a file. I'd like to then be able to "read" or > "retrieve" the permission value for that file and compare it > against what I wanted to set it to to know if it actually did > get changed. I searched the fuctions that are built into PERL > but didn't find anything that seemed to fit. Can anyone > suggest how I can retrieve the permissions on a file? I've > tried a GOOGLE search on "perl" and "module" and > "permissions" but nothing seemed to fit. Thank you. > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How do I retrieve permissions?
On Fri, 3 Jan 2003 11:12:43 -0500, <[EMAIL PROTECTED]> wrote: > > I am writing a program that uses the CHMOD function to set permissions > on a file. I'd like to then be able to "read" or "retrieve" the > permission value for that file and compare it against what I wanted to > set it to to know if it actually did get changed. I searched the > fuctions that are built into PERL but didn't find anything that seemed > to fit. Can anyone suggest how I can retrieve the permissions on a file? > I've tried a GOOGLE search on "perl" and "module" and "permissions" but > nothing seemed to fit. Thank you. > To answer your question you want to have a look at the 'stat' function. perldoc -f stat, specifically the mode entry. As an aside, you should be able to use an 'or' construct with your chmod command to see if it worked, i.e.: chmod 0755, $file or die "Couldn't change permissions on file: $!"; http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: glob subtlety question
From: "David Eason" <[EMAIL PROTECTED]> > A little background on my question. > > Basically I want people to be able to say something like > prog page*.html morebookmarks.html > > For Unix users, I want to be lazy and have the shell glob that for me. > For Windows users, I want to be lazy and have the perl function glob > that for me. > > Q1. Could the redundant perl glob be harmful to files that have > already been shell globbed in Unix? Yes. Keep in mind that under Unix filenames may contain ANY character. Including the asterisks and questionmarks. Also the spaces in the filenames will confuse glob(). > Q2. If bash globs page*.html and there are no matching files, is that > automatically an error even if there are other files are on the > command line to be processed? Or does bash consider you to be > specifying zero or more files that match page*.html and silently glob > it to ''; I have been silently hoping it is the second, but I am not > sure. I believe you'll end up with 'page*.html' if there are no matching files. I can't test it now under Unix, but that's what I was told. > Looks like I have to try Jenda's way! I did not spend the time to write G.pm for nothing. This is one of the issues that look easy at the first glance, but are actually hard to be done right :-) Jenda = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Sent time in a Net::SMTP mail
From: Aman Thind <[EMAIL PROTECTED]> > Apparently the time zones are correct on my machine. > > Statements : > print scalar(localtime)."\n"; > print scalar(gmtime)."\n"; > > Output : > Fri Jan 3 20:35:34 2003 > Fri Jan 3 15:05:34 2003 > > India is +5:30. > > However I think i caught the bug... > > The statement : > > elsif (abs($gm[1]-$local[1]-30) <5) > > should be replaced by : > > elsif (abs(abs($gm[1]-$local[1])-30) <5) > > and similarly for the next elsif. Thanks. (The code was taken directly from Mail::Sender. I applied the fix there as well, it'll be in the upcoming versions ;-) Jenda == [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. -- Rick Osborne, <[EMAIL PROTECTED]> -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Installing Crypt::IDEA
On Friday 03 January 2003 03:47 pm, Steve Rinehart wrote: > Hello, > > I am experiencing some difficulties trying to install the module, > Crypt::IDEA, which is required in order for me to use the Net::SSH > module. > > When trying to install this module, I get the following error when > > attempting to do the "make": > >perl Makefile.PL > > Checking if your kit is complete... > Looks good > Writing Makefile for Crypt::IDEA > > >make > > cp IDEA.pm blib/lib/Crypt/IDEA.pm > cp IDEA.pod blib/lib/Crypt/IDEA.pod > /usr/local/bin/perl /usr/local/lib/perl5/5.6.1/ExtUtils/xsubpp > -typemap > /usr/local/lib/perl5/5.6.1/ExtUtils/typemap -typemap typemap IDEA.xs > > > IDEA.xs > > c && mv IDEA.xsc IDEA.c > Please specify prototyping behavior for IDEA.xs (see perlxs manual) > cc -c-D_HPUX_SOURCE -Aa -I/usr/local/include -O > -DVERSION=\"1.01\ > " -DXS_VERSION=\"1.01\" +z > "-I/usr/local/lib/perl5/5.6.1/PA-RISC2.0/CORE" IDE > A.c > cc: "idea.h", line 5: error 1000: Unexpected symbol: "idea_cblock". > cc: error 2017: Cannot recover from earlier errors, terminating. > *** Error exit code 1 > > Stop. > > > Can anyone help me with this? > > Thank you. > > Steve Rinehart > EDI P/A > Utah Dept. of Health Steve, On my *BSD boxes most perl crypto modules already have a ported interface. On my FreeBSD machine the port for Crypt-IDEA is "p5-Crypt-IDEA". I always check the BSD ports before installing from CPAN. OS specific ported perl interface modules usually install with much less hassle. Check your OS ports for ported perl modules. I'm not sure about ported perl crypto interfaces for Windows. nyec -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: How do I retrieve permissions?
Thank you! -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 11:28 AM To: Copits Richard; [EMAIL PROTECTED] Subject: RE: How do I retrieve permissions? On Fri, 3 Jan 2003 11:12:43 -0500, <[EMAIL PROTECTED]> wrote: > > I am writing a program that uses the CHMOD function to set permissions > on a file. I'd like to then be able to "read" or "retrieve" the > permission value for that file and compare it against what I wanted to > set it to to know if it actually did get changed. I searched the > fuctions that are built into PERL but didn't find anything that seemed > to fit. Can anyone suggest how I can retrieve the permissions on a > file? I've tried a GOOGLE search on "perl" and "module" and > "permissions" but nothing seemed to fit. Thank you. > To answer your question you want to have a look at the 'stat' function. perldoc -f stat, specifically the mode entry. As an aside, you should be able to use an 'or' construct with your chmod command to see if it worked, i.e.: chmod 0755, $file or die "Couldn't change permissions on file: $!"; http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Why Perl kicks but!
Perl has got to be one of the best most efficient and logical languages I have ever learned. I learned it as a hobby with some free time at work (well I am learning anyways). With in the first 2 weeks I found a use for it in my work nearly every day. It has automated many tasks that used to be a pain and solved a 40,000 dollar accounting error in 15 minutes. Where 2 months of ago it would have probably taken us 3 weeks to do it. Just the way the language is ordered has taught me to approach problems in a completely different way. PERL is the shit! Just in case you where wondering and I know you where :) Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to add atachments in NET::SMTP
How to add atachments in NET::SMTP
Extracting an Atachment From a Email
Sign L Rakhitha Malinda Karunarathne Web :- rakhitha.cjb.net Email :[EMAIL PROTECTED] Rakhitha Malinda Karunarathne. I'm Using NET:POP3 to download mail from pop server which is in the same computer with my cgi 1. All the Attachments are comes as a Bulk of text How do I convert it into real binary file? Is Is there a Special Module for that purpose 2. How do I attach a file to email by converting it into a bulk of text? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How to add atachments in NET::SMTP
From: "LRMK" <[EMAIL PROTECTED]> > How to add atachments in NET::SMTP > You use either MIME::Lite or Mail::Sender. Jenda = [EMAIL PROTECTED] === 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 PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Clear command in perl?
On Fri, Jan 03, 2003 at 10:52:27AM -0500, [EMAIL PROTECTED] wrote: > the system "clear" command merely echo's 2 escape sequences to screen, which > are very easy to do by hand. This is idential to what clear does: > > print "\e[H\e[2J"; Or let clear tell you what it does: perl -e 'my $clear = `clear`; print $clear' -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: deleting elements of an array and push into new
Ramprasad wrote: > Hello all, > I have to remove elements from an array if they match a particualr > string and put it into another array > > eg if element matches index or default I want it to be in a new array > > I am trying this > my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); > > > # the following does not compile > #map {s/^(index|default).*/{push @new,$_}/e && delete $_ } @arr; > > > #This works but it does not remove the array element > map {s/^(index|default).*/{push @new,$_}/e && undef $_ } @arr; > > print Dumper([\@new,\@arr]); > > I get > $VAR1 = [ >[ > 'index.html' >], >[ > '01.html', > undef, > 'aa.html', > 'bb.html', > 'cc.html', > 'dd.html' >] > ]; > > the element $arr[1] is undefed but not removed from the array > > > Can I delete the element somehow > I am going to run this for about 60,000 arrays and I cant afford > needless if's and foreach's > > > > Thanks > Ram you might want to try: #!/usr/bin/perl -w use strict; my @index; my @pages = qw(index.html a.html default.html b.html c.html default2.html); @pages = grep{$_}map{/^(index|default)/?push(@index,$_) && undef:$_} @pages; print "@pages\n"; print "@index\n"; __END__ but is slow. david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: ANDing IP addresses
On Tue, 2002-12-31 at 10:12, Mark Goland wrote: > I know there was already solution posted... Ditto. I'm a bit late with this, but there's plenty of example code in the IP::Country distribution of AND'ing IP addresses and looping through subnet masks. I tend to use only pack('N',... as this seems to be the friendliest format for cross-platform binary files. http://search.cpan.org/author/NWETTERS/IP-Country-2.07/ -- Nigel Wetters <[EMAIL PROTECTED]> Perl Developer, Sun Certified Java Programmer 123 Ravensbury Road, London SW18 4RY Tel. 020 8944 8633 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Comparing file sizes
Hello all. I'm trying to compare the size of two files in a script. I know I can open them, feed each into an array, and compare the number of lines, but that seems silly and inefficient. I tried using File::stat in the following manner: $file1 = stat($firstFile); $file2 = stat($secondFile); if ($file1->size > $file2->size) { blahblahblah; } Everytime the script gets to these lines, the stat function fails, and the program exits. Am I doing somthing wrong? I'm using perl 5.8.0 on Redhat 8.0. Thanks for the help, Brian
RE: Comparing file sizes
I tried but am using AS 5.6.0 under w2k. The first time it complained because I did not have the file setup correctly and it died. After correcting that it worked. This is the code: use File::stat; my $firstFile = 'd:/Currwrka/00CommonPerl/03aaplxxx/aapl001.pl'; my $secondFile = 'd:/Currwrka/00CommonPerl/03aaplxxx/aapl002.pl'; my $file1 = stat($firstFile); my $file2 = stat($secondFile); if ($file1->size > $file2->size) { printf "file1 greater than file2"; }else { printf "file2 greater than file1"; } Wags ;) ps R you running with warnings? strict? -Original Message- From: Brian McGraw [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 11:10 To: [EMAIL PROTECTED] Subject: Comparing file sizes Hello all. I'm trying to compare the size of two files in a script. I know I can open them, feed each into an array, and compare the number of lines, but that seems silly and inefficient. I tried using File::stat in the following manner: $file1 = stat($firstFile); $file2 = stat($secondFile); if ($file1->size > $file2->size) { blahblahblah; } Everytime the script gets to these lines, the stat function fails, and the program exits. Am I doing somthing wrong? I'm using perl 5.8.0 on Redhat 8.0. Thanks for the help, Brian ** This message contains information that is confidential and proprietary to FedEx Freight or its affiliates. It is intended only for the recipient named and for the express purpose(s) described therein. Any other use is prohibited. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: glob subtlety question
The following has the same output as John's way: my @Bobs_way = glob "@ARGV" unless ! @ARGV; print "Bob\'s way:\n"; for $arg (@Bobs_way) {print "- $arg\n";}; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
References ch 8 programming Perl
Ok a couple questions on Ref from pg 251 programming Perl. push @$arrrayref,$filename); $$arrayref[0]="January"; @$arrayref[4..6]=qw/May June July/; So this is actually creating an anonymous array that it then references correct? so the assignments January ect are being made to an anonymous array. This is cool but maybe I am missing the point. Why would you use these references rather then just using the actual variable? If some one could give me some real world applications for this I would be most appreciative. I have seen them used to simulate a multidimensional array as well has hash and that makes sense. But beyond that I am kind of at a loss. Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: References ch 8 programming Perl
> push @$arrrayref,$filename); > $$arrayref[0]="January"; > @$arrayref[4..6]=qw/May June July/; > > So this is actually creating an anonymous array that it then > references > correct? > so the assignments January ect are being made to an anonymous array. Yes > > This is cool but maybe I am missing the point. Why would you use these > references rather then just using the actual variable? > If some one could give me some real world applications for > this I would > be most appreciative. i think the idea is to start of with easy examples so you can see how the refs work. > > I have seen them used to simulate a multidimensional array as well has > hash and that makes sense. But beyond that I am kind of at a loss. I use them alot (like you say) to push on array onto another without clobbering the first one. I also create anon refs to arrays to pass to subroutines if they are large arrays, instead of passing the entire large array by value to a sub. You will see alot of useful things for them when you get to the data structures part of the book. HTH, Jim -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Why Perl kicks but!
"Paul Kraus" <[EMAIL PROTECTED]> wrote in message 00e101c2b34e$47871010$64fea8c0@pkrausxp">news:00e101c2b34e$47871010$64fea8c0@pkrausxp... > PERL is the shit! Some among the global readership may not be familiar with this American idiom. This is high praise indeed. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: References ch 8 programming Perl
I use anonymouse variables all the time. Basically in dynamic database applications. It makes very complicated things a bit easier : @files = `ls /home/user`; foreach $file(@files) { open file... @$file = ; close file... } Open fileto contrain contents of all files ... foreach $file(@files) { print FILEHANDLE2 "\n -- begin $file - \n"; print FILEHANDLE2 @$file; print FILEHANDLE2 "\n -- end $file - \n"; } Close fileto contrain contents of all files... Just a quick example Dan -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 2:02 PM To: 'Perl' Subject: References ch 8 programming Perl Ok a couple questions on Ref from pg 251 programming Perl. push @$arrrayref,$filename); $$arrayref[0]="January"; @$arrayref[4..6]=qw/May June July/; So this is actually creating an anonymous array that it then references correct? so the assignments January ect are being made to an anonymous array. This is cool but maybe I am missing the point. Why would you use these references rather then just using the actual variable? If some one could give me some real world applications for this I would be most appreciative. I have seen them used to simulate a multidimensional array as well has hash and that makes sense. But beyond that I am kind of at a loss. Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: References ch 8 programming Perl
Another thing I use a lot is to take form input and build sql queries based on what is input for instance Say I want to search a table withh twenty columns If I have a form with all 20 columns that they can enter something to look for in each field thay will probably only use a few so I go @params = $cgi->params; $where = "WHERE"; Foreach $p(@params) { $where .= " $p=\'$cgi->param($p)\' AND"; } $where =~ s/AND$//; $query = "SELECT FROM tablemonkey $where"; Execute $query Or without annoymous references I could always go If($cgi->param('joemama')) { $where .= " joemama=\'$cgi->param('joemama')\'"; } If($cgi... For all twenty, which would be time consuming and then what if I change the table? I have to go in and modift this everytime which will make it more likelyt errors will creep in and is just big and ugly Anywho hope that helps Dan -Original Message- From: Dan Muey Sent: Friday, January 03, 2003 3:17 PM To: Perl Subject: RE: References ch 8 programming Perl I use anonymouse variables all the time. Basically in dynamic database applications. It makes very complicated things a bit easier : @files = `ls /home/user`; foreach $file(@files) { open file... @$file = ; close file... } Open fileto contrain contents of all files ... foreach $file(@files) { print FILEHANDLE2 "\n -- begin $file - \n"; print FILEHANDLE2 @$file; print FILEHANDLE2 "\n -- end $file - \n"; } Close fileto contrain contents of all files... Just a quick example Dan -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 2:02 PM To: 'Perl' Subject: References ch 8 programming Perl Ok a couple questions on Ref from pg 251 programming Perl. push @$arrrayref,$filename); $$arrayref[0]="January"; @$arrayref[4..6]=qw/May June July/; So this is actually creating an anonymous array that it then references correct? so the assignments January ect are being made to an anonymous array. This is cool but maybe I am missing the point. Why would you use these references rather then just using the actual variable? If some one could give me some real world applications for this I would be most appreciative. I have seen them used to simulate a multidimensional array as well has hash and that makes sense. But beyond that I am kind of at a loss. Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Why Perl kicks but!
David and everybody else, To me, Perl is a tool to be used when other tools don't fit. It's great to be able to write a program that will run on just about every Windows and Unix box ever made, but it's hell trying to use structures more complicated than a hash. Give me Visual Basic first, and then C++. Perl is a last resort. Rob __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: References ch 8 programming Perl
Surprised no one has mentioned it, but the complete foundation of Object Oriented Perl is based on the ability to bless a referent into a particular namespace. So obviously once/if you get into OOP references play a major role. Along these lines is the ability to pass multiple different types of data into and out of subroutines, so that a sub may perform and return different types of actions and data based on what it was given. (perldoc -f ref) http://danconia.org On Fri, 3 Jan 2003 15:02:09 -0500, "Paul Kraus" <[EMAIL PROTECTED]> wrote: > Ok a couple questions on Ref from pg 251 programming Perl. > > push @$arrrayref,$filename); > $$arrayref[0]="January"; > @$arrayref[4..6]=qw/May June July/; > > So this is actually creating an anonymous array that it then references > correct? > so the assignments January ect are being made to an anonymous array. > > This is cool but maybe I am missing the point. Why would you use these > references rather then just using the actual variable? > If some one could give me some real world applications for this I would > be most appreciative. > > I have seen them used to simulate a multidimensional array as well has > hash and that makes sense. But beyond that I am kind of at a loss. > > Paul Kraus > Network Administrator > PEL Supply Company > 216.267.5775 Voice > 216-267-6176 Fax > www.pelsupply.com > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
dealing with funky characters
what i would like to do is the following::: open a file of undetermined format, take all non alphanumeric characters (other than spaces, tabs, \n etc) and parse the output around them... open (IN,"file.unknown"); while () { s/insert regular expression here/\n\n; push(@array,$_); # or just shunt it out to another file :P } i'd love suggestions on this :) also, if memory serves, each time the regular expression is matched, then $1..$n gets the match value (or am i thinking of something else? i would like to be able to manipulate them at some other point in the program- maybe find the use of various unknown tags, or substitute them with html tags that would make the document more legible. (not very worried about that right now though) thank you, willy -- Bill Gates is a man who loves EULAs, If you break his contract he'll just sue ya', If you do any sharing, He'll set you to swearing, So use GPL and shout 'booya'!! - This mail sent through IMP: http://horde.org/imp/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: deleting elements of an array and push into new
Ramprasad wrote: > > Hello all, Hello, > I have to remove elements from an array if they match a particualr > string and put it into another array > > eg if element matches index or default I want it to be in a new array > > I am trying this > my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); > > # the following does not compile > #map {s/^(index|default).*/{push @new,$_}/e && delete $_ } @arr; > > #This works but it does not remove the array element > map {s/^(index|default).*/{push @new,$_}/e && undef $_ } @arr; > > print Dumper([\@new,\@arr]); > > I get > $VAR1 = [ >[ > 'index.html' >], >[ > '01.html', > undef, > 'aa.html', > 'bb.html', > 'cc.html', > 'dd.html' >] > ]; > > the element $arr[1] is undefed but not removed from the array > > Can I delete the element somehow > I am going to run this for about 60,000 arrays and I cant afford > needless if's and foreach's my @new; my @arr = qw( 01.html index.html aa.html bb.html cc.html dd.html ); push @{ /^(?:index|default)/ ? \@new : \@arr }, $_ for splice @arr; print Dumper( [ \@new, \@arr ] ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Why Perl kicks but!
On Fri, Jan 03, 2003 at 01:42:58PM -0800, Rob Richardson wrote: > Give me Visual Basic first, and then C++. Perl is a last resort. Hmmm. That's interesting. Perl doesn't seem to fit everyone's way of thinking. I'm not sure whether that's a problem with Perl, or some people's thinking ;-) Actually, it can take a while to think the "perl way", but when you do it often helps your programming in other languages. (Commenting generally rather than on you specifically.) Me, I would reverse your list. Fortunately, I've never had to get to the end of it :-) -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Sent time in a Net::SMTP mail
Jenda Krynicky wrote: > > #time diference to GMT - Windows will not set $ENV{'TZ'}, if you know a better way >... > my $GMTdiff; > { > my $time = time(); > my @local = (localtime($time))[2,1,3,4,5]; # hour, minute, mday, month, >year; I don't mind year is 1900 based and month 0-11 > my @gm = (gmtime($time))[2,1,3,4,5]; > my $diffdate = ($gm[4]*512*32 + $gm[3]*32 + $gm[2]) <=> ($local[4]*512*32 + >$local[3]*32 + $local[2]); # I know there are 12 months and 365-366 days. Any bigger >numbers work fine as well ;-) > if ($diffdate > 0) {$gm[0]+=24} > elsif ($diffdate < 0) {$local[0]+=24} > my $hourdiff = $gm[0]-$local[0]; > my $mindiff; > if (abs($gm[1]-$local[1])<5) { > $mindiff = 0 > } elsif (abs($gm[1]-$local[1]-30) <5) { > $mindiff = 30 > } elsif (abs($gm[1]-$local[1]-60) <5) { > $mindiff = 0; > $hourdiff ++; > } > $GMTdiff = ($hourdiff < 0 ? '+' : '-') . sprintf "%02d%02d", abs($hourdiff), >$mindiff; > } > my $date = localtime(); > $date =~ s/^(\w+)\s+(\w+)\s+(\d+)\s+(\d+:\d+:\d+)\s+(\d+)$/$1, $3 $2 $5 $4/; > $smtp->datasend("Date: $date $GMTdiff\n"; Or, you could do it the "correct" way. :-) use POSIX 'strftime'; my $date = strftime '%a, %d %b %Y %H:%M:%S %z', localtime; $smtp->datasend( "Date: $date\n" ); John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: References ch 8 programming Perl
Paul Kraus wrote: > > Ok a couple questions on Ref from pg 251 programming Perl. > > push @$arrrayref,$filename); > $$arrayref[0]="January"; > @$arrayref[4..6]=qw/May June July/; > > So this is actually creating an anonymous array that it then references > correct? > so the assignments January ect are being made to an anonymous array. No, an anonymous array is delimited by [ and ]. That is creating an actual array that is only accessible through an array reference. my $ref = [ 1, 2, 3, 4, 5 ]; ^ anonymous array > This is cool but maybe I am missing the point. Why would you use these > references rather then just using the actual variable? > If some one could give me some real world applications for this I would > be most appreciative. A reference is a scalar so it is a lot easier to pass around between subroutines then the entire array contents. You have to remember though that modifying something through a reference will modify the original. > I have seen them used to simulate a multidimensional array as well has > hash and that makes sense. But beyond that I am kind of at a loss. If you are used to data structures in other languages then you may find Perl's data structures pretty limited (I know I did :-).) However Perl's other features more then make up for this. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Why Perl kicks but!
To me Visual Basic is retarded , not even a last resort. At best a good tool to use to learn some basic concepts of programming to move on to a better one like C or a variant. But that's just me. If you don't like perl don't use it and go join a visual basic mailing list. As for me I don't like visual basic so I don't use it and I don't post to mailing lists for it explaining that all of these 1000's of users are dumb to use such a language. I personally like perl very much for plenty of reasons. But why get into a big fight over 'my daddy can beat up your daddy'; It's not 'hell' trying to use data structures more complicated than a hash. It's quite elegant and simple once you do it a bit. Unless you've never done it then it may be, just as riding a bike or tieing your shoes or not crapping in your pants was 'like hell' at one time or another in your life. Sorry, enough ranting I've had quite a day with no one to take it out on. I apologize. Dan -Original Message- From: Rob Richardson [mailto:[EMAIL PROTECTED]] Sent: Friday, January 03, 2003 3:43 PM To: [EMAIL PROTECTED] Subject: Re: Why Perl kicks but! David and everybody else, To me, Perl is a tool to be used when other tools don't fit. It's great to be able to write a program that will run on just about every Windows and Unix box ever made, but it's hell trying to use structures more complicated than a hash. Give me Visual Basic first, and then C++. Perl is a last resort. Rob __ Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now. http://mailplus.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: dealing with funky characters
Willy wrote: > > what i would like to do is the following::: > > open a file of undetermined format, > take all non alphanumeric characters (other than spaces, tabs, \n etc) > and parse the output around them... What about punctuation characters? > open (IN,"file.unknown"); You should _always_ verify that the file was opened. > while () > { >s/insert regular expression here/\n\n; >push(@array,$_); # or just shunt it out to another file :P > } > > i'd love suggestions on this :) also, if memory serves, each time > the regular expression is matched, then $1..$n gets the match value (or > am i thinking of something else? Only if the match value is enclosed in parentheses. > i would like to be able to manipulate them at some other point > in the program- maybe find the use of various unknown tags, or > substitute them with html tags that would make the document more > legible. (not very worried about that right now though) There are various modules available on CPAN that allow you to manipulate HTML documents. http://search.cpan.org/ John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Why Perl kicks but!
Can I ask you a few questions: Dan Muey wrote: > To me Visual Basic is retarded , not even a last resort. How long have you been using VB and what version are you most familiar with? > As for me I don't like visual basic so I don't use it and I don't > post to mailing lists for it explaining that all of these 1000's of users > are dumb to use such a language. do you know how many VB developers are in the US alone? thanks! david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: References ch 8 programming Perl
On Fri, Jan 03, 2003 at 03:33:30PM -0800, John W. Krahn wrote: > Paul Kraus wrote: > > > > Ok a couple questions on Ref from pg 251 programming Perl. > > > > push @$arrrayref,$filename); > > $$arrayref[0]="January"; > > @$arrayref[4..6]=qw/May June July/; > > > > So this is actually creating an anonymous array that it then references > > correct? > > so the assignments January ect are being made to an anonymous array. > > No, an anonymous array is delimited by [ and ]. That is creating an > actual array that is only accessible through an array reference. > > my $ref = [ 1, 2, 3, 4, 5 ]; > ^ >anonymous array Not worth picking a fight over, to be sure, but I don't see the difference. Assuming $arrayref didn't exist before, then after each of those three examples it will, and it will be a reference to an array with no name. Seems to me that Paul got it spot on. > > I have seen them used to simulate a multidimensional array as well has > > hash and that makes sense. But beyond that I am kind of at a loss. > > If you are used to data structures in other languages then you may find > Perl's data structures pretty limited (I know I did :-).) However > Perl's other features more then make up for this. I'm not quite sure what to make of that either. Which languages and data structures are you comparing against? In a language like C, you have to build everything yourself. In C++ you might use the STL, but I think you'd have to compare that against CPAN to be fair. It is, of course, quite possible to build ADTs in Perl - it just seems to be less necessary, as you note. -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: References ch 8 programming Perl
Paul Johnson wrote: > > On Fri, Jan 03, 2003 at 03:33:30PM -0800, John W. Krahn wrote: > > Paul Kraus wrote: > > > > > > Ok a couple questions on Ref from pg 251 programming Perl. > > > > > > push @$arrrayref,$filename); > > > $$arrayref[0]="January"; > > > @$arrayref[4..6]=qw/May June July/; > > > > > > So this is actually creating an anonymous array that it then references > > > correct? > > > so the assignments January ect are being made to an anonymous array. > > > > No, an anonymous array is delimited by [ and ]. That is creating an > > actual array that is only accessible through an array reference. > > > > my $ref = [ 1, 2, 3, 4, 5 ]; > > ^ > >anonymous array > > Not worth picking a fight over, to be sure, but I don't see the > difference. Assuming $arrayref didn't exist before, then after each of > those three examples it will, and it will be a reference to an array > with no name. Seems to me that Paul got it spot on. You are saying that it has no name but it does: arrayref. If it truly had "no name" then there would be no way to access it anywhere else in the program. John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Crypting
Does anyone know a good place to start on encryption socket streams ?? Mark -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]