Re: Strings with @
by diotalevi (Canon) on Mar 09, 2006 at 21:16 UTC
|
You also need to change how you wrote your open() call. Use either of these forms but don't use what you have now. It's terminally buggy. open IN, "<", "netapps" or die "Can't open file";open( IN, "<", "netapps" ) || die "Can't open file";
| [reply] [d/l] [select] |
|
|
open my $in, "<", "netapps"
or die "Can't open file 'netapps' for read:$!";
:-)
---
$world=~s/war/peace/g
| [reply] [d/l] |
|
|
| [reply] [d/l] |
|
|
Re: Strings with @
by shiza (Hermit) on Mar 09, 2006 at 20:47 UTC
|
Actually, don't you need single quotes instead of double?
my $recipient = 'some.g.guy@bigcorporation.com';
You could use double quotes but you need to escape the @:
my $recipient = "some.g.guy\@bigcorporation.com";
| [reply] [d/l] [select] |
Re: Strings with @
by Marcello (Hermit) on Mar 09, 2006 at 20:50 UTC
|
It depends, you can use single quotes like:
my $recipient = 'some.g.guy@bigcorporation.com';
or double quotes with a backslash before the @ character so it will not be interpolated:
my $recipient = "some.g.guy\@bigcorporation.com";
| [reply] [d/l] [select] |
Re: Strings with @
by ayrnieu (Beadle) on Mar 10, 2006 at 06:19 UTC
|
#! /usr/bin/env perl
use strict;
use warnings;
open my $f, 'netapsp' or die "open failed: $!";
my $recip = 'some.g.guy@bigcorp.com';
while (<$f>) {
chomp;
system "rsh $_ quota report | mail $recip" and die "rsh failed: $!";
}
Morever, with such a simple program you've little excuse to not use tainting (perldoc perlsec), which would've suggested that you verify what you get from 'netapps' rather than blindly pass it to a shell. | [reply] [d/l] |
|
|
while (<$f>) {
chomp;
system "rsh $_ quota report | mail $recip" and die "rsh failed: $!";
}
shouldn't that be or die rather than and die? | [reply] [d/l] [select] |
|
|
| [reply] |
Re: Strings with @
by matze (Friar) on Mar 09, 2006 at 20:38 UTC
|
Shouldn't you quote your email-address?
my $recipient="some.g.guy\@bigcorporation.com";
Otherwise perl is expecting some code after the =.
Update: added escaping of '@'. Forgot about that. | [reply] [d/l] [select] |
|
|
Actually he needs to use '' or q{}, otherwise the @bigcorporation will be interpreted as the name of an array and he'll get a different message.
Update: Not to mention changing || to or, or else adding some parens in that open statement.
| [reply] [d/l] [select] |
|
|
Actualy that will try to find the aray @bigcorporation.
better yet:
my $recipient= q{some.g.guy@bigcorporation.com};
this way no interpitation will take place.
Ron... | [reply] [d/l] |
Re: Strings with @
by Anonymous Monk on Mar 09, 2006 at 20:49 UTC
|
| [reply] [d/l] |
Re: Strings with @
by vickym (Novice) on Mar 10, 2006 at 12:15 UTC
|
The '@' symbol is used for array variable. You need to prefix the @ symbol with an escape sequence '\'.
eg: my $recipient="some.g.guy\@bigcorporation.com";
Try it.
| [reply] |
Re: Strings with @
by bravenmd (Sexton) on Mar 10, 2006 at 20:35 UTC
|
First thing you need is some kind of quoting around the email address. Then depending on which quoting system you use you may need to escape the @ character. Perl is mistaking the '@bigcorporation' for an array.
You can try either:
'some.g.guy@bigcorporation.com',
q~some.g.guy@bigcorporation.com~,
q{some.g.guy@bigcorporation.com},
"some.g.guy\@bigcorporation.com",
etc. all of which should work
Hope this helps! | [reply] |
Re: Strings with @
by Anonymous Monk on Mar 10, 2006 at 09:37 UTC
|
my$ recipient=some.g.guy@bigcorporation.com;
should be
my $recipient = "some.g.guy\@bigcorporation.com";
| [reply] [d/l] [select] |