Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: Is there a way to compare strings without using an array?

by Jeri (Scribe)
on Oct 18, 2011 at 19:34 UTC ( #932224=note: print w/replies, xml ) Need Help??

in reply to Re: Is there a way to compare strings without using an array?
in thread Is there a way to compare strings without using an array?

say for $line1 =~ /[$line2]/g;

it complains...

Bareword "say" not allowed while "strict subs"

when I delete say, it complains...

syntax error at line 8, near "$line1 =~"

What's the trick to this sting comparison?


Replies are listed 'Best First'.
Re^3: Is there a way to compare strings without using an array? (say)
by toolic (Bishop) on Oct 18, 2011 at 19:45 UTC
      thanks, it's working

      Why is it necessary to use 'say'? If I took out..

      use feature 'say';

      and the 'say' in...

       say for $line1 =~ /[$line2]/g;

      Why doesn't it work?

        The reason is because say is not (yet) a built-in function. You have to import the function into your namespace first, hence use feature 'say';

        Alternatively, you can just use print, which does not implicitly add the new line for you like say does.

        print "$_\n" for $line1 =~ /[$line2]/g;
        You can also add the -l (dash elle) modifier to your "shebang" line which essentially makes print behave like say:
        #!/path/to/perl -l ... print for $line1 =~ /[$line2]/g;
        Hope this helps!


        (the triplet paradiddle with high-hat)

        use feature qw( say ); or equivalent is required for backwards compatibility reasons. Many scripts and modules already had a sub named say when say was added to Perl, so it's not available by default in order to avoid breaking these scripts and modules.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://932224]
Corion idly wonders about creating a series of HTTP requests. There seems to be no framework to generate a series of HTTP requests, like "try all these requests"
[Corion]: This is vaguely inspired by that list of "nasty" strings, which I'd like to replace among HTTP parameters, just to see whether the application crashes, but also for easy downloading of a list of URLs etc
[Corion]: Maybe I'll just conoct something using Algorithm::Permute to create an (OO) generator for such requests, or a simple function.
[Corion]: For testing I imagine one would want to test a random sampling of such "bad"/"unexpected" requests, while for downloading, one would want to generate them all in order, but not necessarily as a huge list

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-01-16 15:40 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (151 votes). Check out past polls.