using a help file to populate ftp values
- From: Cal Dershowitz <cal@xxxxxxxxxxxxxxx>
- Date: Wed, 01 Aug 2012 20:14:36 -0600
On 08/01/2012 04:11 AM, Wolf Behrenhoff wrote:
Am 01.08.2012 08:00, schrieb Cal Dershowitz:if (/\$domain\) {
print "matched\n";
$word =~ m/
This is the whole match! From the first / right after the if to the
second one which only appears 2 lines later.
You simply forgot to end the match with / and used the \ instead.
Thanks, wolf. I get times where I can't see the difference between the forward and backslash. I call it "Dual-Boot Fatigue Syndrome."
$ perl safe_post4.pl
matched
my $domain = 'www.bedrock.com';
word is www.bedrock.com
matched
my $username = 'barney';
word is barney
matched
my $password = 'rocks';
word is rocks
$ cat safe_post4.pl
#!/usr/bin/perl -w
use strict;
use 5.010;
use Net::FTP;
my ( $domain, $username, $password );
my $identity_file = 'ftp_passwords_1.txt';
my ( @lines, $word );
open( my $gh, '<', $identity_file )
or die("Can't open $identity_file for writing: $!");
chomp( @lines = <$gh> );
close $gh;
foreach (@lines) {
if (/\$domain/) {
print "matched\n";
print $_ . "\n";
m/'(.*)'/;
$domain = $1;
print "word is $domain\n";
}
}
foreach (@lines) {
if (/\$username/) {
print "matched\n";
print $_ . "\n";
m/'(.*)'/;
$username = $1;
print "word is $username\n";
}
}
foreach (@lines) {
if (/\$password/) {
print "matched\n";
print $_ . "\n";
m/'(.*)'/;
$password = $1;
print "word is $password\n";
}
}
$
This works, but I wouldn't be too wild about seeing it included in all my ftp scripts.
Q1) How could one read the word $domain or anything with a dollar sign on it in the help file and then declare it at top scope in the script?
.
- Follow-Ups:
- Re: using a help file to populate ftp values
- From: Ben Morrow
- Re: using a help file to populate ftp values
- From: Jürgen Exner
- Re: using a help file to populate ftp values
- References:
- Re: a regex for removing a password in a source listing
- From: Cal Dershowitz
- Re: a regex for removing a password in a source listing
- From: Wolf Behrenhoff
- Re: a regex for removing a password in a source listing
- Prev by Date: Re: "is-numeric" check?
- Next by Date: Re: a regex for removing a password in a source listing
- Previous by thread: Re: a regex for removing a password in a source listing
- Next by thread: Re: using a help file to populate ftp values
- Index(es):